Re: [External Email] Re: [PATCH v1] serial: sc16is7xx: Extend IRQ check for negative valus

From: Andy Shevchenko
Date: Thu Jan 16 2025 - 07:01:24 EST


On Thu, Jan 16, 2025 at 11:01:30AM +0100, Jiri Slaby wrote:
> On 16. 01. 25, 10:52, Andre Werner wrote:
> > On Thu, 16 Jan 2025, Jiri Slaby wrote:
> > > On 16. 01. 25, 10:32, Andre Werner wrote:
> > > > Fix the IRQ check to treat the negative values as No IRQ.
> > >
> > > Care to describe on what HW that can happen?
> >
> > I have no example on that. In the previous thread it was mentioned that
> > it is not absolutely sure that the API is not called with negative values. Thus,
> > negative values shall also be treated as no IRQ.
>
> SPI:
> if (spi->irq < 0)
> spi->irq = 0;

In all cases of how SPI target device is instantiated? I haven't checked myself
all those (three or four? or even five?) ways.

> I2C:
> if (irq < 0)
> irq = 0;

> So unlikely :).

Yes, but none of them _guarantees_ that (looking at the documentation and
the field type in the respective data structures).

Until there no guarantees, I would consider this patch as robustness increase.

--
With Best Regards,
Andy Shevchenko