Skip to content

Commit

Permalink
ASoC: da7219: Disable regulators on probe() failure
Browse files Browse the repository at this point in the history
If codec probe() function fails after supplies have been enabled
it should really tidy up and disable them again. This patch updates
the probe function to do just that.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Adam Thomson authored and Mark Brown committed Dec 23, 2015
1 parent fdd50a8 commit 9069bf9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sound/soc/codecs/da7219.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,10 +1663,12 @@ static int da7219_probe(struct snd_soc_codec *codec)
/* Check if MCLK provided */
da7219->mclk = devm_clk_get(codec->dev, "mclk");
if (IS_ERR(da7219->mclk)) {
if (PTR_ERR(da7219->mclk) != -ENOENT)
return PTR_ERR(da7219->mclk);
else
if (PTR_ERR(da7219->mclk) != -ENOENT) {
ret = PTR_ERR(da7219->mclk);
goto err_disable_reg;
} else {
da7219->mclk = NULL;
}
}

/* Default PC counter to free-running */
Expand Down Expand Up @@ -1694,7 +1696,16 @@ static int da7219_probe(struct snd_soc_codec *codec)
snd_soc_write(codec, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK);

/* Initialise AAD block */
return da7219_aad_init(codec);
ret = da7219_aad_init(codec);
if (ret)
goto err_disable_reg;

return 0;

err_disable_reg:
regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies);

return ret;
}

static int da7219_remove(struct snd_soc_codec *codec)
Expand Down

0 comments on commit 9069bf9

Please sign in to comment.