summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8737.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 06:36:28 +0200
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 08:09:37 +0200
commit4f69bb31b8840713f82c6c476bae3f2356819ce2 (patch)
treeaf5d152abf489354563bf71ea159430de4c6ced4 /sound/soc/codecs/wm8737.c
parentASoC: wm8728: Convert to direct regmap API usage (diff)
downloadlinux-4f69bb31b8840713f82c6c476bae3f2356819ce2.tar.xz
linux-4f69bb31b8840713f82c6c476bae3f2356819ce2.zip
ASoC: wm8737: Move regulator acquisition to device registration
This is better style as we acquire resources we will need before we go into the ASoC card probe. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8737.c')
-rw-r--r--sound/soc/codecs/wm8737.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c
index 8c25442f9b47..3bf5bc73e2de 100644
--- a/sound/soc/codecs/wm8737.c
+++ b/sound/soc/codecs/wm8737.c
@@ -557,7 +557,7 @@ static int wm8737_resume(struct snd_soc_codec *codec)
static int wm8737_probe(struct snd_soc_codec *codec)
{
struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
- int ret, i;
+ int ret;
ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8737->control_type);
if (ret != 0) {
@@ -565,16 +565,6 @@ static int wm8737_probe(struct snd_soc_codec *codec)
return ret;
}
- for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
- wm8737->supplies[i].supply = wm8737_supply_names[i];
-
- ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8737->supplies),
- wm8737->supplies);
- if (ret != 0) {
- dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
- return ret;
- }
-
ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies),
wm8737->supplies);
if (ret != 0) {
@@ -607,17 +597,12 @@ static int wm8737_probe(struct snd_soc_codec *codec)
err_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
err_get:
- regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
-
return ret;
}
static int wm8737_remove(struct snd_soc_codec *codec)
{
- struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
-
wm8737_set_bias_level(codec, SND_SOC_BIAS_OFF);
- regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
return 0;
}
@@ -645,13 +630,23 @@ static __devinit int wm8737_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct wm8737_priv *wm8737;
- int ret;
+ int ret, i;
wm8737 = devm_kzalloc(&i2c->dev, sizeof(struct wm8737_priv),
GFP_KERNEL);
if (wm8737 == NULL)
return -ENOMEM;
+ for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
+ wm8737->supplies[i].supply = wm8737_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8737->supplies),
+ wm8737->supplies);
+ if (ret != 0) {
+ dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+ return ret;
+ }
+
i2c_set_clientdata(i2c, wm8737);
wm8737->control_type = SND_SOC_I2C;
@@ -691,13 +686,23 @@ static struct i2c_driver wm8737_i2c_driver = {
static int __devinit wm8737_spi_probe(struct spi_device *spi)
{
struct wm8737_priv *wm8737;
- int ret;
+ int ret, i;
wm8737 = devm_kzalloc(&spi->dev, sizeof(struct wm8737_priv),
GFP_KERNEL);
if (wm8737 == NULL)
return -ENOMEM;
+ for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
+ wm8737->supplies[i].supply = wm8737_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(wm8737->supplies),
+ wm8737->supplies);
+ if (ret != 0) {
+ dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
+ return ret;
+ }
+
wm8737->control_type = SND_SOC_SPI;
spi_set_drvdata(spi, wm8737);