diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2005-11-23 15:43:50 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-23 23:03:06 -0800 |
commit | 2b08c8d0468866f86da97f836c6ac14338cb81a9 (patch) | |
tree | eca60a3b6811a825cd3642a666aa523a18fe484b /drivers/base/bus.c | |
parent | 133747e8d1e912863edfb3869e36b97b9939d4fc (diff) |
[PATCH] Small fixes to driver core
This patch (as603) makes a few small fixes to the driver core:
Change spin_lock_irq for a klist lock to spin_lock;
Fix reference count leaks;
Minor spelling and formatting changes.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 03204bfd17af..fa601b085eba 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -133,7 +133,7 @@ static struct kobj_type ktype_bus = { decl_subsys(bus, &ktype_bus, NULL); -/* Manually detach a device from it's associated driver. */ +/* Manually detach a device from its associated driver. */ static int driver_helper(struct device *dev, void *data) { const char *name = data; @@ -151,14 +151,13 @@ static ssize_t driver_unbind(struct device_driver *drv, int err = -ENODEV; dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); - if ((dev) && - (dev->driver == drv)) { + if (dev && dev->driver == drv) { device_release_driver(dev); err = count; } - if (err) - return err; - return count; + put_device(dev); + put_bus(bus); + return err; } static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind); @@ -175,16 +174,14 @@ static ssize_t driver_bind(struct device_driver *drv, int err = -ENODEV; dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); - if ((dev) && - (dev->driver == NULL)) { + if (dev && dev->driver == NULL) { down(&dev->sem); err = driver_probe_device(drv, dev); up(&dev->sem); - put_device(dev); } - if (err) - return err; - return count; + put_device(dev); + put_bus(bus); + return err; } static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind); |