Re: [PATCH v3 4/5] serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_lines)

From: Hugo Villeneuve
Date: Tue Apr 02 2024 - 15:51:26 EST


On Tue, 2 Apr 2024 22:28:25 +0300
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Apr 2, 2024 at 8:45 PM Hugo Villeneuve <hugo@xxxxxxxxxxx> wrote:
> >
> > From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
> >
> > Before, sc16is7xx_lines was checked for a free (zero) bit first, and then
> > later it was set only if UART port registration succeeded. Now that
> > sc16is7xx_lines is shared for the I2C and SPI drivers, there is a
> > possibility that the two drivers can simultaneously try to reserve the same
> > line bit at the same time.
> >
> > To prevent this, make sure line allocation is reserved atomically, and use
> > a new variable to hold the status of UART port regisration.
>
> registration

Hi Andy,
will fix for V4.

>
> > Now that we no longer need to search if a bit is set, it is now possible
> > to simplify sc16is7xx_lines allocation by using the IDA framework.
>
> ...
>
> > -static DECLARE_BITMAP(sc16is7xx_lines, SC16IS7XX_MAX_DEVS);
> > +static DEFINE_IDA(sc16is7xx_lines);
>
> Don't we need to replace bitmap.h with idr.h with this change in place?

Yes, but I will replace bitops.h with idr.h in V4 (bitmap.h was not
included).

While at it, I will include an additional patch to replace inlude of
<uapi/linux/sched/types.h> with <linux/sched.h>.

Thank you,
Hugo.