Skip to content

Commit 3ac6dfe

Browse files
hcodinageertu
authored andcommitted
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>
1 parent a9811ae commit 3ac6dfe

1 file changed

Lines changed: 17 additions & 30 deletions

File tree

drivers/irqchip/irq-ls-extirq.c

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,45 +125,32 @@ static const struct irq_domain_ops extirq_domain_ops = {
125125
static int
126126
ls_extirq_parse_map(struct ls_extirq_data *priv, struct device_node *node)
127127
{
128-
const __be32 *map;
129-
u32 mapsize;
128+
struct of_imap_parser imap_parser;
129+
struct of_imap_item imap_item;
130130
int ret;
131131

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;
138135

139-
while (mapsize) {
136+
for_each_of_imap_item(&imap_parser, &imap_item) {
140137
struct device_node *ipar;
141-
u32 hwirq, intsize, j;
138+
u32 hwirq;
139+
int i;
142140

143-
if (mapsize < 3)
144-
return -EINVAL;
145-
hwirq = be32_to_cpup(map);
146-
if (hwirq >= MAXIRQ)
141+
hwirq = imap_item.child_imap[0];
142+
if (hwirq >= MAXIRQ) {
143+
of_node_put(imap_item.parent_args.np);
147144
return -EINVAL;
145+
}
148146
priv->nirq = max(priv->nirq, hwirq + 1);
149147

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;
159-
160-
if (intsize > mapsize)
161-
return -EINVAL;
148+
ipar = of_node_get(imap_item.parent_args.np);
149+
priv->map[hwirq].fwnode = of_fwnode_handle(ipar);
162150

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];
167154
}
168155
return 0;
169156
}

0 commit comments

Comments
 (0)