[RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip
Michael Walle
mwalle at kernel.org
Mon Nov 30 02:35:58 PST 2026
On Fri Nov 27, 2026 at 7:43 PM CET, Andy Shevchenko wrote:
> On Fri, Nov 27, 2026 at 03:52:23PM +0100, Michael Walle wrote:
>> The most common use-case is to use regmap-irq together with gpio-regmap.
>> To make life easier for that and to avoid code duplication, add helpers
>> to create and attach a regmap-irq domain. These helpers are intended to
>> be called by the new .create_irq_domain() callback.
>>
>> gpio_regmap_add_irq_chip() locks the GPIO line while its interrupt is
>> requested. This assumes that the hwirq numbers match the GPIO offsets.
>> If a driver doesn't follow that, there is one without the locking called
>> gpio_regmap_add_irq_chip_nolock().
>
> Hmm... Can't we simply have a boolean flag instead in GPIO regmap configuration
> and just distinguish it inside the common helper?
Not sure about that, it has nothing to do with the gpio regmap
itself and would even be ignored if these helpers are not used. So
I'd like to keep it out of the config.
We could use a boolean argument for the gpio_regmap_add_irq_chip(),
but then you can't use a function pointer. Thinking further, there
might be some driver data just setting this callback. Who knows.
Thus, I've gone that route.
> ...
>
>> +/**
>> + * gpio_regmap_add_irq_chip_nolock() - Add a regmap-irq chip without line locking
>> + * @gpio: gpio_regmap device
>> + * @irq: the parent interrupt
>> + * @irq_flags: the IRQF_ flags to use for @irq
>> + * @chip: the regmap-irq chip description
>> + *
>> + * Same as gpio_regmap_add_irq_chip() but doesn't lock the GPIO lines.
>> + * Can be used if the hwirq numbers of the regmap-irq chip don't match
>> + * the GPIO offsets.
>> + *
>> + * Return: irq_domain or an ERR_PTR() error value.
>
> Okay, this might justify returning error pointer, but irq_domain_create_*()
> shadows that with NULL, which questions the usefulness of it (the error code).
> I'm fine with either approach but still tend towards using
> irq_domain_create_*() helpers instead their open coded variants.
I'll go with the irq_domain_create_ helper, but I'm unsure if we
want to drop the ERR_PTR here and instead just return NULL. I'd keep
the ERR_PTR here just in case someone will do more than just call
the domain creation helper.
-michael
> On the other hand there is no much win, especially if you replace
>
> info = {};
>
> info.XXX = ...;
>
> ... = irq_domain_instantiate(&info);
>
> with direct assignment as it's done inside irq_domain_create_*(),
>
>> + */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 297 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20261130/7827cf0c/attachment.sig>
More information about the linux-arm-kernel
mailing list