Re: [PATCH v3 19/24] gpio: remove unnecessary checks from gpiod_to_chip()

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

 



On Thu, Feb 08, 2024 at 10:59:15AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> 
> We don't need to check the gdev pointer in struct gpio_desc - it's
> always assigned and never cleared. It's also pointless to check
> gdev->chip before we actually serialize access to it.

...

>  struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
>  {
> -	if (!desc || !desc->gdev)
> +	if (!desc)

Wondering if it makes sense to align with the below and use IS_ERR_OR_NULL() check.

>  		return NULL;
>  	return desc->gdev->chip;

...

> -	if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip)
> +	if (!desc || IS_ERR(desc))

IS_ERR_OR_NULL()

>  		return -EINVAL;
>  
>  	gc = desc->gdev->chip;

-- 
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