Skip to contentSkip to conversation

ASoC: wm8804: Use common error handling code in wm8804_probe()

PATCH In review SF Markus Elfring 2 participants 2 messages Nov 19, 2017 – Nov 20, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: wm8804: Use common error handling code in wm8804_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 19 Nov 2017 07:55:49 +0100

* Add a jump target so that a specific error message is stored only once at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/wm8804.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
sound/soc/codecs/wm8804.c +6 -8
index fc69b87443d8..a45812417909 100644
@@ -626,16 +626,12 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)
 	gpiod_set_value_cansleep(wm8804->reset, 1);
 
 	ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1);
-	if (ret < 0) {
-		dev_err(dev, "Failed to read device ID: %d\n", ret);
-		goto err_reg_enable;
-	}
+	if (ret < 0)
+		goto report_read_failure;
 
 	ret = regmap_read(regmap, WM8804_DEVID2, &id2);
-	if (ret < 0) {
-		dev_err(dev, "Failed to read device ID: %d\n", ret);
-		goto err_reg_enable;
-	}
+	if (ret < 0)
+		goto report_read_failure;
 
 	id2 = (id2 << 8) | id1;
 
@@ -674,6 +670,8 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)
 
 	return 0;
 
+report_read_failure:
+	dev_err(dev, "Failed to read device ID: %d\n", ret);
 err_reg_enable:
 	regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
 	return ret;
Signature · 1 line
2.15.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 19 Nov 2017 07:55:49 +0100

* Add a jump target so that a specific error message is stored only once at the end of this function implementation.

Quoted 6 lines

* Replace two calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

---

Thanks,
Charles