diff options
author | Wanlong Gao <gaowanlong@cn.fujitsu.com> | 2012-12-10 03:38:33 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-12-17 23:50:43 -0500 |
commit | 9a2bdcc85d28506d4e5d4a9618fb133a3f40945d (patch) | |
tree | ac571e092d7542a5c5121d25b5f8f02cdfbb7a41 /drivers/virtio | |
parent | 9bffdca8c64a72ac54c47a552734ab457bc720d4 (diff) |
virtio: add drv_to_virtio to make code clearly
Add drv_to_virtio wrapper to get virtio_driver from device_driver.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 1346ae8e14f3..1c01ac3fad08 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -73,7 +73,7 @@ static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) | |||
73 | struct virtio_device *dev = dev_to_virtio(_dv); | 73 | struct virtio_device *dev = dev_to_virtio(_dv); |
74 | const struct virtio_device_id *ids; | 74 | const struct virtio_device_id *ids; |
75 | 75 | ||
76 | ids = container_of(_dr, struct virtio_driver, driver)->id_table; | 76 | ids = drv_to_virtio(_dr)->id_table; |
77 | for (i = 0; ids[i].device; i++) | 77 | for (i = 0; ids[i].device; i++) |
78 | if (virtio_id_match(dev, &ids[i])) | 78 | if (virtio_id_match(dev, &ids[i])) |
79 | return 1; | 79 | return 1; |
@@ -97,8 +97,7 @@ void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | |||
97 | unsigned int fbit) | 97 | unsigned int fbit) |
98 | { | 98 | { |
99 | unsigned int i; | 99 | unsigned int i; |
100 | struct virtio_driver *drv = container_of(vdev->dev.driver, | 100 | struct virtio_driver *drv = drv_to_virtio(vdev->dev.driver); |
101 | struct virtio_driver, driver); | ||
102 | 101 | ||
103 | for (i = 0; i < drv->feature_table_size; i++) | 102 | for (i = 0; i < drv->feature_table_size; i++) |
104 | if (drv->feature_table[i] == fbit) | 103 | if (drv->feature_table[i] == fbit) |
@@ -111,8 +110,7 @@ static int virtio_dev_probe(struct device *_d) | |||
111 | { | 110 | { |
112 | int err, i; | 111 | int err, i; |
113 | struct virtio_device *dev = dev_to_virtio(_d); | 112 | struct virtio_device *dev = dev_to_virtio(_d); |
114 | struct virtio_driver *drv = container_of(dev->dev.driver, | 113 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
115 | struct virtio_driver, driver); | ||
116 | u32 device_features; | 114 | u32 device_features; |
117 | 115 | ||
118 | /* We have a driver! */ | 116 | /* We have a driver! */ |
@@ -152,8 +150,7 @@ static int virtio_dev_probe(struct device *_d) | |||
152 | static int virtio_dev_remove(struct device *_d) | 150 | static int virtio_dev_remove(struct device *_d) |
153 | { | 151 | { |
154 | struct virtio_device *dev = dev_to_virtio(_d); | 152 | struct virtio_device *dev = dev_to_virtio(_d); |
155 | struct virtio_driver *drv = container_of(dev->dev.driver, | 153 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
156 | struct virtio_driver, driver); | ||
157 | 154 | ||
158 | drv->remove(dev); | 155 | drv->remove(dev); |
159 | 156 | ||