[PATCH] leds: trigger: gpio: use GPIOD_FLAGS_BIT_NONEXCLUSIVE

Piotr Kubik posted 1 patch 2 months, 1 week ago
drivers/leds/trigger/ledtrig-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] leds: trigger: gpio: use GPIOD_FLAGS_BIT_NONEXCLUSIVE
Posted by Piotr Kubik 2 months, 1 week ago
When a GPIO is shared between the LED trigger driver and another driver,
the LED trigger driver needs to request the GPIO with
GPIOD_FLAGS_BIT_NONEXCLUSIVE to allow both drivers to monitor the same
GPIO pin.

Without this flag, if another driver has already claimed the GPIO,
theLED trigger driver's gpiod_get_optional() call fails silently,
and the LED trigger doesn't work.

This is needed for scenarios like:
- SFP module presence/status LED triggered by SFP Mod_ABS/Rx_LOS

Both GPIOs are also monitored by the SFP driver for module state
management, so they need to be shared.

Signed-off-by: Piotr Kubik <piotr@kubik.pl>
---
 drivers/leds/trigger/ledtrig-gpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index fc911dfec0ef..3b3e6869e856 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -86,7 +86,8 @@ static int gpio_trig_activate(struct led_classdev *led)
 	 * The generic property "trigger-sources" is followed,
 	 * and we hope that this is a GPIO.
 	 */
-	gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources", GPIOD_IN);
+	gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources",
+					      GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
 	if (IS_ERR(gpio_data->gpiod)) {
 		ret = PTR_ERR(gpio_data->gpiod);
 		kfree(gpio_data);
-- 
2.47.3
Re: (subset) [PATCH] leds: trigger: gpio: use GPIOD_FLAGS_BIT_NONEXCLUSIVE
Posted by Lee Jones 1 month, 2 weeks ago
On Wed, 08 Apr 2026 13:51:06 +0200, Piotr Kubik wrote:
> When a GPIO is shared between the LED trigger driver and another driver,
> the LED trigger driver needs to request the GPIO with
> GPIOD_FLAGS_BIT_NONEXCLUSIVE to allow both drivers to monitor the same
> GPIO pin.
> 
> Without this flag, if another driver has already claimed the GPIO,
> theLED trigger driver's gpiod_get_optional() call fails silently,
> and the LED trigger doesn't work.
> 
> [...]

Applied, thanks!

[1/1] leds: trigger: gpio: use GPIOD_FLAGS_BIT_NONEXCLUSIVE
      commit: d9651eade266e822a3c152845dd2816de3e3a7a1

--
Lee Jones [李琼斯]