[PATCH 3/3] common: Move autoprobe out to board init

Caleb Connolly caleb.connolly at linaro.org
Tue Oct 22 12:51:37 CEST 2024


Hi Simon,

Just a typo/nit

On 21/10/2024 17:51, Simon Glass wrote:
> 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.
> 
> This patch also drops autoprobe from SPL. If that is needed, we could
> add a call in SPL.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
>   common/board_f.c    |  4 ++++
>   common/board_r.c    |  4 ++++
>   drivers/core/root.c | 17 ++++++++++++++---
>   include/dm/root.h   | 10 ++++++++++
>   4 files changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/common/board_f.c b/common/board_f.c
> index 8684ed71284..6564b2ac2f7 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -822,6 +822,10 @@ static int initf_dm(void)
>   	if (ret)
>   		return ret;
>   
> +	ret = dm_autoprobe();
> +	if (ret)
> +		return ret;
> +
>   	if (IS_ENABLED(CONFIG_TIMER_EARLY)) {
>   		ret = dm_timer_init();
>   		if (ret)
> diff --git a/common/board_r.c b/common/board_r.c
> index e5f33f40643..a2948b7b55c 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -243,6 +243,10 @@ static int initr_dm(void)
>   	if (ret)
>   		return ret;
>   
> +	ret = dm_autoprobe();
> +	if (ret)
> +		return ret;
> +
>   	return 0;
>   }
>   #endif
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 2d4f078f97f..f6bda84b2b9 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -281,7 +281,7 @@ void *dm_priv_to_rw(void *priv)
>   }
>   #endif
>   
> -static int dm_probe_devices(struct udevice *dev)
> +static int dm_probe_devices_(struct udevice *dev)
>   {
>   	struct udevice *child;
>   
> @@ -294,7 +294,18 @@ static int dm_probe_devices(struct udevice *dev)
>   	}
>   
>   	list_for_each_entry(child, &dev->child_head, sibling_node)
> -		dm_probe_devices(child);
> +		dm_probe_devices_(child);
> +
> +	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;
>   }
> @@ -331,7 +342,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)
> diff --git a/include/dm/root.h b/include/dm/root.h
> index b2f30a842f5..2ba5104ce1f 100644
> --- a/include/dm/root.h
> +++ b/include/dm/root.h
> @@ -136,6 +136,16 @@ int dm_scan_other(bool pre_reloc_only);
>    */
>   int dm_init_and_scan(bool pre_reloc_only);
>   
> +/**
> + * dm_autoprobe() - Prove devices which are marked for probe-after-bind

s/prove/probe

Kind regards,

> + *
> + * This probes all devices with a DM_FLAG_PROBE_AFTER_BIND flag. It checks the
> + * entire tree, so parent nodes need not have the flag set.
> + *
> + * Return: 0 if OK, -ve on error
> + */
> +int dm_autoprobe(void);
> +
>   /**
>    * dm_init() - Initialise Driver Model structures
>    *

-- 
// Caleb (they/them)



More information about the U-Boot mailing list