diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-11-19 11:20:42 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-11-18 19:20:42 -0500 |
commit | 74b2553f1d13e60fb27063204bd5b6908a6f8494 (patch) | |
tree | cd35e82d16cf190ccd95362478a598314de639ce /drivers/virtio/virtio.c | |
parent | d1c856e0f1a4c946c6329cff126548ef4288735f (diff) |
virtio: fix module/device unloading
The virtio code never hooked through the ->remove callback. Although
noone supports device removal at the moment, this code is already
needed for module unloading.
This of course also revealed bugs in virtio_blk, virtio_net and lguest
unloading paths.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r-- | drivers/virtio/virtio.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 15d7787dea87..69d7ea02cd48 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d) | |||
96 | return err; | 96 | return err; |
97 | } | 97 | } |
98 | 98 | ||
99 | static int virtio_dev_remove(struct device *_d) | ||
100 | { | ||
101 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | ||
102 | struct virtio_driver *drv = container_of(dev->dev.driver, | ||
103 | struct virtio_driver, driver); | ||
104 | |||
105 | dev->config->set_status(dev, dev->config->get_status(dev) | ||
106 | & ~VIRTIO_CONFIG_S_DRIVER); | ||
107 | drv->remove(dev); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
99 | int register_virtio_driver(struct virtio_driver *driver) | 111 | int register_virtio_driver(struct virtio_driver *driver) |
100 | { | 112 | { |
101 | driver->driver.bus = &virtio_bus; | 113 | driver->driver.bus = &virtio_bus; |
102 | driver->driver.probe = virtio_dev_probe; | 114 | driver->driver.probe = virtio_dev_probe; |
115 | driver->driver.remove = virtio_dev_remove; | ||
103 | return driver_register(&driver->driver); | 116 | return driver_register(&driver->driver); |
104 | } | 117 | } |
105 | EXPORT_SYMBOL_GPL(register_virtio_driver); | 118 | EXPORT_SYMBOL_GPL(register_virtio_driver); |