aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 00:36:28 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-12 02:09:37 -0400
commit4f69bb31b8840713f82c6c476bae3f2356819ce2 (patch)
treeaf5d152abf489354563bf71ea159430de4c6ced4
parentd16383ef2a62fe53a929eac56b662d6def6bb8c7 (diff)
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>
-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)
557static int wm8737_probe(struct snd_soc_codec *codec) 557static int wm8737_probe(struct snd_soc_codec *codec)
558{ 558{
559 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); 559 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
560 int ret, i; 560 int ret;
561 561
562 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8737->control_type); 562 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8737->control_type);
563 if (ret != 0) { 563 if (ret != 0) {
@@ -565,16 +565,6 @@ static int wm8737_probe(struct snd_soc_codec *codec)
565 return ret; 565 return ret;
566 } 566 }
567 567
568 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
569 wm8737->supplies[i].supply = wm8737_supply_names[i];
570
571 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8737->supplies),
572 wm8737->supplies);
573 if (ret != 0) {
574 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
575 return ret;
576 }
577
578 ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), 568 ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies),
579 wm8737->supplies); 569 wm8737->supplies);
580 if (ret != 0) { 570 if (ret != 0) {
@@ -607,17 +597,12 @@ static int wm8737_probe(struct snd_soc_codec *codec)
607err_enable: 597err_enable:
608 regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); 598 regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
609err_get: 599err_get:
610 regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
611
612 return ret; 600 return ret;
613} 601}
614 602
615static int wm8737_remove(struct snd_soc_codec *codec) 603static int wm8737_remove(struct snd_soc_codec *codec)
616{ 604{
617 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
618
619 wm8737_set_bias_level(codec, SND_SOC_BIAS_OFF); 605 wm8737_set_bias_level(codec, SND_SOC_BIAS_OFF);
620 regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
621 return 0; 606 return 0;
622} 607}
623 608
@@ -645,13 +630,23 @@ static __devinit int wm8737_i2c_probe(struct i2c_client *i2c,
645 const struct i2c_device_id *id) 630 const struct i2c_device_id *id)
646{ 631{
647 struct wm8737_priv *wm8737; 632 struct wm8737_priv *wm8737;
648 int ret; 633 int ret, i;
649 634
650 wm8737 = devm_kzalloc(&i2c->dev, sizeof(struct wm8737_priv), 635 wm8737 = devm_kzalloc(&i2c->dev, sizeof(struct wm8737_priv),
651 GFP_KERNEL); 636 GFP_KERNEL);
652 if (wm8737 == NULL) 637 if (wm8737 == NULL)
653 return -ENOMEM; 638 return -ENOMEM;
654 639
640 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
641 wm8737->supplies[i].supply = wm8737_supply_names[i];
642
643 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8737->supplies),
644 wm8737->supplies);
645 if (ret != 0) {
646 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
647 return ret;
648 }
649
655 i2c_set_clientdata(i2c, wm8737); 650 i2c_set_clientdata(i2c, wm8737);
656 wm8737->control_type = SND_SOC_I2C; 651 wm8737->control_type = SND_SOC_I2C;
657 652
@@ -691,13 +686,23 @@ static struct i2c_driver wm8737_i2c_driver = {
691static int __devinit wm8737_spi_probe(struct spi_device *spi) 686static int __devinit wm8737_spi_probe(struct spi_device *spi)
692{ 687{
693 struct wm8737_priv *wm8737; 688 struct wm8737_priv *wm8737;
694 int ret; 689 int ret, i;
695 690
696 wm8737 = devm_kzalloc(&spi->dev, sizeof(struct wm8737_priv), 691 wm8737 = devm_kzalloc(&spi->dev, sizeof(struct wm8737_priv),
697 GFP_KERNEL); 692 GFP_KERNEL);
698 if (wm8737 == NULL) 693 if (wm8737 == NULL)
699 return -ENOMEM; 694 return -ENOMEM;
700 695
696 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
697 wm8737->supplies[i].supply = wm8737_supply_names[i];
698
699 ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(wm8737->supplies),
700 wm8737->supplies);
701 if (ret != 0) {
702 dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
703 return ret;
704 }
705
701 wm8737->control_type = SND_SOC_SPI; 706 wm8737->control_type = SND_SOC_SPI;
702 spi_set_drvdata(spi, wm8737); 707 spi_set_drvdata(spi, wm8737);
703 708