diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-12-07 06:02:26 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-09 10:17:34 -0500 |
commit | d06080cf08e6b59971959d9be3d0587c6e033292 (patch) | |
tree | 47e10e1b5ecfa74dad9d5e9101a9c7fcef7d4611 /sound/soc | |
parent | 9489e9dcae718d5fde988e4a684a0f55b5f94d17 (diff) |
ASoC: tpa6130a2: Use devm_* APIs
Converted to use devm_gpio_request and devm_regulator_get APIs.
These are device managed and make error handling and cleanup
a bit simpler.
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 565ff39ad3a3..ec78073e3588 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
@@ -398,7 +398,8 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, | |||
398 | TPA6130A2_MUTE_L; | 398 | TPA6130A2_MUTE_L; |
399 | 399 | ||
400 | if (data->power_gpio >= 0) { | 400 | if (data->power_gpio >= 0) { |
401 | ret = gpio_request(data->power_gpio, "tpa6130a2 enable"); | 401 | ret = devm_gpio_request(dev, data->power_gpio, |
402 | "tpa6130a2 enable"); | ||
402 | if (ret < 0) { | 403 | if (ret < 0) { |
403 | dev_err(dev, "Failed to request power GPIO (%d)\n", | 404 | dev_err(dev, "Failed to request power GPIO (%d)\n", |
404 | data->power_gpio); | 405 | data->power_gpio); |
@@ -419,16 +420,16 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, | |||
419 | break; | 420 | break; |
420 | } | 421 | } |
421 | 422 | ||
422 | data->supply = regulator_get(dev, regulator); | 423 | data->supply = devm_regulator_get(dev, regulator); |
423 | if (IS_ERR(data->supply)) { | 424 | if (IS_ERR(data->supply)) { |
424 | ret = PTR_ERR(data->supply); | 425 | ret = PTR_ERR(data->supply); |
425 | dev_err(dev, "Failed to request supply: %d\n", ret); | 426 | dev_err(dev, "Failed to request supply: %d\n", ret); |
426 | goto err_regulator; | 427 | goto err_gpio; |
427 | } | 428 | } |
428 | 429 | ||
429 | ret = tpa6130a2_power(1); | 430 | ret = tpa6130a2_power(1); |
430 | if (ret != 0) | 431 | if (ret != 0) |
431 | goto err_power; | 432 | goto err_gpio; |
432 | 433 | ||
433 | 434 | ||
434 | /* Read version */ | 435 | /* Read version */ |
@@ -440,15 +441,10 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, | |||
440 | /* Disable the chip */ | 441 | /* Disable the chip */ |
441 | ret = tpa6130a2_power(0); | 442 | ret = tpa6130a2_power(0); |
442 | if (ret != 0) | 443 | if (ret != 0) |
443 | goto err_power; | 444 | goto err_gpio; |
444 | 445 | ||
445 | return 0; | 446 | return 0; |
446 | 447 | ||
447 | err_power: | ||
448 | regulator_put(data->supply); | ||
449 | err_regulator: | ||
450 | if (data->power_gpio >= 0) | ||
451 | gpio_free(data->power_gpio); | ||
452 | err_gpio: | 448 | err_gpio: |
453 | tpa6130a2_client = NULL; | 449 | tpa6130a2_client = NULL; |
454 | 450 | ||
@@ -457,14 +453,7 @@ err_gpio: | |||
457 | 453 | ||
458 | static int __devexit tpa6130a2_remove(struct i2c_client *client) | 454 | static int __devexit tpa6130a2_remove(struct i2c_client *client) |
459 | { | 455 | { |
460 | struct tpa6130a2_data *data = i2c_get_clientdata(client); | ||
461 | |||
462 | tpa6130a2_power(0); | 456 | tpa6130a2_power(0); |
463 | |||
464 | if (data->power_gpio >= 0) | ||
465 | gpio_free(data->power_gpio); | ||
466 | |||
467 | regulator_put(data->supply); | ||
468 | tpa6130a2_client = NULL; | 457 | tpa6130a2_client = NULL; |
469 | 458 | ||
470 | return 0; | 459 | return 0; |