[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240530-dt-interrupt-map-fix-v1-2-2331d8732f08@kernel.org>
Date: Thu, 30 May 2024 20:03:28 -0500
From: "Rob Herring (Arm)" <robh@...nel.org>
To: Saravana Kannan <saravanak@...gle.com>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] of: Add missing locking to
of_(bus_)?n_(size|addr)_cells()
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;
+ struct device_node *parent __free(device_node) = of_get_parent(np);
- return of_bus_n_addr_cells(np);
+ return of_bus_n_addr_cells(parent);
}
EXPORT_SYMBOL(of_n_addr_cells);
@@ -112,8 +111,8 @@ int of_bus_n_size_cells(struct device_node *np)
{
u32 cells;
- for (; np; np = np->parent)
- if (!of_property_read_u32(np, "#size-cells", &cells))
+ for_each_parent_of_node_scoped(parent, np)
+ if (!of_property_read_u32(parent, "#size-cells", &cells))
return cells;
/* No #size-cells property for the root node */
@@ -122,10 +121,9 @@ int of_bus_n_size_cells(struct device_node *np)
int of_n_size_cells(struct device_node *np)
{
- if (np->parent)
- np = np->parent;
+ struct device_node *parent __free(device_node) = of_get_parent(np);
- return of_bus_n_size_cells(np);
+ return of_bus_n_size_cells(parent);
}
EXPORT_SYMBOL(of_n_size_cells);
--
2.43.0
Powered by blists - more mailing lists