]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqchip/renesas-rza1: Use for_each_of_imap_item iterator
authorHerve Codina (Schneider Electric) <herve.codina@bootlin.com>
Wed, 14 Jan 2026 09:39:33 +0000 (10:39 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 15 Jan 2026 11:03:27 +0000 (12:03 +0100)
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>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260114093938.1089936-5-herve.codina@bootlin.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
drivers/irqchip/irq-renesas-rza1.c

index 6047a524ac77e2ed34bf787855c4cca0874cb42d..370d968b2398cf706a3271b0cf70e695306dc0a7 100644 (file)
@@ -142,47 +142,36 @@ 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)
 {
+       struct of_imap_parser imap_parser;
        struct device *dev = priv->dev;
-       unsigned int imaplen, i, j;
+       struct of_imap_item imap_item;
        struct device_node *ipar;
-       const __be32 *imap;
-       u32 intsize;
+       unsigned int j;
+       u32 i = 0;
        int ret;
 
-       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;