Re: [PATCH v2 17/23] gpio: reduce the functionality of validate_desc()

From: Andy Shevchenko
Date: Tue Feb 06 2024 - 07:35:36 EST


On Mon, Feb 05, 2024 at 08:22:23PM +0100, Bartosz Golaszewski wrote:
> On Mon, Feb 5, 2024 at 2:47 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Mon, Feb 05, 2024 at 10:34:12AM +0100, Bartosz Golaszewski wrote:

..

> > > void gpiod_free(struct gpio_desc *desc)
> > > {
> > > - /*
> > > - * We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip
> > > - * may already be NULL but we still want to put the references.
> > > - */
> > > - if (!desc)
> > > - return;
> > > + VALIDATE_DESC_VOID(desc);
> >
> > IIRC we (used to) have two cases like this (you added one in some code like
> > last year).
> >
>
> None of the consumer-facing functions does it anymore. Not sure about
> this, maybe it was removed earlier.

Okay, the only place that might be considered is gpiod_to_gpio_device().

But that API seems new, I don't know if VALIDATE_DESC_VOID() is okay to use there,
maybe it should be commented if not. Also there is a typo in the kernel doc —
'the users already holds' --> 'the user already holds'.

--
With Best Regards,
Andy Shevchenko