[PATCH v3 4/8] irqchip/renesas-rza1: Use for_each_of_imap_item iterator

Herve Codina (Schneider Electric)
2025-09-18T10:40:37Z

The renesas-rza1 driver parses the interrupt-map property. It does it
using open code.

Recently for_each_of_imap_item iterator has been introduce to help
drivers in this parsing.

Convert the renesas-rza1 driver to use the for_each_of_imap_item
iterator instead of open code.

Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
drivers/irqchip/irq-renesas-rza1.c | 43 +++++++++++-------------------
1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/drivers/irqchip/irq-renesas-rza1.c b/drivers/irqchip/irq-renesas-rza1.c
index a697eb55ac90..789196b71656 100644
--- a/drivers/irqchip/irq-renesas-rza1.c
+++ b/drivers/irqchip/irq-renesas-rza1.c
@@ -142,46 +142,35 @@ static const struct irq_domain_ops rza1_irqc_domain_ops = {
static int rza1_irqc_parse_map(struct rza1_irqc_priv *priv,
struct device_node *gic_node)
{
- unsigned int imaplen, i, j, ret;
+ struct of_imap_parser imap_parser;
struct device *dev = priv->dev;
+ struct of_imap_item imap_item;
struct device_node *ipar;
- const __be32 *imap;
- u32 intsize;
+ int j, ret;
+ u32 i = 0;

- imap = of_get_property(dev->of_node, "interrupt-map", &imaplen);
- if (!imap)
- return -EINVAL;
-
- for (i = 0; i < IRQC_NUM_IRQ; i++) {
- if (imaplen < 3)
- return -EINVAL;
+ ret = of_imap_parser_init(&imap_parser, dev->of_node, &imap_item);
+ if (ret)
+ return ret;

+ for_each_of_imap_item(&imap_parser, &imap_item) {
/* Check interrupt number, ignore sense */
- if (be32_to_cpup(imap) != i)
+ if (imap_item.child_imap[0] != i) {
+ of_node_put(imap_item.parent_args.np);
return -EINVAL;
+ }

- ipar = of_find_node_by_phandle(be32_to_cpup(imap + 2));
+ ipar = imap_item.parent_args.np;
if (ipar != gic_node) {
of_node_put(ipar);
return -EINVAL;
}

- imap += 3;
- imaplen -= 3;
-
- ret = of_property_read_u32(ipar, "#interrupt-cells", &intsize);
- of_node_put(ipar);
- if (ret)
- return ret;
-
- if (imaplen < intsize)
- return -EINVAL;
-
- priv->map[i].args_count = intsize;
- for (j = 0; j < intsize; j++)
- priv->map[i].args[j] = be32_to_cpup(imap++);
+ priv->map[i].args_count = imap_item.parent_args.args_count;
+ for (j = 0; j < priv->map[i].args_count; j++)
+ priv->map[i].args[j] = imap_item.parent_args.args[j];

- imaplen -= intsize;
+ i++;
}

return 0;
--
2.51.0