Commit 3d8bb3d3 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpio: provide for_each_hwgpio()

We only provide iterators for requested GPIOs to provider drivers. In
order to allow them to display debug information about all GPIOs, let's
provide a variant for iterating over all GPIOs.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 5d60c1e6
......@@ -551,6 +551,21 @@ DEFINE_CLASS(_gpiochip_for_each_data,
}),
const char **label, int *i)
/**
* for_each_hwgpio - Iterates over all GPIOs for given chip.
* @_chip: Chip to iterate over.
* @_i: Loop counter.
* @_label: Place to store the address of the label if the GPIO is requested.
* Set to NULL for unused GPIOs.
*/
#define for_each_hwgpio(_chip, _i, _label) \
for (CLASS(_gpiochip_for_each_data, _data)(&_label, &_i); \
*_data.i < _chip->ngpio; \
(*_data.i)++, kfree(*(_data.label)), *_data.label = NULL) \
if (IS_ERR(*_data.label = \
gpiochip_dup_line_label(_chip, *_data.i))) {} \
else
/**
* for_each_requested_gpio_in_range - iterates over requested GPIOs in a given range
* @_chip: the chip to query
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment