[PATCH 3/3] of/irq: Use of_bus_n_addr_cells() to retrieve "#address-cells"
From: Rob Herring (Arm)
Date: Thu May 30 2024 - 21:04:19 EST
of_irq_parse_raw() is open coding what of_bus_n_addr_cells() does, so
replace it with of_bus_n_addr_cells().
Note that the original code would use 2 cells if #address-cells was not
found. That doesn't match the default of 1 for anything but Sparc which
doesn't use this code.
Signed-off-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
---
drivers/of/irq.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 462375b293e4..d81ee880a553 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -165,10 +165,10 @@ const __be32 *of_irq_parse_imap_parent(const __be32 *imap, int len, struct of_ph
*/
int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
{
- struct device_node *ipar, *tnode, *old = NULL;
+ struct device_node *ipar, *tnode;
__be32 initial_match_array[MAX_PHANDLE_ARGS];
const __be32 *match_array = initial_match_array;
- const __be32 *tmp, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
+ const __be32 dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
u32 intsize = 1, addrsize;
int i, rc = -EINVAL;
@@ -202,16 +202,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
/* Look for this #address-cells. We have to implement the old linux
* trick of looking for the parent here as some device-trees rely on it
*/
- old = of_node_get(ipar);
- do {
- tmp = of_get_property(old, "#address-cells", NULL);
- tnode = of_get_parent(old);
- of_node_put(old);
- old = tnode;
- } while (old && tmp == NULL);
- of_node_put(old);
- old = NULL;
- addrsize = (tmp == NULL) ? 2 : be32_to_cpu(*tmp);
+ addrsize = of_bus_n_addr_cells(ipar);
pr_debug(" -> addrsize=%d\n", addrsize);
--
2.43.0