[PATCH 2/5] of: platform: optimize of_find_device_by_node when deep probing

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 5 03:35:43 PDT 2022


With deep probe enabled, we are guaranteed that struct device_node::dev
is populated whenever a device had been created for a node, so in that
case, skip the iteration over the linked list of registered devices.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/of/platform.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 7f377b8b378a..dc784ea8e550 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -28,6 +28,9 @@ struct device_d *of_find_device_by_node(struct device_node *np)
 	if (ret)
 		return NULL;
 
+	if (deep_probe_is_supported())
+		return np->dev;
+
 	for_each_device(dev)
 		if (dev->device_node == np)
 			return dev;
-- 
2.30.2




More information about the barebox mailing list