blob: 71a986e9b694d672823a87c17260f8fd39882e24 [file] [log] [blame]
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +00001#include <linux/device.h>
2#include <linux/mod_devicetable.h>
3
4struct gio_device_id {
5 __u8 id;
6};
7
8struct gio_device {
Ralf Baechle70342282013-01-22 12:59:30 +01009 struct device dev;
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000010 struct resource resource;
Ralf Baechle70342282013-01-22 12:59:30 +010011 unsigned int irq;
12 unsigned int slotno;
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000013
Ralf Baechle70342282013-01-22 12:59:30 +010014 const char *name;
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000015 struct gio_device_id id;
Ralf Baechle70342282013-01-22 12:59:30 +010016 unsigned id32:1;
17 unsigned gio64:1;
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000018};
19#define to_gio_device(d) container_of(d, struct gio_device, dev)
20
21struct gio_driver {
22 const char *name;
23 struct module *owner;
24 const struct gio_device_id *id_table;
25
26 int (*probe)(struct gio_device *, const struct gio_device_id *);
27 void (*remove)(struct gio_device *);
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000028 void (*shutdown)(struct gio_device *);
29
30 struct device_driver driver;
31};
32#define to_gio_driver(drv) container_of(drv, struct gio_driver, driver)
33
34extern const struct gio_device_id *gio_match_device(const struct gio_device_id *,
35 const struct gio_device *);
36extern struct gio_device *gio_dev_get(struct gio_device *);
37extern void gio_dev_put(struct gio_device *);
38
39extern int gio_device_register(struct gio_device *);
40extern void gio_device_unregister(struct gio_device *);
41extern void gio_release_dev(struct device *);
42
43static inline void gio_device_free(struct gio_device *dev)
44{
45 gio_release_dev(&dev->dev);
46}
47
48extern int gio_register_driver(struct gio_driver *);
49extern void gio_unregister_driver(struct gio_driver *);
50
Thomas Bogendoerfer1d421ca2014-06-04 12:00:37 +020051#define gio_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
52#define gio_set_drvdata(_dev, data) dev_set_drvdata(&(_dev)->dev, (data))
Thomas Bogendoerfere84de0c2011-11-22 14:38:02 +000053
54extern void gio_set_master(struct gio_device *);