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 3/8] deep-probe: skip on-demand platform dev creation for nodes without compatible
Date: Wed, 29 Nov 2023 10:12:19 +0100	[thread overview]
Message-ID: <20231129091219.GK977968@pengutronix.de> (raw)
In-Reply-To: <20231127063559.2205776-4-a.fatoum@pengutronix.de>

On Mon, Nov 27, 2023 at 07:35:54AM +0100, Ahmad Fatoum wrote:
> of_device_create_on_demand won't create a new device if the device tree
> node already has a device associated. What it will do however, is to
> create devices for all parent nodes in the device tree if they don't
> already exist. This is unnecessary and clutters the device list
> with nodes that won't ever be matched as they lack a compatible anyway.
> For example a reference to scmi_reg11 in below snippet:
> 
>   &{scmi/protocol@17} {
>       reg = <0x17>;
>       regulators {
>           #address-cells = <0x1>;
>           #size-cells = <0x0>;
>           scmi_reg11: regulator@0 {
>               reg = <0x0>;
>               regulator-name = "reg11";
>           };
>       };
>   };
> 
> will result in creation of a device for the regulators node that serves
> no purpose whatsoever:
> 
>   `-- firmware.of
>      `-- firmware:scmi.of
>         `-- scmi_dev0
>            `-- firmware:scmi:protocol@17:regulators.of
> 
> Avoid this by creating devices on demand only if they have a compatible.

How will this change affect the device hierarchy? When a parent device
node doesn't have a compatible, will the child device then be a child
of its grandparent, or will it just have no parent at all?

Sascha

> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/of/platform.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 9e592d567cae..9ba4438812c1 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -442,9 +442,6 @@ static struct device *of_device_create_on_demand(struct device_node *np)
>  	if (!np->dev && parent->dev)
>  		device_rescan(parent->dev);
>  
> -	if (!np->dev)
> -		pr_debug("Creating device for %pOF\n", np);
> -
>  	/* Create all parent devices needed for the requested device */
>  	parent_dev = parent->dev ? : of_device_create_on_demand(parent);
>  	if (IS_ERR(parent_dev))
> @@ -458,6 +455,11 @@ static struct device *of_device_create_on_demand(struct device_node *np)
>  	if (np->dev)
>  		return np->dev;
>  
> +	if (!of_property_present(np, "compatible"))
> +		return NULL;
> +
> +	pr_debug("Creating device for %pOF\n", np);
> +
>  	if (of_device_is_compatible(np, "arm,primecell"))
>  		dev = of_amba_device_create(np);
>  	else
> -- 
> 2.39.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 |



  reply	other threads:[~2023-11-29  9:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27  6:35 [PATCH 0/8] optee: add bidirectional communication support Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 1/8] driver: don't clear unrelated struct device_node::device on unregister Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 2/8] deep-probe: don't panic when device can't be created Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 3/8] deep-probe: skip on-demand platform dev creation for nodes without compatible Ahmad Fatoum
2023-11-29  9:12   ` Sascha Hauer [this message]
2023-11-30  8:02     ` Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 4/8] devinfo: indicate if device tree nodes are differently populated Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 5/8] include: uaccess.h: import from linux Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 6/8] optee: add bidirectional communication support Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 7/8] optee: add experimental support for /dev/tee0 Ahmad Fatoum
2023-11-27  6:35 ` [PATCH 8/8] hw_random: add implementation for OP-TEE RNG pseudo TA Ahmad Fatoum
2023-12-01 10:39 ` [PATCH 0/8] optee: add bidirectional communication support Sascha Hauer

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=20231129091219.GK977968@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