[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240604160809.GA1060206-robh@kernel.org>
Date: Tue, 4 Jun 2024 11:08:09 -0500
From: Rob Herring <robh@...nel.org>
To: Saravana Kannan <saravanak@...gle.com>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] of: Add missing locking to
of_(bus_)?n_(size|addr)_cells()
On Thu, May 30, 2024 at 08:03:28PM -0500, Rob Herring (Arm) wrote:
> When accessing parent/child/sibling pointers the DT spinlock needs to
> be held. The of_(bus_)?n_(size|addr)_cells() functions are missing that
> when walking up the parent nodes. In reality, it rarely matters as most
> nodes are static.
>
> Signed-off-by: Rob Herring (Arm) <robh@...nel.org>
> ---
> drivers/of/base.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 20603d3c9931..61fff13bbee5 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -91,8 +91,8 @@ int of_bus_n_addr_cells(struct device_node *np)
> {
> u32 cells;
>
> - for (; np; np = np->parent)
> - if (!of_property_read_u32(np, "#address-cells", &cells))
> + for_each_parent_of_node_scoped(parent, np)
> + if (!of_property_read_u32(parent, "#address-cells", &cells))
> return cells;
>
> /* No #address-cells property for the root node */
> @@ -101,10 +101,9 @@ int of_bus_n_addr_cells(struct device_node *np)
>
> int of_n_addr_cells(struct device_node *np)
> {
> - if (np->parent)
> - np = np->parent;
This isn't going to work... This drops of_n_addr_cells working for the
root node. Callers wanting to get root node's properties need to use the
of_bus_n variant instead, so those callers will have to be checked and
fixed first.
Rob
Powered by blists - more mailing lists