Re: [PATCH v3 04/11] gpio: Ensure struct gpio_chip for gpiochip_setup_dev()

Bartosz Golaszewski
2026-02-18T10:24:37Z

On Fri, Feb 13, 2026 at 10:31 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> Ensure struct gpio_chip for gpiochip_setup_dev(). This eliminates a few
> checks for struct gpio_chip.
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
> ---
>
> -int gpiochip_sysfs_register(struct gpio_device *gdev)
> +int gpiochip_sysfs_register(struct gpio_chip *chip)
> {
> + struct gpio_device *gdev = chip->gpiodev;
> struct gpiodev_data *data;
> - struct gpio_chip *chip;
> struct device *parent;
> int err;
>
> @@ -994,12 +994,6 @@ int gpiochip_sysfs_register(struct gpio_device *gdev)
> if (!class_is_registered(&gpio_class))
> return 0;
>
> - guard(srcu)(&gdev->srcu);
> -
> - chip = srcu_dereference(gdev->chip, &gdev->srcu);
> - if (!chip)
> - return -ENODEV;

I think it would make sense to add lockdep checks when removing guards
in non-static functions.

Bart