diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2025-02-13 20:24:01 +0200 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2025-02-17 14:27:35 +0100 |
commit | 23318614f8c146d440e57a69d7171dd8c0d249b7 (patch) | |
tree | 4f87a4f843bfb887e1255d026114bd09e7bdf7c9 | |
parent | b2108fc82a0acda34388bff3e3ee3544013b1623 (diff) |
gpiolib: Switch to use for_each_if() helper
The for_each_*() APIs that are conditional can be written shorter and
less error prone with for_each_if() helper in use. Switch them to use
this helper.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250213182527.3092371-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r-- | include/linux/gpio/driver.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 89439be2ddaa..10544f4a03e5 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -14,6 +14,7 @@ #include <linux/property.h> #include <linux/spinlock_types.h> #include <linux/types.h> +#include <linux/util_macros.h> #ifdef CONFIG_GENERIC_MSI_IRQ #include <asm/msi.h> @@ -562,7 +563,7 @@ DEFINE_CLASS(_gpiochip_for_each_data, for (CLASS(_gpiochip_for_each_data, _data)(&_label, &_i); \ _i < _size; \ _i++, kfree(_label), _label = NULL) \ - if (IS_ERR(_label = gpiochip_dup_line_label(_chip, _base + _i))) {} else + for_each_if(!IS_ERR(_label = gpiochip_dup_line_label(_chip, _base + _i))) /** * for_each_hwgpio - Iterates over all GPIOs for given chip. @@ -584,7 +585,7 @@ DEFINE_CLASS(_gpiochip_for_each_data, */ #define for_each_requested_gpio_in_range(_chip, _i, _base, _size, _label) \ for_each_hwgpio_in_range(_chip, _i, _base, _size, _label) \ - if (_label == NULL) {} else + for_each_if(_label) /* Iterates over all requested GPIO of the given @chip */ #define for_each_requested_gpio(chip, i, label) \ @@ -870,7 +871,7 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc, #define for_each_gpiochip_node(dev, child) \ device_for_each_child_node(dev, child) \ - if (!fwnode_property_present(child, "gpio-controller")) {} else + for_each_if(fwnode_property_present(child, "gpio-controller")) static inline unsigned int gpiochip_node_count(struct device *dev) { |