Re: [PATCH v2 3/3] gpiolib: Switch to use for_each_if() helper

From: Bartosz Golaszewski
Date: Wed Feb 12 2025 - 08:41:55 EST


On Fri, Feb 7, 2025 at 4:11 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxxxxxxx>
> ---
> include/linux/gpio/driver.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
> index ae93f75170f2..a7e9c1d3df71 100644
> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -532,6 +532,7 @@ struct gpio_chip {
>
> char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset);
>
> +#define for_each_if(condition) if (!(condition)) {} else

This is already defined in drm/drm_util.h. Please move it out of there
and make it available globally instead of duplicating.

Bart