Linux LED subsystem development
 help / color / mirror / Atom feed
From: Steve Dunnagan <sdunnaga@redhat.com>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Linus Walleij <linusw@kernel.org>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] leds: gpio: Clear error pointers for skipped LEDs
Date: Fri, 24 Jul 2026 14:04:12 -0400	[thread overview]
Message-ID: <20260724180412.43150-1-sdunnaga@redhat.com> (raw)
In-Reply-To: <20260710150841.19669-1-sdunnaga@redhat.com>

gpio_led_get_gpiod() returns an error pointer when a platform-data
LED's GPIO is unavailable. gpio_led_probe() skips registration in that
case, but leaves the error pointer in led_dat->gpiod.

The skipped entry remains included in priv->num_leds. During shutdown,
gpio_led_shutdown() walks those entries and passes the error pointer to
gpio_led_set(), producing:

  gpiod_set_value: invalid GPIO (errorpointer: -ENOENT)

Clear led_dat->gpiod before skipping the LED so skipped entries do not
retain error-valued descriptors.

Fixes: 45d4c6de4e49 ("leds: gpio: Try to lookup gpiod from device")
Suggested-by: Lee Jones <lee@kernel.org>
Assisted-by: ChatGPT:GPT-5.5-Thinking
Signed-off-by: Steve Dunnagan <sdunnaga@redhat.com>
---
Changes in v2:
- Clear led_dat->gpiod in the probe skip path instead of checking for
  error-valued descriptors during shutdown, as suggested by Lee.

Tested on an Orange Pi 5 Plus running Fedora 42 with a test platform
device containing an unavailable GPIO LED. Before the fix, reboot
logged:

  gpiod_set_value: invalid GPIO (errorpointer: -ENOENT)

After the fix, the LED was still skipped during probe, but reboot
completed without the invalid-GPIO warning.

 drivers/leds/leds-gpio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 8ae71c2e91e0..8810fdcf2d77 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -277,6 +277,7 @@ static int gpio_led_probe(struct platform_device *pdev)
 			if (IS_ERR(led_dat->gpiod)) {
 				dev_info(dev, "Skipping unavailable LED gpio %d (%s)\n",
 					 template->gpio, template->name);
+				led_dat->gpiod = NULL;
 				continue;
 			}
 
-- 
2.55.0


  parent reply	other threads:[~2026-07-24 18:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 15:08 [PATCH] leds: gpio: Skip unavailable LEDs during shutdown Steve Dunnagan
2026-07-10 15:21 ` sashiko-bot
2026-07-23 11:35 ` Lee Jones
2026-07-24 18:04 ` Steve Dunnagan [this message]
2026-07-24 18:16   ` [PATCH v2] leds: gpio: Clear error pointers for skipped LEDs sashiko-bot
2026-07-25 14:02   ` Linus Walleij
2026-08-06 13:52   ` (subset) " Lee Jones
2026-08-13 15:45   ` Steve Dunnagan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260724180412.43150-1-sdunnaga@redhat.com \
    --to=sdunnaga@redhat.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox