Re: [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells()

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

 



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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux