summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.h
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.h
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.h')
-rw-r--r--drivers/gpio/gpiolib.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 30bc3f80f83e..e1fff54a937d 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -82,6 +82,13 @@ struct gpio_array {
};
struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, unsigned int hwnum);
+
+#define for_each_gpio_desc_with_flag(i, gc, desc, flag) \
+ for (i = 0, desc = gpiochip_get_desc(gc, i); \
+ i < gc->ngpio; \
+ i++, desc = gpiochip_get_desc(gc, i)) \
+ if (!test_bit(flag, &desc->flags)) {} else
+
int gpiod_get_array_value_complex(bool raw, bool can_sleep,
unsigned int array_size,
struct gpio_desc **desc_array,