Skip to content

Commit

Permalink
ASoC: wm8804: Use new devres regulator_register_notifier
Browse files Browse the repository at this point in the history
This is more idiomatic and also fixes an issue where the notifiers were
being leaked if probe failed.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Charles Keepax authored and Mark Brown committed Mar 5, 2015
1 parent 5142442 commit 0be9653
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions sound/soc/codecs/wm8804.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,10 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)

/* This should really be moved into the regulator core */
for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
ret = regulator_register_notifier(wm8804->supplies[i].consumer,
&wm8804->disable_nb[i]);
struct regulator *regulator = wm8804->supplies[i].consumer;

ret = devm_regulator_register_notifier(regulator,
&wm8804->disable_nb[i]);
if (ret != 0) {
dev_err(dev,
"Failed to register regulator notifier: %d\n",
Expand Down Expand Up @@ -662,15 +664,6 @@ EXPORT_SYMBOL_GPL(wm8804_probe);

void wm8804_remove(struct device *dev)
{
struct wm8804_priv *wm8804;
int i;

wm8804 = dev_get_drvdata(dev);

for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
regulator_unregister_notifier(wm8804->supplies[i].consumer,
&wm8804->disable_nb[i]);

snd_soc_unregister_codec(dev);
}
EXPORT_SYMBOL_GPL(wm8804_remove);
Expand Down

0 comments on commit 0be9653

Please sign in to comment.