aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-10 05:52:59 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-10 06:04:40 -0400
commitd9780550a354058bc47db6ac48d3b77f186882c6 (patch)
tree0b39203e7bd0c0d93fddd1dd02f6e11fe6575b4a
parent6ac4262f367fd0d9b0219dfd014ffcca4a6cfa6a (diff)
ASoC: wm8741: Move regulator acquisition to I2C/SPI probe()
Better style as we acquire resources before trying the ASoC card probe. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/codecs/wm8741.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
index 35f3d23200e0..742744b4bba7 100644
--- a/sound/soc/codecs/wm8741.c
+++ b/sound/soc/codecs/wm8741.c
@@ -403,17 +403,6 @@ static int wm8741_probe(struct snd_soc_codec *codec)
403{ 403{
404 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 404 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
405 int ret = 0; 405 int ret = 0;
406 int i;
407
408 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
409 wm8741->supplies[i].supply = wm8741_supply_names[i];
410
411 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8741->supplies),
412 wm8741->supplies);
413 if (ret != 0) {
414 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
415 goto err;
416 }
417 406
418 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), 407 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies),
419 wm8741->supplies); 408 wm8741->supplies);
@@ -450,7 +439,6 @@ static int wm8741_probe(struct snd_soc_codec *codec)
450err_enable: 439err_enable:
451 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); 440 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
452err_get: 441err_get:
453 regulator_bulk_free(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
454err: 442err:
455 return ret; 443 return ret;
456} 444}
@@ -460,7 +448,6 @@ static int wm8741_remove(struct snd_soc_codec *codec)
460 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 448 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
461 449
462 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); 450 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
463 regulator_bulk_free(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
464 451
465 return 0; 452 return 0;
466} 453}
@@ -492,13 +479,23 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
492 const struct i2c_device_id *id) 479 const struct i2c_device_id *id)
493{ 480{
494 struct wm8741_priv *wm8741; 481 struct wm8741_priv *wm8741;
495 int ret; 482 int ret, i;
496 483
497 wm8741 = devm_kzalloc(&i2c->dev, sizeof(struct wm8741_priv), 484 wm8741 = devm_kzalloc(&i2c->dev, sizeof(struct wm8741_priv),
498 GFP_KERNEL); 485 GFP_KERNEL);
499 if (wm8741 == NULL) 486 if (wm8741 == NULL)
500 return -ENOMEM; 487 return -ENOMEM;
501 488
489 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
490 wm8741->supplies[i].supply = wm8741_supply_names[i];
491
492 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8741->supplies),
493 wm8741->supplies);
494 if (ret != 0) {
495 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
496 goto err;
497 }
498
502 i2c_set_clientdata(i2c, wm8741); 499 i2c_set_clientdata(i2c, wm8741);
503 wm8741->control_type = SND_SOC_I2C; 500 wm8741->control_type = SND_SOC_I2C;
504 501
@@ -536,13 +533,23 @@ static struct i2c_driver wm8741_i2c_driver = {
536static int __devinit wm8741_spi_probe(struct spi_device *spi) 533static int __devinit wm8741_spi_probe(struct spi_device *spi)
537{ 534{
538 struct wm8741_priv *wm8741; 535 struct wm8741_priv *wm8741;
539 int ret; 536 int ret, i;
540 537
541 wm8741 = devm_kzalloc(&spi->dev, sizeof(struct wm8741_priv), 538 wm8741 = devm_kzalloc(&spi->dev, sizeof(struct wm8741_priv),
542 GFP_KERNEL); 539 GFP_KERNEL);
543 if (wm8741 == NULL) 540 if (wm8741 == NULL)
544 return -ENOMEM; 541 return -ENOMEM;
545 542
543 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
544 wm8741->supplies[i].supply = wm8741_supply_names[i];
545
546 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8741->supplies),
547 wm8741->supplies);
548 if (ret != 0) {
549 dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
550 goto err;
551 }
552
546 wm8741->control_type = SND_SOC_SPI; 553 wm8741->control_type = SND_SOC_SPI;
547 spi_set_drvdata(spi, wm8741); 554 spi_set_drvdata(spi, wm8741);
548 555