From 21dd873572a01d74bfdfceb7a30b056f8ccba187 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 20 Nov 2024 08:36:40 -0700 Subject: dm: core: Simplify dm_probe_devices() There is no point in checking the pre_reloc flag, since devices not marked as pre-reloc will not have been bound, so won't exist yet. There doesn't seem to be any point in checking if the device has a valid devicetree node either, so drop that too. Signed-off-by: Simon Glass --- drivers/core/root.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'drivers/core/root.c') diff --git a/drivers/core/root.c b/drivers/core/root.c index c7fb58285ca..6388444bfb1 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -288,26 +288,20 @@ void *dm_priv_to_rw(void *priv) } #endif -static int dm_probe_devices(struct udevice *dev, bool pre_reloc_only) +static int dm_probe_devices(struct udevice *dev) { - ofnode node = dev_ofnode(dev); struct udevice *child; - int ret; - - if (pre_reloc_only && - (!ofnode_valid(node) || !ofnode_pre_reloc(node)) && - !(dev->driver->flags & DM_FLAG_PRE_RELOC)) - goto probe_children; if (dev_get_flags(dev) & DM_FLAG_PROBE_AFTER_BIND) { + int ret; + ret = device_probe(dev); if (ret) return ret; } -probe_children: list_for_each_entry(child, &dev->child_head, sibling_node) - dm_probe_devices(child, pre_reloc_only); + dm_probe_devices(child); return 0; } @@ -344,7 +338,7 @@ static int dm_scan(bool pre_reloc_only) if (ret) return ret; - return dm_probe_devices(gd->dm_root, pre_reloc_only); + return dm_probe_devices(gd->dm_root); } int dm_init_and_scan(bool pre_reloc_only) -- cgit v1.2.3 From 6995f2c8be901b5f3f4183ccc4a58c209e8bce52 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 20 Nov 2024 08:36:41 -0700 Subject: common: Move autoprobe out to board init Rather than doing autoprobe within the driver model code, move it out to the board-init code. This makes it clear that it is a separate step from binding devices. For now this is always done twice, before and after relocation, but we should discuss whether it might be possible to drop the post-relocation probe. For boards with SPL, the autoprobe is still done there as well. Note that with this change, autoprobe happens after the EVT_DM_POST_INIT_R/F events are sent, rather than before. Link: https://lore.kernel.org/u-boot/20240626235717.272219-1-marex@denx.de/ Signed-off-by: Simon Glass --- drivers/core/root.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'drivers/core/root.c') diff --git a/drivers/core/root.c b/drivers/core/root.c index 6388444bfb1..15b8c83fee9 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -288,6 +288,15 @@ void *dm_priv_to_rw(void *priv) } #endif +/** + * dm_probe_devices() - Check whether to probe a device and all children + * + * Probes the device if DM_FLAG_PROBE_AFTER_BIND is enabled for it. Then scans + * all its children recursively to do the same. + * + * @dev: Device to (maybe) probe + * Return 0 if OK, -ve on error + */ static int dm_probe_devices(struct udevice *dev) { struct udevice *child; @@ -306,6 +315,17 @@ static int dm_probe_devices(struct udevice *dev) return 0; } +int dm_autoprobe(void) +{ + int ret; + + ret = dm_probe_devices(gd->dm_root); + if (ret) + return log_msg_ret("pro", ret); + + return 0; +} + /** * dm_scan() - Scan tables to bind devices * @@ -338,7 +358,7 @@ static int dm_scan(bool pre_reloc_only) if (ret) return ret; - return dm_probe_devices(gd->dm_root); + return 0; } int dm_init_and_scan(bool pre_reloc_only) -- cgit v1.2.3