diff mbox series

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

Message ID 20231105154940.97688-2-wahrenst@gmx.net
State Superseded
Headers show
Series ARM: dts: bcm2711-rpi-400: Fix delete-node of led_act | expand

Commit Message

Stefan Wahren Nov. 5, 2023, 3:49 p.m. UTC
In case leds-gpio fails to get the GPIO from the DT (e.g. the GPIO is
already requested) the driver doesn't provide any helpful error log:

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

So add a new error log in case devm_fwnode_gpiod_get() fails.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/leds/leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.34.1

Comments

Andy Shevchenko Nov. 6, 2023, 11:19 a.m. UTC | #1
On Sun, Nov 05, 2023 at 04:49:39PM +0100, Stefan Wahren wrote:
> In case leds-gpio fails to get the GPIO from the DT (e.g. the GPIO is
> already requested) the driver doesn't provide any helpful error log:
> 
>     leds-gpio: probe of leds failed with error -16
> 
> So add a new error log in case devm_fwnode_gpiod_get() fails.

...

>  		led.gpiod = devm_fwnode_gpiod_get(dev, child, NULL, GPIOD_ASIS,
>  						  NULL);
>  		if (IS_ERR(led.gpiod)) {
> +			dev_err(dev, "Failed to get gpio '%pfw': %ld\n",
> +				child, PTR_ERR(led.gpiod));

Perhaps %pe ?

>  			fwnode_handle_put(child);
>  			return ERR_CAST(led.gpiod);
>  		}
Stefan Wahren Nov. 18, 2023, 12:31 p.m. UTC | #2
Hi Andy,

Am 06.11.23 um 12:19 schrieb Andy Shevchenko:
> On Sun, Nov 05, 2023 at 04:49:39PM +0100, Stefan Wahren wrote:
>> In case leds-gpio fails to get the GPIO from the DT (e.g. the GPIO is
>> already requested) the driver doesn't provide any helpful error log:
>>
>>      leds-gpio: probe of leds failed with error -16
>>
>> So add a new error log in case devm_fwnode_gpiod_get() fails.
> ...
>
>>   		led.gpiod = devm_fwnode_gpiod_get(dev, child, NULL, GPIOD_ASIS,
>>   						  NULL);
>>   		if (IS_ERR(led.gpiod)) {
>> +			dev_err(dev, "Failed to get gpio '%pfw': %ld\n",
>> +				child, PTR_ERR(led.gpiod));
> Perhaps %pe ?
i notice that i need to use dev_err_probe because of EPROBE_DEFER
anyway. So i will drop the second parameter in the next version.
>
>>   			fwnode_handle_put(child);
>>   			return ERR_CAST(led.gpiod);
>>   		}
diff mbox series

Patch

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 710c319ad312..284a9e66fd9e 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -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(dev, "Failed to get gpio '%pfw': %ld\n",
+				child, PTR_ERR(led.gpiod));
 			fwnode_handle_put(child);
 			return ERR_CAST(led.gpiod);
 		}