Re: [PATCH 1/3] of: platform: call struct device::detect in of_device_create_on_demand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 16, 2023 at 02:36:37PM +0100, Ahmad Fatoum wrote:
> 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(+)

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux