diff options
author | 2025-02-07 17:07:35 +0200 | |
---|---|---|
committer | 2025-02-12 15:20:16 +0100 | |
commit | 767412f092fc6e04147305acd70f15770ece47ec (patch) | |
tree | 26ee4a9279ac2a2861e1f866c4a9696ca45508ca | |
parent | gpiolib: Deduplicate some code in for_each_requested_gpio_in_range() (diff) | |
download | wireguard-linux-767412f092fc6e04147305acd70f15770ece47ec.tar.xz wireguard-linux-767412f092fc6e04147305acd70f15770ece47ec.zip |
gpiolib: Simplify implementation of for_each_hwgpio_in_range()
The whole purpose of the custom CLASS() is to have possibility
to initialise the counter variable _i to 0. This can't be done
with simple __free() macro as it will be not allowed by C language.
OTOH, the CLASS() operates with the pointers and explicit usage of
the scoped variable _data is not needed, since the pointers are kept
the same over the iterations. Simplify the implementation of
for_each_hwgpio_in_range().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250207151149.2119765-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r-- | include/linux/gpio/driver.h | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 314f4241e306..89439be2ddaa 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -560,11 +560,9 @@ DEFINE_CLASS(_gpiochip_for_each_data, */ #define for_each_hwgpio_in_range(_chip, _i, _base, _size, _label) \ for (CLASS(_gpiochip_for_each_data, _data)(&_label, &_i); \ - *_data.i < _size; \ - (*_data.i)++, kfree(*(_data.label)), *_data.label = NULL) \ - if (IS_ERR(*_data.label = \ - gpiochip_dup_line_label(_chip, _base + *_data.i))) {} \ - else + _i < _size; \ + _i++, kfree(_label), _label = NULL) \ + if (IS_ERR(_label = gpiochip_dup_line_label(_chip, _base + _i))) {} else /** * for_each_hwgpio - Iterates over all GPIOs for given chip. |