diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2022-02-01 17:27:56 +0200 |
---|---|---|
committer | Bartosz Golaszewski <brgl@bgdev.pl> | 2022-02-08 10:35:49 +0100 |
commit | 80c78fbeef10121a0fbba3fd2ed333f5de118f6d (patch) | |
tree | 2ac77439b974b3e37fe4909bec319da190239e55 /drivers/gpio/gpiolib-of.c | |
parent | 0868ad385affa28cf15aebca3c38c5c51f79b286 (diff) |
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-of.c')
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 91dcf2c6cdd8..ae1ce319cd78 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -711,14 +711,12 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip) static void of_gpiochip_remove_hog(struct gpio_chip *chip, struct device_node *hog) { - struct gpio_desc *descs = chip->gpiodev->descs; + struct gpio_desc *desc; unsigned int i; - for (i = 0; i < chip->ngpio; i++) { - if (test_bit(FLAG_IS_HOGGED, &descs[i].flags) && - descs[i].hog == hog) - gpiochip_free_own_desc(&descs[i]); - } + for_each_gpio_desc_with_flag(i, chip, desc, FLAG_IS_HOGGED) + if (desc->hog == hog) + gpiochip_free_own_desc(desc); } static int of_gpiochip_match_node(struct gpio_chip *chip, void *data) |