aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra/tegra_alc5632.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-05-22 18:14:53 -0400
committerMark Brown <broonie@linaro.org>2014-05-26 09:32:34 -0400
commitfb6b8e71448aef58628eb9da007c30e731925260 (patch)
treeef47b51e3386916a0517615b299caaf6c4a0d3fb /sound/soc/tegra/tegra_alc5632.c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
ASoC: tegra: free jack GPIOs before the sound card is freed
snd_soc_jack_add_gpios() schedules a work queue item to poll the GPIO to generate an initial jack status report. If sound card initialization fails, that work item needs to be cancelled, so it doesn't run after the card has been freed. Specifically, freeing the card calls snd_jack_dev_free() which calls snd_jack_dev_disconnect() which sets jack->input_dev = NULL, and input_dev is used by snd_jack_report(), which is called from the work queue item. snd_soc_jack_free_gpios() cancels the work item. The Tegra ASoC machine drivers do call this function in the platform driver remove() callback. However, this happens after the sound card is freed, at least when the card is freed due to errors late during snd_soc_instantiate_card(). This leaves a window where the work item can execute after the card is freed. In next-20140522, sound card initialization does fail for unrelated reasons, and hits the problem described above. To solve this, fix the Tegra ASoC machine drivers to clean up the Jack GPIOs during the snd_soc_card's .remove() callback, which is executed before the overall card object is freed. also, gGuard the cleanup call based on whether we actually setup up the GPIOs in the first place. Ideally, we'd do the cleanup in a struct snd_soc_dai_link .fini/remove function to match where the GPIOs get set up. However, there is no such callback. This change fixes all Tegra machine drivers. By code inspection, I believe some non-Tegra machine drivers have the same issue. I'll send a patch for that separately, once this is reviewed. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/tegra/tegra_alc5632.c')
-rw-r--r--sound/soc/tegra/tegra_alc5632.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index c61ea3a1030f..02734bd4f09b 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -125,6 +125,18 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
125 return 0; 125 return 0;
126} 126}
127 127
128static int tegra_alc5632_card_remove(struct snd_soc_card *card)
129{
130 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card);
131
132 if (gpio_is_valid(machine->gpio_hp_det)) {
133 snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1,
134 &tegra_alc5632_hp_jack_gpio);
135 }
136
137 return 0;
138}
139
128static struct snd_soc_dai_link tegra_alc5632_dai = { 140static struct snd_soc_dai_link tegra_alc5632_dai = {
129 .name = "ALC5632", 141 .name = "ALC5632",
130 .stream_name = "ALC5632 PCM", 142 .stream_name = "ALC5632 PCM",
@@ -139,6 +151,7 @@ static struct snd_soc_dai_link tegra_alc5632_dai = {
139static struct snd_soc_card snd_soc_tegra_alc5632 = { 151static struct snd_soc_card snd_soc_tegra_alc5632 = {
140 .name = "tegra-alc5632", 152 .name = "tegra-alc5632",
141 .owner = THIS_MODULE, 153 .owner = THIS_MODULE,
154 .remove = tegra_alc5632_card_remove,
142 .dai_link = &tegra_alc5632_dai, 155 .dai_link = &tegra_alc5632_dai,
143 .num_links = 1, 156 .num_links = 1,
144 .controls = tegra_alc5632_controls, 157 .controls = tegra_alc5632_controls,
@@ -223,9 +236,6 @@ static int tegra_alc5632_remove(struct platform_device *pdev)
223 struct snd_soc_card *card = platform_get_drvdata(pdev); 236 struct snd_soc_card *card = platform_get_drvdata(pdev);
224 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); 237 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card);
225 238
226 snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1,
227 &tegra_alc5632_hp_jack_gpio);
228
229 snd_soc_unregister_card(card); 239 snd_soc_unregister_card(card);
230 240
231 tegra_asoc_utils_fini(&machine->util_data); 241 tegra_asoc_utils_fini(&machine->util_data);