aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRyan Wilson <hap9@epoch.ncsc.mil>2006-03-22 16:26:25 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-14 14:41:25 -0400
commit372254018eb1b65ee69210d11686bfc65c8d84db (patch)
treed231099272446513886eeab80e94b8fb84881ed9 /drivers
parenta14388904ca67197c9a531dba2358d8131697865 (diff)
[PATCH] driver core: driver_bind attribute returns incorrect value
The manual driver <-> device binding attribute in sysfs doesn't return the correct value on failure or success of driver_probe_device. driver_probe_device returns 1 on success (the driver accepted the device) or 0 on probe failure (when the driver didn't accept the device but no real error occured). However, the attribute can't just return 0 or 1, it must return the number of bytes consumed from buf or an error value. Returning 0 indicates to userspace that nothing was written (even though the kernel has tried to do the bind/probe and failed). Returning 1 indicates that only one character was accepted in which case userspace will re-try the write with a partial string. A more correct version of driver_bind would return count (to indicate the entire string was consumed) when driver_probe_device returns 1 and -ENODEV when driver_probe_device returns 0. This patch makes that change. Signed-off-by: Ryan Wilson <hap9@epoch.ncsc.mil> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/bus.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 48718b7f4fa0..76656acd00d4 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -188,6 +188,11 @@ static ssize_t driver_bind(struct device_driver *drv,
188 up(&dev->sem); 188 up(&dev->sem);
189 if (dev->parent) 189 if (dev->parent)
190 up(&dev->parent->sem); 190 up(&dev->parent->sem);
191
192 if (err > 0) /* success */
193 err = count;
194 else if (err == 0) /* driver didn't accept device */
195 err = -ENODEV;
191 } 196 }
192 put_device(dev); 197 put_device(dev);
193 put_bus(bus); 198 put_bus(bus);