[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250729195151.GB658914-robh@kernel.org>
Date: Tue, 29 Jul 2025 14:51:51 -0500
From: Rob Herring <robh@...nel.org>
To: Herve Codina <herve.codina@...tlin.com>
Cc: Hoan Tran <hoan@...amperecomputing.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Magnus Damm <magnus.damm@...il.com>,
Saravana Kannan <saravanak@...gle.com>,
Serge Semin <fancer.lancer@...il.com>,
Phil Edworthy <phil.edworthy@...esas.com>,
linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
Miquel Raynal <miquel.raynal@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH 4/6] of/irq: Introduce of_irq_foreach_imap
On Fri, Jul 25, 2025 at 05:26:13PM +0200, Herve Codina wrote:
> of_irq_foreach_imap is an iterator designed to help a driver to parse
> an interrupt-map property.
>
> Indeed some drivers need to know details about the interrupt mapping
> described in the device-tree in order to set internal registers
> accordingly.
I would like to see some existing user converted to make sure it works
for other cases.
>
> Signed-off-by: Herve Codina <herve.codina@...tlin.com>
> ---
> drivers/of/irq.c | 70 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/of_irq.h | 11 +++++++
> 2 files changed, 81 insertions(+)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index f8ad79b9b1c9..863b31eb3c1a 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -157,6 +157,76 @@ const __be32 *of_irq_parse_imap_parent(const __be32 *imap, int len, struct of_ph
> return imap;
> }
>
> +/**
> + * of_irq_foreach_imap - Iterate through interrupt-map items
> + * @np: device node where interrupt-map is available
> + * @func: function called on each interrupt-map items
> + * @data: data passe to @func
> + *
> + * This function iterates through interrupt-map items and calls @func on each
> + * item. The parent interrupt described in the interrupt-map item is parsed
> + * and passed to @func using a pointer to a struct of_phandle_args.
> + * Also the imap raw value is passed in order to allow @func to look at other
> + * values of the interrupt-map (child unit address and child interrupt
> + * specificer)
> + *
> + * If @func returns an error, the iteration stops and this error is returned.
> + */
> +int of_irq_foreach_imap(struct device_node *np,
> + int (*func)(void *data,
> + const __be32 *imap,
> + const struct of_phandle_args *parent_args),
> + void *data)
The func callback is a departure from other DT iterators. Look at the
'ranges' iterator which keeps the state on each iteration.
Rob
Powered by blists - more mailing lists