Re: [PATCH v3 10/10] gpiolib: remove gpiochip_is_requested()

From: Andy Shevchenko
Date: Mon Dec 04 2023 - 08:22:32 EST


On Mon, Dec 04, 2023 at 10:35:09AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> We have no external users of gpiochip_is_requested(). Let's remove it
> and replace its internal calls with direct testing of the REQUESTED flag.

...

> char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset)
> {
> - const char *label;
> - char *copy;
> + struct gpio_desc *desc;
> + char *label;
>
> - label = gpiochip_is_requested(gc, offset);
> - if (!label)
> + desc = gpiochip_get_desc(gc, offset);
> + if (IS_ERR(desc))
> return NULL;
>
> - copy = kstrdup(label, GFP_KERNEL);
> - if (!copy)
> + guard(spinlock_irqsave)(&gpio_lock);
> +
> + if (!test_bit(FLAG_REQUESTED, &desc->flags))
> + return NULL;
> +
> + label = kstrdup(desc->label, GFP_KERNEL);
> + if (!label)
> return ERR_PTR(-ENOMEM);
>
> - return copy;
> + return label;
> }

My gosh, maybe we take better naming to reduce churn here?
Whatever, let's stop bikeshedding :-)

--
With Best Regards,
Andy Shevchenko