Re: [PATCH v2 6/6] gpiolib: let the character device free its IRQs first on chip removal

From: Kent Gibson

Date: Mon Oct 19 2026 - 05:02:07 EST


On Mon, Oct 19, 2026 at 11:40:43AM +0300, Andy Shevchenko wrote:
> On Fri, Oct 16, 2026 at 09:40:03PM +0800, Kent Gibson wrote:
> > On Fri, Oct 16, 2026 at 12:23:38PM +0300, Adrian Ambrozewicz wrote:
>
> ...
>
> > > + /* Called with gdev->chip already NULL, so gpiod_to_irq() can't be used. */
> > > + if (gc->to_irq)
> > > + irq = gc->to_irq(gc, gpiod_hwgpio(desc));
> > > + else
> > > + irq = 0;
> > > + if (irq <= 0)
> > > + return;
> >
> > Perhaps I'm channelling Andy here, but how about:
>
> It was in the previous version and I suggested to move it to the above. Seems
> like we have an opposite comments. Can you provide a rationale behind your choice?
>

Ha, so it was, though your suggestion was not quite the above - it
didn't allow for gc->to_irq() returning 0 and it set the irq to a
negative error code.

> > if (!gc->to_irq)
> > return;
> > irq = gc->to_irq(gc, gpiod_hwgpio(desc));
> > if (irq <= 0)
> > return;
>

This way is clearer given gc->to_irq() can return 0 - the <= condition
there is purely because of its possible return values.
Setting irq to either 0 or an negative error code, rather than just returning
on the spot, are both more confusing and pointless.

This is my preferred form, and I obviously expected that you would prefer the
shorter form as well, but apparently not.

Cheers,
Kent.