aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-05-30 14:42:57 -0400
committerMark Brown <broonie@linaro.org>2014-06-03 05:41:16 -0400
commite1d4d3c854f25cff6c6c139588570e124d5e8fa4 (patch)
treed3fcf11a7912943e8924dae0ef82cb0a81f23be7 /sound/soc/pxa
parenta2fbbbf10d7a11a949c32625e7088ad46f3c4bbc (diff)
ASoC: free jack GPIOs before the sound card is freed
This is the same change as commit fb6b8e71448a "ASoC: tegra: free jack GPIOs before the sound card is freed", but applied to all other ASoC machine drivers where code inspection indicates the same problem exists. That commit's description is: ========== 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, guard 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. ========== Note that I have not even compile-tested this in most cases, since most of the drivers rely on specific mach-* support I don't have enabled, and don't support COMPILE_TEST. Testing by the relevant board maintainers would be useful. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r--sound/soc/pxa/hx4700.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c
index dcc9b04bd92c..6b81acaffddd 100644
--- a/sound/soc/pxa/hx4700.c
+++ b/sound/soc/pxa/hx4700.c
@@ -152,6 +152,13 @@ static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd)
152 return err; 152 return err;
153} 153}
154 154
155static int hx4700_card_remove(struct snd_soc_pcm_runtime *rtd)
156{
157 snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio);
158
159 return 0;
160}
161
155/* hx4700 digital audio interface glue - connects codec <--> CPU */ 162/* hx4700 digital audio interface glue - connects codec <--> CPU */
156static struct snd_soc_dai_link hx4700_dai = { 163static struct snd_soc_dai_link hx4700_dai = {
157 .name = "ak4641", 164 .name = "ak4641",
@@ -170,6 +177,7 @@ static struct snd_soc_dai_link hx4700_dai = {
170static struct snd_soc_card snd_soc_card_hx4700 = { 177static struct snd_soc_card snd_soc_card_hx4700 = {
171 .name = "iPAQ hx4700", 178 .name = "iPAQ hx4700",
172 .owner = THIS_MODULE, 179 .owner = THIS_MODULE,
180 .remove = hx4700_card_remove,
173 .dai_link = &hx4700_dai, 181 .dai_link = &hx4700_dai,
174 .num_links = 1, 182 .num_links = 1,
175 .dapm_widgets = hx4700_dapm_widgets, 183 .dapm_widgets = hx4700_dapm_widgets,
@@ -206,7 +214,6 @@ static int hx4700_audio_probe(struct platform_device *pdev)
206 214
207static int hx4700_audio_remove(struct platform_device *pdev) 215static int hx4700_audio_remove(struct platform_device *pdev)
208{ 216{
209 snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio);
210 snd_soc_unregister_card(&snd_soc_card_hx4700); 217 snd_soc_unregister_card(&snd_soc_card_hx4700);
211 218
212 gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); 219 gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0);