Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/renesas-rza1: Use for_each_of_imap_item iterator

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>

authored by

Herve Codina (Schneider Electric) and committed by
Geert Uytterhoeven
94ed03a0 3ac6dfe3

+16 -27
+16 -27
drivers/irqchip/irq-renesas-rza1.c
··· 142 142 static int rza1_irqc_parse_map(struct rza1_irqc_priv *priv, 143 143 struct device_node *gic_node) 144 144 { 145 + struct of_imap_parser imap_parser; 145 146 struct device *dev = priv->dev; 146 - unsigned int imaplen, i, j; 147 + struct of_imap_item imap_item; 147 148 struct device_node *ipar; 148 - const __be32 *imap; 149 - u32 intsize; 149 + unsigned int j; 150 + u32 i = 0; 150 151 int ret; 151 152 152 - imap = of_get_property(dev->of_node, "interrupt-map", &imaplen); 153 - if (!imap) 154 - return -EINVAL; 153 + ret = of_imap_parser_init(&imap_parser, dev->of_node, &imap_item); 154 + if (ret) 155 + return ret; 155 156 156 - for (i = 0; i < IRQC_NUM_IRQ; i++) { 157 - if (imaplen < 3) 158 - return -EINVAL; 159 - 157 + for_each_of_imap_item(&imap_parser, &imap_item) { 160 158 /* Check interrupt number, ignore sense */ 161 - if (be32_to_cpup(imap) != i) 159 + if (imap_item.child_imap[0] != i) { 160 + of_node_put(imap_item.parent_args.np); 162 161 return -EINVAL; 162 + } 163 163 164 - ipar = of_find_node_by_phandle(be32_to_cpup(imap + 2)); 164 + ipar = imap_item.parent_args.np; 165 165 if (ipar != gic_node) { 166 166 of_node_put(ipar); 167 167 return -EINVAL; 168 168 } 169 169 170 - imap += 3; 171 - imaplen -= 3; 170 + priv->map[i].args_count = imap_item.parent_args.args_count; 171 + for (j = 0; j < priv->map[i].args_count; j++) 172 + priv->map[i].args[j] = imap_item.parent_args.args[j]; 172 173 173 - ret = of_property_read_u32(ipar, "#interrupt-cells", &intsize); 174 - of_node_put(ipar); 175 - if (ret) 176 - return ret; 177 - 178 - if (imaplen < intsize) 179 - return -EINVAL; 180 - 181 - priv->map[i].args_count = intsize; 182 - for (j = 0; j < intsize; j++) 183 - priv->map[i].args[j] = be32_to_cpup(imap++); 184 - 185 - imaplen -= intsize; 174 + i++; 186 175 } 187 176 188 177 return 0;