Re: [PATCH v3 04/11] gpio: Ensure struct gpio_chip for gpiochip_setup_dev()
From: Bartosz Golaszewski
Date: Wed Feb 18 2026 - 05:37:26 EST
On Fri, Feb 13, 2026 at 10:31 AM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
>
> -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