linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: tegra+wm8903: turn of mic detect when card is removed
@ 2012-06-11 17:27 Stephen Warren
       [not found] ` <1339435640-20171-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2012-06-11 17:27 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: linux-tegra, alsa-devel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

If mic detect is left enabled and the WM8903 detects a status change,
the WM8903 driver will make a callback against the free()d jack, which
will cause a crash.

This problem can be triggered by fully initializing an audio card, then
removing and re-inserting the machine driver module.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/tegra_wm8903.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index 08b5fef..0c5bb33 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -213,6 +213,17 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
+static int tegra_wm8903_remove(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]);
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+
+	wm8903_mic_detect(codec, NULL, 0, 0);
+
+	return 0;
+}
+
 static struct snd_soc_dai_link tegra_wm8903_dai = {
 	.name = "WM8903",
 	.stream_name = "WM8903 PCM",
@@ -233,6 +244,8 @@ static struct snd_soc_card snd_soc_tegra_wm8903 = {
 	.dai_link = &tegra_wm8903_dai,
 	.num_links = 1,
 
+	.remove = tegra_wm8903_remove,
+
 	.controls = tegra_wm8903_controls,
 	.num_controls = ARRAY_SIZE(tegra_wm8903_controls),
 	.dapm_widgets = tegra_wm8903_dapm_widgets,
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-12  3:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-11 17:27 [PATCH] ASoC: tegra+wm8903: turn of mic detect when card is removed Stephen Warren
     [not found] ` <1339435640-20171-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-06-12  3:42   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).