lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250819121907.GA7508@google.com>
Date: Tue, 19 Aug 2025 13:19:07 +0100
From: Lee Jones <lee@...nel.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Bartosz Golaszewski <brgl@...ev.pl>,
	Linus Walleij <linus.walleij@...aro.org>,
	linux-gpio@...r.kernel.org, Pavel Machek <pavel@...nel.org>,
	Arnd Bergmann <arnd@...db.de>,
	Javier Carrasco <javier.carrasco.cruz@...il.com>,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Kees Cook <kees@...nel.org>, Anish Kumar <yesanishhere@...il.com>,
	Mukesh Ojha <quic_mojha@...cinc.com>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	Dmitry Rokosov <ddrokosov@...utedevices.com>,
	linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional

On Fri, 08 Aug 2025, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@...db.de>
> 
> There are still a handful of ancient mips/armv5/sh boards that use the
> gpio_led:gpio member to pass an old-style gpio number, but all modern
> users have been converted to gpio descriptors.
> 
> Make the code that deals with this optional so the legacy interfaces
> can be left out for all normal builds.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/leds/leds-gpio.c | 8 ++++++--
>  include/linux/leds.h     | 2 ++
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index a3428b22de3a..e43accfa78e9 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -212,7 +212,9 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
>  					    const struct gpio_led *template)
>  {
>  	struct gpio_desc *gpiod;
> +#ifdef CONFIG_GPIOLIB_LEGACY
>  	int ret;
> +#endif

Isn't there another way to do his that doesn't entail sprinkling #ifery
around C-files?

>  	/*
>  	 * This means the LED does not come from the device tree
> @@ -228,6 +230,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
>  		return gpiod;
>  	}
>  
> +#ifdef CONFIG_GPIOLIB_LEGACY
>  	/*
>  	 * This is the legacy code path for platform code that
>  	 * still uses GPIO numbers. Ultimately we would like to get
> @@ -244,6 +247,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
>  		return ERR_PTR(ret);
>  
>  	gpiod = gpio_to_desc(template->gpio);
> +#endif
>  	if (!gpiod)
>  		return ERR_PTR(-EINVAL);
>  
> @@ -276,8 +280,8 @@ static int gpio_led_probe(struct platform_device *pdev)
>  				led_dat->gpiod =
>  					gpio_led_get_gpiod(dev, i, template);
>  			if (IS_ERR(led_dat->gpiod)) {
> -				dev_info(dev, "Skipping unavailable LED gpio %d (%s)\n",
> -					 template->gpio, template->name);
> +				dev_info(dev, "Skipping unavailable LED gpio %s\n",
> +					 template->name);
>  				continue;
>  			}
>  
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index b16b803cc1ac..034643f40152 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -676,7 +676,9 @@ typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,
>  struct gpio_led {
>  	const char *name;
>  	const char *default_trigger;
> +#ifdef CONFIG_GPIOLIB_LEGACY
>  	unsigned 	gpio;
> +#endif
>  	unsigned	active_low : 1;
>  	unsigned	retain_state_suspended : 1;
>  	unsigned	panic_indicator : 1;
> -- 
> 2.39.5
> 

-- 
Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ