Skip to content

Commit 25e9fbf

Browse files
Isaac J. Manjarresgregkh
authored andcommitted
driver core: Don't probe devices after bus_type.match() probe deferral
Both __device_attach_driver() and __driver_attach() check the return code of the bus_type.match() function to see if the device needs to be added to the deferred probe list. After adding the device to the list, the logic attempts to bind the device to the driver anyway, as if the device had matched with the driver, which is not correct. If __device_attach_driver() detects that the device in question is not ready to match with a driver on the bus, then it doesn't make sense for the device to attempt to bind with the current driver or continue attempting to match with any of the other drivers on the bus. So, update the logic in __device_attach_driver() to reflect this. If __driver_attach() detects that a driver tried to match with a device that is not ready to match yet, then the driver should not attempt to bind with the device. However, the driver can still attempt to match and bind with other devices on the bus, as drivers can be bound to multiple devices. So, update the logic in __driver_attach() to reflect this. Fixes: 656b803 ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()") Cc: [email protected] Cc: Saravana Kannan <[email protected]> Reported-by: Guenter Roeck <[email protected]> Tested-by: Guenter Roeck <[email protected]> Tested-by: Linus Walleij <[email protected]> Reviewed-by: Saravana Kannan <[email protected]> Signed-off-by: Isaac J. Manjarres <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a4f1249 commit 25e9fbf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/base/dd.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
911911
dev_dbg(dev, "Device match requests probe deferral\n");
912912
dev->can_match = true;
913913
driver_deferred_probe_add(dev);
914+
/*
915+
* Device can't match with a driver right now, so don't attempt
916+
* to match or bind with other drivers on the bus.
917+
*/
918+
return ret;
914919
} else if (ret < 0) {
915920
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
916921
return ret;
@@ -1150,6 +1155,11 @@ static int __driver_attach(struct device *dev, void *data)
11501155
dev_dbg(dev, "Device match requests probe deferral\n");
11511156
dev->can_match = true;
11521157
driver_deferred_probe_add(dev);
1158+
/*
1159+
* Driver could not match with device, but may match with
1160+
* another device on the bus.
1161+
*/
1162+
return 0;
11531163
} else if (ret < 0) {
11541164
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
11551165
return ret;

0 commit comments

Comments
 (0)