mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] of: platform: call struct device::detect in of_device_create_on_demand
@ 2023-01-16 13:36 Ahmad Fatoum
  2023-01-16 13:36 ` [PATCH 2/3] i2c: write debug print when registering any i2c client Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-01-16 13:36 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-20  7:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 13:36 [PATCH 1/3] of: platform: call struct device::detect in of_device_create_on_demand Ahmad Fatoum
2023-01-16 13:36 ` [PATCH 2/3] i2c: write debug print when registering any i2c client Ahmad Fatoum
2023-01-16 13:36 ` [PATCH 3/3] i2c: implement detect callback Ahmad Fatoum
2023-01-20  7:36 ` [PATCH 1/3] of: platform: call struct device::detect in of_device_create_on_demand Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox