diff options
| -rw-r--r-- | drivers/virtio/virtio.c | 11 | ||||
| -rw-r--r-- | include/linux/virtio.h | 5 |
2 files changed, 9 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 | ||
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 5f1f80c76468..cf8adb1f5b2c 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
| @@ -119,6 +119,11 @@ struct virtio_driver { | |||
| 119 | #endif | 119 | #endif |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv) | ||
| 123 | { | ||
| 124 | return container_of(drv, struct virtio_driver, driver); | ||
| 125 | } | ||
| 126 | |||
| 122 | int register_virtio_driver(struct virtio_driver *drv); | 127 | int register_virtio_driver(struct virtio_driver *drv); |
| 123 | void unregister_virtio_driver(struct virtio_driver *drv); | 128 | void unregister_virtio_driver(struct virtio_driver *drv); |
| 124 | #endif /* _LINUX_VIRTIO_H */ | 129 | #endif /* _LINUX_VIRTIO_H */ |
