]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ASoC: tegra+wm8903: turn of mic detect when card is removed
authorStephen Warren <swarren@nvidia.com>
Mon, 11 Jun 2012 17:27:19 +0000 (11:27 -0600)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 12 Jun 2012 03:38:48 +0000 (11:38 +0800)
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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/tegra/tegra_wm8903.c

index 0b0df49d9d33b071118576c340b69366f212663f..3b6da91188a9949faaacaa73539f3fa04dbbcd4b 100644 (file)
@@ -346,6 +346,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",
@@ -363,6 +374,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,