Re: [PATCH v9 09/20] gpiolib: cdev: support edge detection for uAPI v2

From: Andy Shevchenko
Date: Fri Sep 25 2020 - 05:36:09 EST


On Thu, Sep 24, 2020 at 6:07 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
> On Wed, Sep 23, 2020 at 06:47:28PM +0300, Andy Shevchenko wrote:
> > On Tue, Sep 22, 2020 at 5:35 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:

...

> Also, this code is drawn from lineevent_irq_thread(), which is ordered
> this way.

Negative conditionals are slightly harder to read.

...

> > > + if (!line->timestamp_ns) {
> > > + le.timestamp_ns = ktime_get_ns();
> > > + if (lr->num_lines != 1)
> > > + line->req_seqno = atomic_inc_return(&lr->seqno);
> > > + } else {
> > > + le.timestamp_ns = line->timestamp_ns;
> > > > + }
> >
> > Ditto.
>
> Firstly, drawn from lineevent_irq_thread() which is structured this way.
>
> In this case the comment relates to the condition being true, so
> re-ordering the if/else would be confusing - unless the comment were
> moved into the corresponding body??

Yes.

...

> > > + irq = gpiod_to_irq(line->desc);
> > > + if (irq <= 0)
> > > + return -ENODEV;
> >
> > So, you mean this is part of ABI. Can we return more appropriate code,
> > because getting no IRQ doesn't mean we don't have a device.
> > Also does 0 case have the same meaning?
>
> Firstly, this code is drawn from lineevent_create(), so any changes
> here should be considered for there as well - though this may
> constitute an ABI change??

For v1 probably, for v2 we are free to fix this.

> I agree ENODEV doesn't seem right here. Are you ok with ENXIO?

Yes.

> From gpiod_to_irq():
>
> /* Zero means NO_IRQ */
> if (!retirq)
> return -ENXIO;
>
> so it can't even return a 0 :-| - we're just being cautious.

I would drop = part then.

--
With Best Regards,
Andy Shevchenko