mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] of: platform: call struct device::detect in of_device_create_on_demand
Date: Fri, 20 Jan 2023 08:36:52 +0100	[thread overview]
Message-ID: <20230120073652.GI24755@pengutronix.de> (raw)
In-Reply-To: <20230116133639.1999170-1-a.fatoum@pengutronix.de>

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



      parent reply	other threads:[~2023-01-20  7:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2023-01-16 13:36 ` [PATCH 3/3] i2c: implement detect callback Ahmad Fatoum
2023-01-20  7:36 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120073652.GI24755@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox