[RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Thu Dec 3 02:15:07 PST 2026
On Mon, Nov 30, 2026 at 11:35:58AM +0100, Michael Walle wrote:
> 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.
OK. Let's see how it will evolve.
...
> >> +/**
> >> + * 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.
That's why I have no strong opinion, but since the helpers provided by IRQ
domain core I believe that the error codes (since they are shadowed in this
case) are considered internal granulation and users in general do not need
to care about them.
> > 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_*(),
> >
> >> + */
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list