summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib-sysfs.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-02-01 18:27:56 +0300
committerBartosz Golaszewski <brgl@bgdev.pl>2022-02-08 12:35:49 +0300
commit80c78fbeef10121a0fbba3fd2ed333f5de118f6d (patch)
tree2ac77439b974b3e37fe4909bec319da190239e55 /drivers/gpio/gpiolib-sysfs.c
parent0868ad385affa28cf15aebca3c38c5c51f79b286 (diff)
downloadlinux-80c78fbeef10121a0fbba3fd2ed333f5de118f6d.tar.xz
gpiolib: Introduce for_each_gpio_desc_with_flag() macro
In a few places we are using a loop against all GPIO descriptors with a given flag for a given device. Replace it with a consolidated for_each type of macro. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Diffstat (limited to 'drivers/gpio/gpiolib-sysfs.c')
-rw-r--r--drivers/gpio/gpiolib-sysfs.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 4098bc7f88b7..fc9ec6aa2fc2 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -793,11 +793,8 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
mutex_unlock(&sysfs_lock);
/* unregister gpiod class devices owned by sysfs */
- for (i = 0; i < chip->ngpio; i++) {
- desc = &gdev->descs[i];
- if (test_and_clear_bit(FLAG_SYSFS, &desc->flags))
- gpiod_free(desc);
- }
+ for_each_gpio_desc_with_flag(i, chip, desc, FLAG_SYSFS)
+ gpiod_free(desc);
}
static int __init gpiolib_sysfs_init(void)