Skip to contentSkip to conversation

leds: lm3532: Propagate enable GPIO errors

PATCH Superseded [email protected] 3 participants 8 messages Oct 9 – Oct 21 LED

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 leds: lm3532: Propagate enable GPIO errors

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

lm3532_parse_node() currently treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the enable GPIO lookup.

Fixes bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver")

---

Changes in v2:
- Capitalize the first letter of the commit message subject

 drivers/leds/leds-lm3532.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/leds-lm3532.c +2 -1
index b51496910b08..a3bc9680dc4c 100644
@@ -560,7 +560,8 @@ static int lm3532_parse_node(struct lm3532_data *priv)
 	priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev,
 						   "enable", GPIOD_OUT_LOW);
 	if (IS_ERR(priv->enable_gpio))
-		priv->enable_gpio = NULL;
+		return dev_err_probe(&priv->client->dev, PTR_ERR(priv->enable_gpio),
+				     "failed to get enable GPIO\n");
 
 	if (priv->enable_gpio) {
 		ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/2 leds: lm3532: Avoid duplicate error messages

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Add an error message for the devm_add_action() failure and remove the redundant error message from lm3532_probe() to avoid duplicate logs.

---
 drivers/leds/leds-lm3532.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/leds/leds-lm3532.c +3 -4
index a3bc9680dc4c..05856c053fac 100644
@@ -566,7 +566,8 @@ static int lm3532_parse_node(struct lm3532_data *priv)
 	if (priv->enable_gpio) {
 		ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
 		if (ret)
-			return ret;
+			return dev_err_probe(&priv->client->dev, ret,
+					     "failed to add GPIO action\n");
 	}
 
 	priv->regulator = devm_regulator_get(&priv->client->dev, "vin");
@@ -708,10 +709,8 @@ static int lm3532_probe(struct i2c_client *client)
 	i2c_set_clientdata(client, drvdata);
 
 	ret = lm3532_parse_node(drvdata);
-	if (ret) {
-		dev_err(&client->dev, "Failed to parse node\n");
+	if (ret)
 		return ret;
-	}
 
 	return ret;
 }
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 2/2] leds: lm3532: Avoid duplicate error messages

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Add an error message for the devm_add_action() failure and remove the redundant error message from lm3532_probe() to avoid duplicate logs.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#3 lore raw

Re: [PATCH v2 2/2] leds: lm3532: Avoid duplicate error messages

In reply to [email protected]

--- checkpatch.pl: clean (0 issues) ---

Quoted 7 lines · On Fri, 09 Oct 2026, [email protected] wrote:

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Add an error message for the devm_add_action() failure and remove the redundant error message from lm3532_probe() to avoid duplicate logs.

Please capitalise your name appropriately here and in the 'From:' line.

Quoted 9 lines
---
 drivers/leds/leds-lm3532.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/leds/leds-lm3532.c +0 -0
index a3bc9680dc4c..05856c053fac 100644

drivers/leds/leds-lm3532.c static int lm3532_parse_node(struct lm3532_data *priv) · line 570

Quoted 6 lines
drivers/leds/leds-lm3532.c +2 -1
@@ -566,7 +566,8 @@ static int lm3532_parse_node(struct lm3532_data *priv)
 	if (priv->enable_gpio) {
 		ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
 		if (ret)
-			return ret;
+			return dev_err_probe(&priv->client->dev, ret,
+					     "failed to add GPIO action\n");

We do not usually print messages for '-ENOMEM' failures.

It was better before.

Quoted 4 lines
drivers/leds/leds-lm3532.c +0 -0
 	}
 
 	priv->regulator = devm_regulator_get(&priv->client->dev, "vin");

drivers/leds/leds-lm3532.c static int lm3532_probe(struct i2c_client *client) · line 715

Quoted 10 lines
drivers/leds/leds-lm3532.c +1 -3
@@ -708,10 +709,8 @@ static int lm3532_probe(struct i2c_client *client)
 	i2c_set_clientdata(client, drvdata);
 
 	ret = lm3532_parse_node(drvdata);
-	if (ret) {
-		dev_err(&client->dev, "Failed to parse node\n");
+	if (ret)
 		return ret;
-	}
 
 	return ret;

return lm3532_parse_node(drvdata);

Signature · 1 line
Lee Jones
#4 lore raw

Re: [PATCH v2 2/2] leds: lm3532: Avoid duplicate error messages

Hi Lee,

Quoted 4 lines
Quoted 1 line

Please capitalise your name appropriately here and in the 'From:' line.

Dan and Cezary have discussed my name formatting before:
https://lore.kernel.org/all/[email protected]/

I'd prefer to keep my current name formatting,
as I have done in my previous contributions.

Quoted 10 lines

drivers/leds/leds-lm3532.c static int lm3532_parse_node(struct lm3532_data *priv) · line 570

Quoted 5 lines
              ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
              if (ret)
drivers/leds/leds-lm3532.c +2 -1
-                     return ret;
+                     return dev_err_probe(&priv->client->dev, ret,
+                                          "failed to add GPIO action\n");

We do not usually print messages for '-ENOMEM' failures.

It was better before.

Thanks for pointing this out.
The original code propagates the error to lm3532_probe(), where it is already logged.
I'll keep the error propagation without adding a dev_err_probe() message here and
return the error directly from devm_add_action() and lm3532_parse_node().

I'll send an updated version soon.

Best regards,
Phuc

#5 lore raw
In reply to [email protected]
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

Quoted 7 lines

lm3532_parse_node() currently treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the enable GPIO lookup.

Fixes bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#6 lore raw
In reply to [email protected]
Quoted 25 lines · On Fri, 09 Oct 2026, [email protected] wrote:

From: bui duc phuc <[email protected]>

devm_gpiod_get_optional() returns NULL when the optional GPIO is not present, but may return -EPROBE_DEFER or other errors.

lm3532_parse_node() currently treats GPIO lookup errors as if the GPIO were not present.

Check the return value and propagate errors from the enable GPIO lookup.

Fixes bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver")

---

Changes in v2:
- Capitalize the first letter of the commit message subject

 drivers/leds/leds-lm3532.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/leds-lm3532.c +0 -0
index b51496910b08..a3bc9680dc4c 100644

drivers/leds/leds-lm3532.c static int lm3532_parse_node(struct lm3532_data *priv) · line 564

Quoted 6 lines
drivers/leds/leds-lm3532.c +2 -1
@@ -560,7 +560,8 @@ static int lm3532_parse_node(struct lm3532_data *priv)
 	priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev,
 						   "enable", GPIOD_OUT_LOW);
 	if (IS_ERR(priv->enable_gpio))
-		priv->enable_gpio = NULL;
+		return dev_err_probe(&priv->client->dev, PTR_ERR(priv->enable_gpio),
+				     "failed to get enable GPIO\n");

This changes the semantics of the GPIO handling.

Currently we treat the GPIO as optional, regardless of what is returned.

Ideally we'd have the author review this - did you Cc them?

Quoted 5 lines
drivers/leds/leds-lm3532.c +0 -0
 	if (priv->enable_gpio) {
 		ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
Signature · 1 line
2.43.0
Signature · 1 line
Lee Jones
#7 lore raw

Hi Lee,

Quoted 3 lines

Ideally we'd have the author review this - did you Cc them?

Yes, I Cc'd both authors listed in commit bc1b8492c764:
Dan Murphy and Jacek Anaszewski.

Best regards,
Phuc