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-19 11:20:42 +1100 |
commit | 74b2553f1d13e60fb27063204bd5b6908a6f8494 (patch) | |
tree | cd35e82d16cf190ccd95362478a598314de639ce /drivers/virtio | |
parent | d1c856e0f1a4c946c6329cff126548ef4288735f (diff) | |
download | kernel_samsung_tuna-74b2553f1d13e60fb27063204bd5b6908a6f8494.zip kernel_samsung_tuna-74b2553f1d13e60fb27063204bd5b6908a6f8494.tar.gz kernel_samsung_tuna-74b2553f1d13e60fb27063204bd5b6908a6f8494.tar.bz2 |
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')
-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 15d7787..69d7ea0 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d) return err; } +static int virtio_dev_remove(struct device *_d) +{ + struct virtio_device *dev = container_of(_d,struct virtio_device,dev); + struct virtio_driver *drv = container_of(dev->dev.driver, + struct virtio_driver, driver); + + dev->config->set_status(dev, dev->config->get_status(dev) + & ~VIRTIO_CONFIG_S_DRIVER); + drv->remove(dev); + return 0; +} + int register_virtio_driver(struct virtio_driver *driver) { driver->driver.bus = &virtio_bus; driver->driver.probe = virtio_dev_probe; + driver->driver.remove = virtio_dev_remove; return driver_register(&driver->driver); } EXPORT_SYMBOL_GPL(register_virtio_driver); |