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

irqchip/ls-extirq: Use for_each_of_imap_item iterator

The ls-extirq 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 ls-extirq 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>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260114093938.1089936-4-herve.codina@bootlin.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

authored by

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

+17 -30
+17 -30
drivers/irqchip/irq-ls-extirq.c
··· 125 125 static int 126 126 ls_extirq_parse_map(struct ls_extirq_data *priv, struct device_node *node) 127 127 { 128 - const __be32 *map; 129 - u32 mapsize; 128 + struct of_imap_parser imap_parser; 129 + struct of_imap_item imap_item; 130 130 int ret; 131 131 132 - map = of_get_property(node, "interrupt-map", &mapsize); 133 - if (!map) 134 - return -ENOENT; 135 - if (mapsize % sizeof(*map)) 136 - return -EINVAL; 137 - mapsize /= sizeof(*map); 132 + ret = of_imap_parser_init(&imap_parser, node, &imap_item); 133 + if (ret) 134 + return ret; 138 135 139 - while (mapsize) { 136 + for_each_of_imap_item(&imap_parser, &imap_item) { 140 137 struct device_node *ipar; 141 - u32 hwirq, intsize, j; 138 + u32 hwirq; 139 + int i; 142 140 143 - if (mapsize < 3) 141 + hwirq = imap_item.child_imap[0]; 142 + if (hwirq >= MAXIRQ) { 143 + of_node_put(imap_item.parent_args.np); 144 144 return -EINVAL; 145 - hwirq = be32_to_cpup(map); 146 - if (hwirq >= MAXIRQ) 147 - return -EINVAL; 145 + } 148 146 priv->nirq = max(priv->nirq, hwirq + 1); 149 147 150 - ipar = of_find_node_by_phandle(be32_to_cpup(map + 2)); 151 - map += 3; 152 - mapsize -= 3; 153 - if (!ipar) 154 - return -EINVAL; 155 - priv->map[hwirq].fwnode = &ipar->fwnode; 156 - ret = of_property_read_u32(ipar, "#interrupt-cells", &intsize); 157 - if (ret) 158 - return ret; 148 + ipar = of_node_get(imap_item.parent_args.np); 149 + priv->map[hwirq].fwnode = of_fwnode_handle(ipar); 159 150 160 - if (intsize > mapsize) 161 - return -EINVAL; 162 - 163 - priv->map[hwirq].param_count = intsize; 164 - for (j = 0; j < intsize; ++j) 165 - priv->map[hwirq].param[j] = be32_to_cpup(map++); 166 - mapsize -= intsize; 151 + priv->map[hwirq].param_count = imap_item.parent_args.args_count; 152 + for (i = 0; i < priv->map[hwirq].param_count; i++) 153 + priv->map[hwirq].param[i] = imap_item.parent_args.args[i]; 167 154 } 168 155 return 0; 169 156 }