summaryrefslogtreecommitdiff
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-17 17:22:11 +0300
committerAlex Williamson <alex.williamson@redhat.com>2021-06-22 00:29:24 +0300
commitef6dcbdd8eb2f44dce70a3abecc32d43cc5f3e64 (patch)
treedcb0a8002852ae99ea21945002848c958d5e4c52 /drivers/base/bus.c
parente1499647c69c72c4583273e773d8c2786cb4bee9 (diff)
downloadlinux-ef6dcbdd8eb2f44dce70a3abecc32d43cc5f3e64.tar.xz
driver core: Flow the return code from ->probe() through to sysfs bind
Currently really_probe() returns 1 on success and 0 if the probe() call fails. This return code arrangement is designed to be useful for __device_attach_driver() which is walking the device list and trying every driver. 0 means to keep trying. However, it is not useful for the other places that call through to really_probe() that do actually want to see the probe() return code. For instance bind_store() would be better to return the actual error code from the driver's probe method, not discarding it and returning -ENODEV. Reorganize things so that really_probe() returns the error code from ->probe as a (inverted) positive number, and 0 for successful attach. With this, __device_attach_driver can ignore the (positive) probe errors, return 1 to exit the loop for a successful binding and pass on the other negative errors, while device_driver_attach simplify inverts the positive errors and returns all errors to the sysfs code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Link: https://lore.kernel.org/r/20210617142218.1877096-4-hch@lst.de Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 7de13302e8c8..1f6b4bd61056 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -212,13 +212,9 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
dev = bus_find_device_by_name(bus, NULL, buf);
if (dev && driver_match_device(drv, dev)) {
err = device_driver_attach(drv, dev);
-
- if (err > 0) {
+ if (!err) {
/* success */
err = count;
- } else if (err == 0) {
- /* driver didn't accept device */
- err = -ENODEV;
}
}
put_device(dev);