summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8580.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 12:03:51 +0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 14:09:18 +0800
commit18273b05def692d1883745d22e72fa275bc92c17 (patch)
tree328cdf6e7b13577b974f47d14750b70230febafe /sound/soc/codecs/wm8580.c
parentb689d9f9961befd9b322783f512195785fe82daa (diff)
downloadop-kernel-dev-18273b05def692d1883745d22e72fa275bc92c17.zip
op-kernel-dev-18273b05def692d1883745d22e72fa275bc92c17.tar.gz
ASoC: wm8580: Move regulator acquisition to I2C probe
Better style as we get all the resources we need prior to starting the ASoC level probe. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8580.c')
-rw-r--r--sound/soc/codecs/wm8580.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c
index 02c75be..5e9c40f 100644
--- a/sound/soc/codecs/wm8580.c
+++ b/sound/soc/codecs/wm8580.c
@@ -867,7 +867,7 @@ static struct snd_soc_dai_driver wm8580_dai[] = {
static int wm8580_probe(struct snd_soc_codec *codec)
{
struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
- int ret = 0,i;
+ int ret = 0;
ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
if (ret < 0) {
@@ -875,16 +875,6 @@ static int wm8580_probe(struct snd_soc_codec *codec)
return ret;
}
- for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++)
- wm8580->supplies[i].supply = wm8580_supply_names[i];
-
- ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8580->supplies),
- wm8580->supplies);
- if (ret != 0) {
- dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
- return ret;
- }
-
ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies),
wm8580->supplies);
if (ret != 0) {
@@ -906,7 +896,6 @@ static int wm8580_probe(struct snd_soc_codec *codec)
err_regulator_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
err_regulator_get:
- regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
return ret;
}
@@ -918,7 +907,6 @@ static int wm8580_remove(struct snd_soc_codec *codec)
wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF);
regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
- regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
return 0;
}
@@ -958,7 +946,7 @@ static int wm8580_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct wm8580_priv *wm8580;
- int ret;
+ int ret, i;
wm8580 = devm_kzalloc(&i2c->dev, sizeof(struct wm8580_priv),
GFP_KERNEL);
@@ -969,6 +957,16 @@ static int wm8580_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(wm8580->regmap))
return PTR_ERR(wm8580->regmap);
+ for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++)
+ wm8580->supplies[i].supply = wm8580_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8580->supplies),
+ wm8580->supplies);
+ if (ret != 0) {
+ dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+ return ret;
+ }
+
i2c_set_clientdata(i2c, wm8580);
ret = snd_soc_register_codec(&i2c->dev,
OpenPOWER on IntegriCloud