lkml.org 
[lkml]   [2024]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] gpio: provide for_each_gpio()
Hi Bartosz,

On Thu, Feb 15, 2024 at 9:33 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> 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: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
(...)

> +/**
> + * for_each_gpio - Iterates over all GPIOs for given chip.

Does this really intuitively fit with other functions named for_each_XXX()?

> + * @_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_gpio(_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

I would call it for_each_line_label() or something. I try to avoid using
"gpio" in function names as well because of ambiguity, I could also go
with for_each_hwgpio_label() I suppose.

With some more reasonable name:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

\
 
 \ /
  Last update: 2024-05-27 15:15    [W:0.126 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site