diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-12 00:03:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-12 02:09:18 -0400 |
commit | 18273b05def692d1883745d22e72fa275bc92c17 (patch) | |
tree | 328cdf6e7b13577b974f47d14750b70230febafe /sound/soc/codecs/wm8580.c | |
parent | b689d9f9961befd9b322783f512195785fe82daa (diff) |
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.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 02c75bec7d71..5e9c40fa7eb2 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[] = { | |||
867 | static int wm8580_probe(struct snd_soc_codec *codec) | 867 | static int wm8580_probe(struct snd_soc_codec *codec) |
868 | { | 868 | { |
869 | struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); | 869 | struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); |
870 | int ret = 0,i; | 870 | int ret = 0; |
871 | 871 | ||
872 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); | 872 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); |
873 | if (ret < 0) { | 873 | if (ret < 0) { |
@@ -875,16 +875,6 @@ static int wm8580_probe(struct snd_soc_codec *codec) | |||
875 | return ret; | 875 | return ret; |
876 | } | 876 | } |
877 | 877 | ||
878 | for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++) | ||
879 | wm8580->supplies[i].supply = wm8580_supply_names[i]; | ||
880 | |||
881 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8580->supplies), | ||
882 | wm8580->supplies); | ||
883 | if (ret != 0) { | ||
884 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), | 878 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), |
889 | wm8580->supplies); | 879 | wm8580->supplies); |
890 | if (ret != 0) { | 880 | if (ret != 0) { |
@@ -906,7 +896,6 @@ static int wm8580_probe(struct snd_soc_codec *codec) | |||
906 | err_regulator_enable: | 896 | err_regulator_enable: |
907 | regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); | 897 | regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); |
908 | err_regulator_get: | 898 | err_regulator_get: |
909 | regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); | ||
910 | return ret; | 899 | return ret; |
911 | } | 900 | } |
912 | 901 | ||
@@ -918,7 +907,6 @@ static int wm8580_remove(struct snd_soc_codec *codec) | |||
918 | wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF); | 907 | wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF); |
919 | 908 | ||
920 | regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); | 909 | regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); |
921 | regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); | ||
922 | 910 | ||
923 | return 0; | 911 | return 0; |
924 | } | 912 | } |
@@ -958,7 +946,7 @@ static int wm8580_i2c_probe(struct i2c_client *i2c, | |||
958 | const struct i2c_device_id *id) | 946 | const struct i2c_device_id *id) |
959 | { | 947 | { |
960 | struct wm8580_priv *wm8580; | 948 | struct wm8580_priv *wm8580; |
961 | int ret; | 949 | int ret, i; |
962 | 950 | ||
963 | wm8580 = devm_kzalloc(&i2c->dev, sizeof(struct wm8580_priv), | 951 | wm8580 = devm_kzalloc(&i2c->dev, sizeof(struct wm8580_priv), |
964 | GFP_KERNEL); | 952 | GFP_KERNEL); |
@@ -969,6 +957,16 @@ static int wm8580_i2c_probe(struct i2c_client *i2c, | |||
969 | if (IS_ERR(wm8580->regmap)) | 957 | if (IS_ERR(wm8580->regmap)) |
970 | return PTR_ERR(wm8580->regmap); | 958 | return PTR_ERR(wm8580->regmap); |
971 | 959 | ||
960 | for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++) | ||
961 | wm8580->supplies[i].supply = wm8580_supply_names[i]; | ||
962 | |||
963 | ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8580->supplies), | ||
964 | wm8580->supplies); | ||
965 | if (ret != 0) { | ||
966 | dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); | ||
967 | return ret; | ||
968 | } | ||
969 | |||
972 | i2c_set_clientdata(i2c, wm8580); | 970 | i2c_set_clientdata(i2c, wm8580); |
973 | 971 | ||
974 | ret = snd_soc_register_codec(&i2c->dev, | 972 | ret = snd_soc_register_codec(&i2c->dev, |