Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stephen Warren and committed by
Mark Brown
e2d287c1 f51022f1

+10 -32
+10 -32
sound/soc/tegra/tegra_wm8903.c
··· 50 50 51 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 53 #define GPIO_HP_DET BIT(4) 58 54 59 55 struct tegra_wm8903 { ··· 397 401 } 398 402 399 403 if (gpio_is_valid(pdata->gpio_spkr_en)) { 400 - ret = gpio_request(pdata->gpio_spkr_en, "spkr_en"); 404 + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_spkr_en, 405 + GPIOF_OUT_INIT_LOW, "spkr_en"); 401 406 if (ret) { 402 407 dev_err(card->dev, "cannot get spkr_en gpio\n"); 403 408 return ret; 404 409 } 405 - machine->gpio_requested |= GPIO_SPKR_EN; 406 - 407 - gpio_direction_output(pdata->gpio_spkr_en, 0); 408 410 } 409 411 410 412 if (gpio_is_valid(pdata->gpio_hp_mute)) { 411 - ret = gpio_request(pdata->gpio_hp_mute, "hp_mute"); 413 + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_hp_mute, 414 + GPIOF_OUT_INIT_HIGH, "hp_mute"); 412 415 if (ret) { 413 416 dev_err(card->dev, "cannot get hp_mute gpio\n"); 414 417 return ret; 415 418 } 416 - machine->gpio_requested |= GPIO_HP_MUTE; 417 - 418 - gpio_direction_output(pdata->gpio_hp_mute, 1); 419 419 } 420 420 421 421 if (gpio_is_valid(pdata->gpio_int_mic_en)) { 422 - ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en"); 422 + /* Disable int mic; enable signal is active-high */ 423 + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_int_mic_en, 424 + GPIOF_OUT_INIT_LOW, "int_mic_en"); 423 425 if (ret) { 424 426 dev_err(card->dev, "cannot get int_mic_en gpio\n"); 425 427 return ret; 426 428 } 427 - machine->gpio_requested |= GPIO_INT_MIC_EN; 428 - 429 - /* Disable int mic; enable signal is active-high */ 430 - gpio_direction_output(pdata->gpio_int_mic_en, 0); 431 429 } 432 430 433 431 if (gpio_is_valid(pdata->gpio_ext_mic_en)) { 434 - ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en"); 432 + /* Enable ext mic; enable signal is active-low */ 433 + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_ext_mic_en, 434 + GPIOF_OUT_INIT_LOW, "ext_mic_en"); 435 435 if (ret) { 436 436 dev_err(card->dev, "cannot get ext_mic_en gpio\n"); 437 437 return ret; 438 438 } 439 - machine->gpio_requested |= GPIO_EXT_MIC_EN; 440 - 441 - /* Enable ext mic; enable signal is active-low */ 442 - gpio_direction_output(pdata->gpio_ext_mic_en, 0); 443 439 } 444 440 445 441 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); ··· 457 469 { 458 470 struct snd_soc_card *card = platform_get_drvdata(pdev); 459 471 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); 460 - struct tegra_wm8903_platform_data *pdata = &machine->pdata; 461 472 462 473 if (machine->gpio_requested & GPIO_HP_DET) 463 474 snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 464 475 1, 465 476 &tegra_wm8903_hp_jack_gpio); 466 - if (machine->gpio_requested & GPIO_EXT_MIC_EN) 467 - gpio_free(pdata->gpio_ext_mic_en); 468 - if (machine->gpio_requested & GPIO_INT_MIC_EN) 469 - gpio_free(pdata->gpio_int_mic_en); 470 - if (machine->gpio_requested & GPIO_HP_MUTE) 471 - gpio_free(pdata->gpio_hp_mute); 472 - if (machine->gpio_requested & GPIO_SPKR_EN) 473 - gpio_free(pdata->gpio_spkr_en); 474 - machine->gpio_requested = 0; 475 477 476 478 snd_soc_unregister_card(card); 477 479