aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-05-22 18:08:55 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-03 08:06:36 -0400
commite2d287c179a12a6069bc3b746e2e34edcddf81b3 (patch)
tree6dbb60fc7f15c550e7d077010fde9b106b1a1762 /sound/soc/tegra
parentf51022f1aedc4d1a02d0dfa8fde47f6a8291f618 (diff)
ASoC: tegra+wm8903: Use devm_gpio_request_one
By using this function, the driver no longer needs to explicitly free the GPIOs. Hence, we can also remove the flags we use to track whether we allocated these GPIOs. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/tegra')
-rw-r--r--sound/soc/tegra/tegra_wm8903.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index a8a3103ab4cb..5ef2063e0ab1 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -50,10 +50,6 @@
50 50
51#define DRV_NAME "tegra-snd-wm8903" 51#define DRV_NAME "tegra-snd-wm8903"
52 52
53#define GPIO_SPKR_EN BIT(0)
54#define GPIO_HP_MUTE BIT(1)
55#define GPIO_INT_MIC_EN BIT(2)
56#define GPIO_EXT_MIC_EN BIT(3)
57#define GPIO_HP_DET BIT(4) 53#define GPIO_HP_DET BIT(4)
58 54
59struct tegra_wm8903 { 55struct tegra_wm8903 {
@@ -401,49 +397,41 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
401 } 397 }
402 398
403 if (gpio_is_valid(pdata->gpio_spkr_en)) { 399 if (gpio_is_valid(pdata->gpio_spkr_en)) {
404 ret = gpio_request(pdata->gpio_spkr_en, "spkr_en"); 400 ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_spkr_en,
401 GPIOF_OUT_INIT_LOW, "spkr_en");
405 if (ret) { 402 if (ret) {
406 dev_err(card->dev, "cannot get spkr_en gpio\n"); 403 dev_err(card->dev, "cannot get spkr_en gpio\n");
407 return ret; 404 return ret;
408 } 405 }
409 machine->gpio_requested |= GPIO_SPKR_EN;
410
411 gpio_direction_output(pdata->gpio_spkr_en, 0);
412 } 406 }
413 407
414 if (gpio_is_valid(pdata->gpio_hp_mute)) { 408 if (gpio_is_valid(pdata->gpio_hp_mute)) {
415 ret = gpio_request(pdata->gpio_hp_mute, "hp_mute"); 409 ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_hp_mute,
410 GPIOF_OUT_INIT_HIGH, "hp_mute");
416 if (ret) { 411 if (ret) {
417 dev_err(card->dev, "cannot get hp_mute gpio\n"); 412 dev_err(card->dev, "cannot get hp_mute gpio\n");
418 return ret; 413 return ret;
419 } 414 }
420 machine->gpio_requested |= GPIO_HP_MUTE;
421
422 gpio_direction_output(pdata->gpio_hp_mute, 1);
423 } 415 }
424 416
425 if (gpio_is_valid(pdata->gpio_int_mic_en)) { 417 if (gpio_is_valid(pdata->gpio_int_mic_en)) {
426 ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en"); 418 /* Disable int mic; enable signal is active-high */
419 ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_int_mic_en,
420 GPIOF_OUT_INIT_LOW, "int_mic_en");
427 if (ret) { 421 if (ret) {
428 dev_err(card->dev, "cannot get int_mic_en gpio\n"); 422 dev_err(card->dev, "cannot get int_mic_en gpio\n");
429 return ret; 423 return ret;
430 } 424 }
431 machine->gpio_requested |= GPIO_INT_MIC_EN;
432
433 /* Disable int mic; enable signal is active-high */
434 gpio_direction_output(pdata->gpio_int_mic_en, 0);
435 } 425 }
436 426
437 if (gpio_is_valid(pdata->gpio_ext_mic_en)) { 427 if (gpio_is_valid(pdata->gpio_ext_mic_en)) {
438 ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en"); 428 /* Enable ext mic; enable signal is active-low */
429 ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_ext_mic_en,
430 GPIOF_OUT_INIT_LOW, "ext_mic_en");
439 if (ret) { 431 if (ret) {
440 dev_err(card->dev, "cannot get ext_mic_en gpio\n"); 432 dev_err(card->dev, "cannot get ext_mic_en gpio\n");
441 return ret; 433 return ret;
442 } 434 }
443 machine->gpio_requested |= GPIO_EXT_MIC_EN;
444
445 /* Enable ext mic; enable signal is active-low */
446 gpio_direction_output(pdata->gpio_ext_mic_en, 0);
447 } 435 }
448 436
449 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); 437 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
@@ -469,21 +457,11 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
469{ 457{
470 struct snd_soc_card *card = platform_get_drvdata(pdev); 458 struct snd_soc_card *card = platform_get_drvdata(pdev);
471 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); 459 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
472 struct tegra_wm8903_platform_data *pdata = &machine->pdata;
473 460
474 if (machine->gpio_requested & GPIO_HP_DET) 461 if (machine->gpio_requested & GPIO_HP_DET)
475 snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 462 snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack,
476 1, 463 1,
477 &tegra_wm8903_hp_jack_gpio); 464 &tegra_wm8903_hp_jack_gpio);
478 if (machine->gpio_requested & GPIO_EXT_MIC_EN)
479 gpio_free(pdata->gpio_ext_mic_en);
480 if (machine->gpio_requested & GPIO_INT_MIC_EN)
481 gpio_free(pdata->gpio_int_mic_en);
482 if (machine->gpio_requested & GPIO_HP_MUTE)
483 gpio_free(pdata->gpio_hp_mute);
484 if (machine->gpio_requested & GPIO_SPKR_EN)
485 gpio_free(pdata->gpio_spkr_en);
486 machine->gpio_requested = 0;
487 465
488 snd_soc_unregister_card(card); 466 snd_soc_unregister_card(card);
489 467