[PATCH 3/8] deep-probe: skip on-demand platform dev creation for nodes without compatible
Sascha Hauer
sha at pengutronix.de
Wed Nov 29 01:12:19 PST 2023
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 at 17} {
> reg = <0x17>;
> regulators {
> #address-cells = <0x1>;
> #size-cells = <0x0>;
> scmi_reg11: regulator at 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 at 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 at 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 |
More information about the barebox
mailing list