1
2
3
4
5
6
7
8
9
10 #ifndef MDEV_H
11 #define MDEV_H
12
13 struct mdev_device;
14
15
16
17
18
19
20
21
22
23
24
25 int mdev_set_iommu_device(struct device *dev, struct device *iommu_device);
26
27 struct device *mdev_get_iommu_device(struct device *dev);
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 struct mdev_parent_ops {
79 struct module *owner;
80 const struct attribute_group **dev_attr_groups;
81 const struct attribute_group **mdev_attr_groups;
82 struct attribute_group **supported_type_groups;
83
84 int (*create)(struct kobject *kobj, struct mdev_device *mdev);
85 int (*remove)(struct mdev_device *mdev);
86 int (*open)(struct mdev_device *mdev);
87 void (*release)(struct mdev_device *mdev);
88 ssize_t (*read)(struct mdev_device *mdev, char __user *buf,
89 size_t count, loff_t *ppos);
90 ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
91 size_t count, loff_t *ppos);
92 long (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
93 unsigned long arg);
94 int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
95 };
96
97
98 struct mdev_type_attribute {
99 struct attribute attr;
100 ssize_t (*show)(struct kobject *kobj, struct device *dev, char *buf);
101 ssize_t (*store)(struct kobject *kobj, struct device *dev,
102 const char *buf, size_t count);
103 };
104
105 #define MDEV_TYPE_ATTR(_name, _mode, _show, _store) \
106 struct mdev_type_attribute mdev_type_attr_##_name = \
107 __ATTR(_name, _mode, _show, _store)
108 #define MDEV_TYPE_ATTR_RW(_name) \
109 struct mdev_type_attribute mdev_type_attr_##_name = __ATTR_RW(_name)
110 #define MDEV_TYPE_ATTR_RO(_name) \
111 struct mdev_type_attribute mdev_type_attr_##_name = __ATTR_RO(_name)
112 #define MDEV_TYPE_ATTR_WO(_name) \
113 struct mdev_type_attribute mdev_type_attr_##_name = __ATTR_WO(_name)
114
115
116
117
118
119
120
121
122
123 struct mdev_driver {
124 const char *name;
125 int (*probe)(struct device *dev);
126 void (*remove)(struct device *dev);
127 struct device_driver driver;
128 };
129
130 #define to_mdev_driver(drv) container_of(drv, struct mdev_driver, driver)
131
132 void *mdev_get_drvdata(struct mdev_device *mdev);
133 void mdev_set_drvdata(struct mdev_device *mdev, void *data);
134 const guid_t *mdev_uuid(struct mdev_device *mdev);
135
136 extern struct bus_type mdev_bus_type;
137
138 int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);
139 void mdev_unregister_device(struct device *dev);
140
141 int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
142 void mdev_unregister_driver(struct mdev_driver *drv);
143
144 struct device *mdev_parent_dev(struct mdev_device *mdev);
145 struct device *mdev_dev(struct mdev_device *mdev);
146 struct mdev_device *mdev_from_dev(struct device *dev);
147
148 #endif