]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: sysfs: Remove redundant check for struct gpio_chip
authorTzung-Bi Shih <tzungbi@kernel.org>
Mon, 23 Feb 2026 06:17:23 +0000 (14:17 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Fri, 27 Feb 2026 09:05:21 +0000 (10:05 +0100)
gpiochip_sysfs_unregister() is only called by gpiochip_remove() where
the struct gpio_chip is ensured.

Remove the redundant check.

Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260223061726.82161-4-tzungbi@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib-sysfs.c
drivers/gpio/gpiolib-sysfs.h
drivers/gpio/gpiolib.c

index 270e8060e761613f7af82ca0602a1934f79fc1ad..1c25a7dd3db42c927a61ef091226f433126a2e67 100644 (file)
@@ -1053,11 +1053,11 @@ int gpiochip_sysfs_register(struct gpio_device *gdev)
        return 0;
 }
 
-void gpiochip_sysfs_unregister(struct gpio_device *gdev)
+void gpiochip_sysfs_unregister(struct gpio_chip *gc)
 {
+       struct gpio_device *gdev = gc->gpiodev;
        struct gpiodev_data *data;
        struct gpio_desc *desc;
-       struct gpio_chip *chip;
 
        guard(mutex)(&sysfs_lock);
 
@@ -1065,13 +1065,8 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
        if (!data)
                return;
 
-       guard(srcu)(&gdev->srcu);
-       chip = srcu_dereference(gdev->chip, &gdev->srcu);
-       if (!chip)
-               return;
-
        /* unregister gpiod class devices owned by sysfs */
-       for_each_gpio_desc_with_flag(chip, desc, GPIOD_FLAG_SYSFS) {
+       for_each_gpio_desc_with_flag(gc, desc, GPIOD_FLAG_SYSFS) {
                gpiod_unexport_unlocked(desc);
                gpiod_free(desc);
        }
index b794b396d6a52588c93839fbba062eb160236ca4..fd5db5384681a8463f1b9408175ce62b2417d9d5 100644 (file)
@@ -8,7 +8,7 @@ struct gpio_device;
 #ifdef CONFIG_GPIO_SYSFS
 
 int gpiochip_sysfs_register(struct gpio_device *gdev);
-void gpiochip_sysfs_unregister(struct gpio_device *gdev);
+void gpiochip_sysfs_unregister(struct gpio_chip *gc);
 
 #else
 
@@ -17,7 +17,7 @@ static inline int gpiochip_sysfs_register(struct gpio_device *gdev)
        return 0;
 }
 
-static inline void gpiochip_sysfs_unregister(struct gpio_device *gdev)
+static inline void gpiochip_sysfs_unregister(struct gpio_chip *gc)
 {
 }
 
index 9408ecbe791370440534512131824c3386f5a3fd..8001ec1f9799bc78f87afb1755e6440e298790d0 100644 (file)
@@ -1286,7 +1286,7 @@ void gpiochip_remove(struct gpio_chip *gc)
        struct gpio_device *gdev = gc->gpiodev;
 
        /* FIXME: should the legacy sysfs handling be moved to gpio_device? */
-       gpiochip_sysfs_unregister(gdev);
+       gpiochip_sysfs_unregister(gc);
        gpiochip_free_hogs(gc);
        gpiochip_free_remaining_irqs(gc);