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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux