Skip to contentSkip to conversation

leds: lm3532: Propagate enable GPIO errors

PATCH In review [email protected] 4 participants 7 messages Oct 21 – Nov 13 LED

lore
Share & tools
lore
#0 lore raw

PATCH v3 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")

---

Link v1 :
https://lore.kernel.org/all/[email protected]/
Link v2 :
https://lore.kernel.org/all/[email protected]/

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 v3 2/2 leds: lm3532: Avoid duplicate error messages

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Remove the redundant error message from lm3532_probe() to avoid duplicate logs.

---

Link v1 :
https://lore.kernel.org/all/[email protected]/
Link v2 :
https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Remove the error message for devm_add_action() failures.

 drivers/leds/leds-lm3532.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/leds/leds-lm3532.c +1 -3
index a3bc9680dc4c..a050e4350bdb 100644
@@ -708,10 +708,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
#4 lore raw
In reply to [email protected]
Sashiko has reviewed this patch and found no issues.
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.

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

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

In reply to [email protected]
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Remove the redundant error message from lm3532_probe() to avoid duplicate logs.

Sashiko has reviewed this patch and found no issues.

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

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

In reply to [email protected]
Quoted 25 lines · On Wed, 21 Oct 2026, [email protected] wrote:

From: bui duc phuc <[email protected]>

Most error paths in lm3532_parse_node() already log errors. Remove the redundant error message from lm3532_probe() to avoid duplicate logs.

---

Link v1 :
https://lore.kernel.org/all/[email protected]/
Link v2 :
https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Remove the error message for devm_add_action() failures.

 drivers/leds/leds-lm3532.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/leds/leds-lm3532.c +0 -0
index a3bc9680dc4c..a050e4350bdb 100644

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

Quoted 10 lines
drivers/leds/leds-lm3532.c +1 -3
@@ -708,10 +708,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;

As requested on v2, just:

    return lm3532_parse_node(drvdata);
Quoted 5 lines
drivers/leds/leds-lm3532.c +0 -0
 }
Signature · 1 line
2.43.0
Signature · 1 line
Lee Jones
maintainer
#6 lore raw
In reply to [email protected]
Quoted 30 lines · On Wed, 21 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")

---

Link v1 :
https://lore.kernel.org/all/[email protected]/
Link v2 :
https://lore.kernel.org/all/[email protected]/

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")

Please capitalise the first letter of the error message.

Quoted 6 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