Skip to content

Commit

Permalink
ASoC: sgtl5000: Use devm_regulator_bulk_get()
Browse files Browse the repository at this point in the history
Using devm_regulator_bulk_get() can make the code cleaner and smaller as we
do not need to call regulator_bulk_free() in the error and remove paths.

Signed-off-by: Fabio Estevam <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
Fabio Estevam authored and linux4kix committed Jul 13, 2014
1 parent 4235c71 commit 61f693f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions sound/soc/codecs/sgtl5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,24 +1320,21 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
return ret;
}

ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies),
ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
if (ret)
goto err_ldo_remove;

ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
if (ret)
goto err_regulator_free;
goto err_ldo_remove;

/* wait for all power rails bring up */
udelay(10);

return 0;

err_regulator_free:
regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
err_ldo_remove:
if (!external_vddd)
ldo_regulator_remove(codec);
Expand Down Expand Up @@ -1415,8 +1412,6 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
err:
regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
ldo_regulator_remove(codec);

return ret;
Expand All @@ -1430,8 +1425,6 @@ static int sgtl5000_remove(struct snd_soc_codec *codec)

regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);
ldo_regulator_remove(codec);

return 0;
Expand Down

0 comments on commit 61f693f

Please sign in to comment.