Skip to contentSkip to conversation

drivers: leds: tlc591xx: check error during device init

PATCH Applied Daniel Mack 3 participants 3 messages Sep 13, 2019 – Sep 19, 2019 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: leds: tlc591xx: check error during device init

The driver currently ignores errors from register writes at probe time. It will hence register an LED class device no matter whether the pyhsical device is present or not.

To fix this, make the device probe fail in case regmap operations return an error.

---
 drivers/leds/leds-tlc591xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/leds/leds-tlc591xx.c +4 -1
index 59ff088c7d75..00702824d27c 100644
@@ -147,7 +147,10 @@ tlc591xx_configure(struct device *dev,
 	unsigned int i;
 	int err = 0;
 
-	tlc591xx_set_mode(priv->regmap, MODE2_DIM);
+	err = tlc591xx_set_mode(priv->regmap, MODE2_DIM);
+	if (err < 0)
+		return err;
+
 	for (i = 0; i < TLC591XX_MAX_LEDS; i++) {
 		struct tlc591xx_led *led = &priv->leds[i];
 
Signature · 1 line
2.21.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Daniel Mack

The driver currently ignores errors from register writes at probe time. It will hence register an LED class device no matter whether the pyhsical device is present or not.

To fix this, make the device probe fail in case regmap operations return an error.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
In reply to Daniel Mack

Hi Daniel,

Thank you for the patch.

Quoted 19 lines · Daniel Mack

The driver currently ignores errors from register writes at probe time. It will hence register an LED class device no matter whether the pyhsical device is present or not.

To fix this, make the device probe fail in case regmap operations return an error.

---
 drivers/leds/leds-tlc591xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/leds/leds-tlc591xx.c +0 -0
index 59ff088c7d75..00702824d27c 100644
@@ -147,7 +147,10 @@ tlc591xx_configure(struct device *dev,
 	unsigned int i;

drivers/leds/leds-tlc591xx.c tlc591xx_configure(struct device *dev, · line 156

Quoted 10 lines
drivers/leds/leds-tlc591xx.c +4 -1
 	int err = 0;
 
-	tlc591xx_set_mode(priv->regmap, MODE2_DIM);
+	err = tlc591xx_set_mode(priv->regmap, MODE2_DIM);
+	if (err < 0)
+		return err;
+
 	for (i = 0; i < TLC591XX_MAX_LEDS; i++) {
 		struct tlc591xx_led *led = &priv->leds[i];
 

Applied.

Signature · 2 lines
Best regards,
Jacek Anaszewski