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

ASoC: tegra+wm8903: unconditionally free jack GPIOs in remove

The headphone jack GPIOs are added/initialized in the DAI link's init()
method, and hence in theory may not always have been added before remove()
is called in some unusual cases. In order to prevent calling
snd_soc_jack_free_gpios() if snd_soc_jack_add_gpios() had not been, the
code kept track of the initialization state to avoid the free call when
necessary.

However, it appears that snd_soc_jack_free_gpios() is robust in the face
of being called without snd_soc_jack_add_gpios() first succeeding, so
there is little point manually tracking this information. Hence, remove
the tracking code. Almost all other machine drivers already operate this
way.

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
e44fbbd4 e2d287c1

+2 -8
+2 -8
sound/soc/tegra/tegra_wm8903.c
··· 50 50 51 51 #define DRV_NAME "tegra-snd-wm8903" 52 52 53 - #define GPIO_HP_DET BIT(4) 54 - 55 53 struct tegra_wm8903 { 56 54 struct tegra_wm8903_platform_data pdata; 57 55 struct tegra_asoc_utils_data util_data; 58 - int gpio_requested; 59 56 }; 60 57 61 58 static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream, ··· 249 252 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 250 253 1, 251 254 &tegra_wm8903_hp_jack_gpio); 252 - machine->gpio_requested |= GPIO_HP_DET; 253 255 } 254 256 255 257 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, ··· 454 458 struct snd_soc_card *card = platform_get_drvdata(pdev); 455 459 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); 456 460 457 - if (machine->gpio_requested & GPIO_HP_DET) 458 - snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 459 - 1, 460 - &tegra_wm8903_hp_jack_gpio); 461 + snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1, 462 + &tegra_wm8903_hp_jack_gpio); 461 463 462 464 snd_soc_unregister_card(card); 463 465