summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-04-08 21:18:50 +0300
committerBartosz Golaszewski <brgl@bgdev.pl>2022-04-09 23:37:48 +0300
commit57017edd46f835c85642fe8299f13b0db61d4c31 (patch)
tree81235681e68566e5b4717ba9d0cdc4782f3a209e /drivers/gpio/gpiolib.h
parent24a9dbb1c1575b9890bb7d9028cc89894da6dc22 (diff)
downloadlinux-57017edd46f835c85642fe8299f13b0db61d4c31.tar.xz
gpiolib: Embed iterator variable into for_each_gpio_desc_with_flag()
The iterator loop is used exclusively to get a descriptor, which in its turn is what is being used by the caller. Embed the iterator variable into the loop in the for_each_gpio_desc_with_flag() macro helper. Suggested-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Diffstat (limited to 'drivers/gpio/gpiolib.h')
-rw-r--r--drivers/gpio/gpiolib.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 06f3faa9fbef..7bac62d36f0c 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -100,10 +100,10 @@ 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)) \
+#define for_each_gpio_desc_with_flag(gc, desc, flag) \
+ for (unsigned int __i = 0; \
+ __i < gc->ngpio && (desc = gpiochip_get_desc(gc, __i)); \
+ __i++) \
if (!test_bit(flag, &desc->flags)) {} else
int gpiod_get_array_value_complex(bool raw, bool can_sleep,