[PATCH 2/6] driver: make struct bus_type::probe optional
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Feb 28 08:05:14 PST 2024
Newly introduce soc_bus_type doesn't define .probe, which would crash
once a driver is registered on that bus. Do as Linux does and defer
to the driver probe function if there's no bus probe function and
treat non-existence of either as a successful probe.
This has the added benefit that it will allow us to drop very simple bus
probe functions that just call the driver probe and do nothing else.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/base/driver.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index babc08f8b6b2..b2d428b70550 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -137,7 +137,12 @@ int device_probe(struct device *dev)
list_add(&dev->active, &active_device_list);
- ret = dev->bus->probe(dev);
+ if (dev->bus->probe)
+ ret = dev->bus->probe(dev);
+ else if (dev->driver->probe)
+ ret = dev->driver->probe(dev);
+ else
+ ret = 0;
depth--;
--
2.39.2
More information about the barebox
mailing list