Most devices featuring a detect callback use it to probe an underlying bus. However, of_device_create_on_demand so far created devices on the platform bus, ignoring that it might be e.g. an I2C device that's supposed to be crated by the parent controller. Fix this by calling the parent's detect callback if available. Busses that probe via device tree, but register their devices on a different bus will need to register a detect callback to benefit from this. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/of/platform.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index ff7096b6eedd..edb082b106ff 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -414,11 +414,18 @@ static struct device *of_device_create_on_demand(struct device_node *np) { struct device_node *parent; struct device *parent_dev, *dev; + int ret; parent = of_get_parent(np); if (!parent) return NULL; + if (!np->dev && parent->dev) { + ret = device_detect(parent->dev); + if (ret && ret != -ENOSYS) + return ERR_PTR(ret); + } + if (!np->dev) pr_debug("Creating device for %s\n", np->full_name); -- 2.30.2