diff options
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r-- | drivers/virtio/virtio.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 809b0de59c09..ee59b74768d9 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -10,33 +10,32 @@ static DEFINE_IDA(virtio_index_ida); | |||
10 | static ssize_t device_show(struct device *_d, | 10 | static ssize_t device_show(struct device *_d, |
11 | struct device_attribute *attr, char *buf) | 11 | struct device_attribute *attr, char *buf) |
12 | { | 12 | { |
13 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 13 | struct virtio_device *dev = dev_to_virtio(_d); |
14 | return sprintf(buf, "0x%04x\n", dev->id.device); | 14 | return sprintf(buf, "0x%04x\n", dev->id.device); |
15 | } | 15 | } |
16 | static ssize_t vendor_show(struct device *_d, | 16 | static ssize_t vendor_show(struct device *_d, |
17 | struct device_attribute *attr, char *buf) | 17 | struct device_attribute *attr, char *buf) |
18 | { | 18 | { |
19 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 19 | struct virtio_device *dev = dev_to_virtio(_d); |
20 | return sprintf(buf, "0x%04x\n", dev->id.vendor); | 20 | return sprintf(buf, "0x%04x\n", dev->id.vendor); |
21 | } | 21 | } |
22 | static ssize_t status_show(struct device *_d, | 22 | static ssize_t status_show(struct device *_d, |
23 | struct device_attribute *attr, char *buf) | 23 | struct device_attribute *attr, char *buf) |
24 | { | 24 | { |
25 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 25 | struct virtio_device *dev = dev_to_virtio(_d); |
26 | return sprintf(buf, "0x%08x\n", dev->config->get_status(dev)); | 26 | return sprintf(buf, "0x%08x\n", dev->config->get_status(dev)); |
27 | } | 27 | } |
28 | static ssize_t modalias_show(struct device *_d, | 28 | static ssize_t modalias_show(struct device *_d, |
29 | struct device_attribute *attr, char *buf) | 29 | struct device_attribute *attr, char *buf) |
30 | { | 30 | { |
31 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 31 | struct virtio_device *dev = dev_to_virtio(_d); |
32 | |||
33 | return sprintf(buf, "virtio:d%08Xv%08X\n", | 32 | return sprintf(buf, "virtio:d%08Xv%08X\n", |
34 | dev->id.device, dev->id.vendor); | 33 | dev->id.device, dev->id.vendor); |
35 | } | 34 | } |
36 | static ssize_t features_show(struct device *_d, | 35 | static ssize_t features_show(struct device *_d, |
37 | struct device_attribute *attr, char *buf) | 36 | struct device_attribute *attr, char *buf) |
38 | { | 37 | { |
39 | struct virtio_device *dev = container_of(_d, struct virtio_device, dev); | 38 | struct virtio_device *dev = dev_to_virtio(_d); |
40 | unsigned int i; | 39 | unsigned int i; |
41 | ssize_t len = 0; | 40 | ssize_t len = 0; |
42 | 41 | ||
@@ -71,10 +70,10 @@ static inline int virtio_id_match(const struct virtio_device *dev, | |||
71 | static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) | 70 | static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) |
72 | { | 71 | { |
73 | unsigned int i; | 72 | unsigned int i; |
74 | struct virtio_device *dev = container_of(_dv,struct virtio_device,dev); | 73 | struct virtio_device *dev = dev_to_virtio(_dv); |
75 | const struct virtio_device_id *ids; | 74 | const struct virtio_device_id *ids; |
76 | 75 | ||
77 | ids = container_of(_dr, struct virtio_driver, driver)->id_table; | 76 | ids = drv_to_virtio(_dr)->id_table; |
78 | for (i = 0; ids[i].device; i++) | 77 | for (i = 0; ids[i].device; i++) |
79 | if (virtio_id_match(dev, &ids[i])) | 78 | if (virtio_id_match(dev, &ids[i])) |
80 | return 1; | 79 | return 1; |
@@ -83,7 +82,7 @@ static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) | |||
83 | 82 | ||
84 | static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env) | 83 | static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env) |
85 | { | 84 | { |
86 | struct virtio_device *dev = container_of(_dv,struct virtio_device,dev); | 85 | struct virtio_device *dev = dev_to_virtio(_dv); |
87 | 86 | ||
88 | return add_uevent_var(env, "MODALIAS=virtio:d%08Xv%08X", | 87 | return add_uevent_var(env, "MODALIAS=virtio:d%08Xv%08X", |
89 | dev->id.device, dev->id.vendor); | 88 | dev->id.device, dev->id.vendor); |
@@ -98,8 +97,7 @@ void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | |||
98 | unsigned int fbit) | 97 | unsigned int fbit) |
99 | { | 98 | { |
100 | unsigned int i; | 99 | unsigned int i; |
101 | struct virtio_driver *drv = container_of(vdev->dev.driver, | 100 | struct virtio_driver *drv = drv_to_virtio(vdev->dev.driver); |
102 | struct virtio_driver, driver); | ||
103 | 101 | ||
104 | for (i = 0; i < drv->feature_table_size; i++) | 102 | for (i = 0; i < drv->feature_table_size; i++) |
105 | if (drv->feature_table[i] == fbit) | 103 | if (drv->feature_table[i] == fbit) |
@@ -111,9 +109,8 @@ EXPORT_SYMBOL_GPL(virtio_check_driver_offered_feature); | |||
111 | static int virtio_dev_probe(struct device *_d) | 109 | static int virtio_dev_probe(struct device *_d) |
112 | { | 110 | { |
113 | int err, i; | 111 | int err, i; |
114 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 112 | struct virtio_device *dev = dev_to_virtio(_d); |
115 | struct virtio_driver *drv = container_of(dev->dev.driver, | 113 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
116 | struct virtio_driver, driver); | ||
117 | u32 device_features; | 114 | u32 device_features; |
118 | 115 | ||
119 | /* We have a driver! */ | 116 | /* We have a driver! */ |
@@ -152,9 +149,8 @@ static int virtio_dev_probe(struct device *_d) | |||
152 | 149 | ||
153 | static int virtio_dev_remove(struct device *_d) | 150 | static int virtio_dev_remove(struct device *_d) |
154 | { | 151 | { |
155 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 152 | struct virtio_device *dev = dev_to_virtio(_d); |
156 | struct virtio_driver *drv = container_of(dev->dev.driver, | 153 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
157 | struct virtio_driver, driver); | ||
158 | 154 | ||
159 | drv->remove(dev); | 155 | drv->remove(dev); |
160 | 156 | ||