Skip to contentSkip to conversation

leds: gpio: Add kernel log if devm_fwnode_gpiod_get fails

PATCH Applied Stefan Wahren 4 participants 4 messages Dec 2, 2023 – Dec 7, 2023 LED

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 leds: gpio: Add kernel log if devm_fwnode_gpiod_get fails

In case leds-gpio fails to get at least one of possibly many GPIOs from the DT (e.g. the GPIO is already requested) neither gpiolib nor the driver does provide any helpful error log:

leds-gpio: probe of leds failed with error -16

As the driver knows better how to handle errors with such mandatory GPIOs, let's implement an error log which points to the affected GPIO.

---

Previous discussion:
https://lore.kernel.org/linux-leds/[email protected]/T/

Changes in V3:
- drop already applied patch from series
- s/gpio/GPIO/ as suggested by Lee Jones
- improve commit message

Changes in V2:
- replace dev_err with dev_err_probe to handle EPROBE_DEFER properly

 drivers/leds/leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/leds-gpio.c +2 -0
index 710c319ad312..83fcd7b6afff 100644
@@ -172,6 +172,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct device *dev)
 		led.gpiod = devm_fwnode_gpiod_get(dev, child, NULL, GPIOD_ASIS,
 						  NULL);
 		if (IS_ERR(led.gpiod)) {
+			dev_err_probe(dev, PTR_ERR(led.gpiod), "Failed to get GPIO '%pfw'\n",
+				      child);
 			fwnode_handle_put(child);
 			return ERR_CAST(led.gpiod);
 		}

--
2.34.1

Reviewed-by on v3 1/1
#1 lore raw
Quoted 11 lines · Stefan Wahren

In case leds-gpio fails to get at least one of possibly many GPIOs from the DT (e.g. the GPIO is already requested) neither gpiolib nor the driver does provide any helpful error log:

leds-gpio: probe of leds failed with error -16

As the driver knows better how to handle errors with such mandatory GPIOs, let's implement an error log which points to the affected GPIO.

Yours,
Linus Walleij

Reviewed-by on v3 1/1
#2 lore raw
In reply to Stefan Wahren
Quoted 9 lines · Stefan Wahren

In case leds-gpio fails to get at least one of possibly many GPIOs from the DT (e.g. the GPIO is already requested) neither gpiolib nor the driver does provide any helpful error log:

leds-gpio: probe of leds failed with error -16

As the driver knows better how to handle errors with such mandatory GPIOs, let's implement an error log which points to the affected GPIO.

As we have had a consensus,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#3 lore raw

Re: (subset) [PATCH V3] leds: gpio: Add kernel log if devm_fwnode_gpiod_get fails

In reply to Stefan Wahren
Quoted 11 lines · Stefan Wahren

In case leds-gpio fails to get at least one of possibly many GPIOs from the DT (e.g. the GPIO is already requested) neither gpiolib nor the driver does provide any helpful error log:

leds-gpio: probe of leds failed with error -16

As the driver knows better how to handle errors with such mandatory GPIOs, let's implement an error log which points to the affected GPIO.

[...]

Applied, thanks!

[1/1] leds: gpio: Add kernel log if devm_fwnode_gpiod_get fails

      commit: 430545cd13d0f554aaadb8b938ac0bdf7a70a413

--
Lee Jones [李琼斯]