diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-10 04:23:34 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-10 05:25:44 -0400 |
commit | 719b0c593cbb2a199e977b4dcca1d096a4a0d6a7 (patch) | |
tree | 0e6675250dbf2e381b57b681e815d7ed25572629 | |
parent | 7d014db8baf70bcc7e9cf1457350b11bc2affbbd (diff) |
ASoC: wm8523: Move regulator acquisition to I2C probe()
This is better style since we acquire all needed resources before we try
to do the ASoC card probe.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8523.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index af2289ee6cd6..c4c64e225c42 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c | |||
@@ -402,7 +402,7 @@ static int wm8523_resume(struct snd_soc_codec *codec) | |||
402 | static int wm8523_probe(struct snd_soc_codec *codec) | 402 | static int wm8523_probe(struct snd_soc_codec *codec) |
403 | { | 403 | { |
404 | struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); | 404 | struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); |
405 | int ret, i; | 405 | int ret; |
406 | 406 | ||
407 | wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; | 407 | wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; |
408 | wm8523->rate_constraint.count = | 408 | wm8523->rate_constraint.count = |
@@ -414,16 +414,6 @@ static int wm8523_probe(struct snd_soc_codec *codec) | |||
414 | return ret; | 414 | return ret; |
415 | } | 415 | } |
416 | 416 | ||
417 | for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++) | ||
418 | wm8523->supplies[i].supply = wm8523_supply_names[i]; | ||
419 | |||
420 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8523->supplies), | ||
421 | wm8523->supplies); | ||
422 | if (ret != 0) { | ||
423 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
424 | return ret; | ||
425 | } | ||
426 | |||
427 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), | 417 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), |
428 | wm8523->supplies); | 418 | wm8523->supplies); |
429 | if (ret != 0) { | 419 | if (ret != 0) { |
@@ -471,7 +461,6 @@ static int wm8523_probe(struct snd_soc_codec *codec) | |||
471 | err_enable: | 461 | err_enable: |
472 | regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); | 462 | regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); |
473 | err_get: | 463 | err_get: |
474 | regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); | ||
475 | 464 | ||
476 | return ret; | 465 | return ret; |
477 | } | 466 | } |
@@ -481,7 +470,6 @@ static int wm8523_remove(struct snd_soc_codec *codec) | |||
481 | struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); | 470 | struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); |
482 | 471 | ||
483 | wm8523_set_bias_level(codec, SND_SOC_BIAS_OFF); | 472 | wm8523_set_bias_level(codec, SND_SOC_BIAS_OFF); |
484 | regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); | ||
485 | return 0; | 473 | return 0; |
486 | } | 474 | } |
487 | 475 | ||
@@ -514,13 +502,23 @@ static __devinit int wm8523_i2c_probe(struct i2c_client *i2c, | |||
514 | const struct i2c_device_id *id) | 502 | const struct i2c_device_id *id) |
515 | { | 503 | { |
516 | struct wm8523_priv *wm8523; | 504 | struct wm8523_priv *wm8523; |
517 | int ret; | 505 | int ret, i; |
518 | 506 | ||
519 | wm8523 = devm_kzalloc(&i2c->dev, sizeof(struct wm8523_priv), | 507 | wm8523 = devm_kzalloc(&i2c->dev, sizeof(struct wm8523_priv), |
520 | GFP_KERNEL); | 508 | GFP_KERNEL); |
521 | if (wm8523 == NULL) | 509 | if (wm8523 == NULL) |
522 | return -ENOMEM; | 510 | return -ENOMEM; |
523 | 511 | ||
512 | for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++) | ||
513 | wm8523->supplies[i].supply = wm8523_supply_names[i]; | ||
514 | |||
515 | ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8523->supplies), | ||
516 | wm8523->supplies); | ||
517 | if (ret != 0) { | ||
518 | dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); | ||
519 | return ret; | ||
520 | } | ||
521 | |||
524 | i2c_set_clientdata(i2c, wm8523); | 522 | i2c_set_clientdata(i2c, wm8523); |
525 | wm8523->control_type = SND_SOC_I2C; | 523 | wm8523->control_type = SND_SOC_I2C; |
526 | 524 | ||