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

Andy Shevchenko
2024-02-08T17:39:07Z

On Thu, Feb 08, 2024 at 10:59:15AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> 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