diff mbox

[1/2] ASoC: wm8804: Fix small issues in probe error path

Message ID 1425319075-10400-1-git-send-email-ckeepax@opensource.wolfsonmicro.com (mailing list archive)
State New, archived
Headers show

Commit Message

Charles Keepax March 2, 2015, 5:57 p.m. UTC
The regulator notifiers were not being cleared up on the error path in
wm8804_probe and the nothing was being cleared up if
snd_soc_register_codec failed. This patch fixes these issues.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/wm8804.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

Comments

Mark Brown March 2, 2015, 6:03 p.m. UTC | #1
On Mon, Mar 02, 2015 at 05:57:54PM +0000, Charles Keepax wrote:

> The regulator notifiers were not being cleared up on the error path in
> wm8804_probe and the nothing was being cleared up if
> snd_soc_register_codec failed. This patch fixes these issues.

Why not fix this at source by adding a devm_ notifier registration?
Charles Keepax March 2, 2015, 6:15 p.m. UTC | #2
On Mon, Mar 02, 2015 at 06:03:51PM +0000, Mark Brown wrote:
> On Mon, Mar 02, 2015 at 05:57:54PM +0000, Charles Keepax wrote:
> 
> > The regulator notifiers were not being cleared up on the error path in
> > wm8804_probe and the nothing was being cleared up if
> > snd_soc_register_codec failed. This patch fixes these issues.
> 
> Why not fix this at source by adding a devm_ notifier registration?

Oops.. yeah that is almost certainly better. I will respin for
that.

Thanks,
Charles
diff mbox

Patch

diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index 1bd4ace..6131c2a 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -607,6 +607,7 @@  int wm8804_probe(struct device *dev, struct regmap *regmap)
 			dev_err(dev,
 				"Failed to register regulator notifier: %d\n",
 				ret);
+			return ret;
 		}
 	}
 
@@ -614,7 +615,7 @@  int wm8804_probe(struct device *dev, struct regmap *regmap)
 				    wm8804->supplies);
 	if (ret) {
 		dev_err(dev, "Failed to enable supplies: %d\n", ret);
-		goto err_reg_enable;
+		goto err_reg_notify;
 	}
 
 	ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1);
@@ -651,11 +652,22 @@  int wm8804_probe(struct device *dev, struct regmap *regmap)
 		goto err_reg_enable;
 	}
 
-	return snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
-				      &wm8804_dai, 1);
+	ret = snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
+				     &wm8804_dai, 1);
+	if (ret < 0) {
+		dev_err(dev, "Failed to register CODEC: %d\n", ret);
+		goto err_reg_enable;
+	}
+
+	return 0;
 
 err_reg_enable:
 	regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
+err_reg_notify:
+	for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
+		regulator_unregister_notifier(wm8804->supplies[i].consumer,
+					      &wm8804->disable_nb[i]);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(wm8804_probe);