From patchwork Mon Jun 11 17:27:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 164230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 080D2B6FFE for ; Tue, 12 Jun 2012 03:27:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751354Ab2FKR12 (ORCPT ); Mon, 11 Jun 2012 13:27:28 -0400 Received: from avon.wwwdotorg.org ([70.85.31.133]:34275 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942Ab2FKR12 (ORCPT ); Mon, 11 Jun 2012 13:27:28 -0400 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 8D5D59EA43; Mon, 11 Jun 2012 11:30:47 -0600 (MDT) Received: from localhost.localdomain (searspoint.nvidia.com [216.228.112.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 24479E40F2; Mon, 11 Jun 2012 11:27:26 -0600 (MDT) From: Stephen Warren To: Mark Brown , Liam Girdwood Cc: alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org, Stephen Warren Subject: [PATCH] ASoC: tegra+wm8903: turn of mic detect when card is removed Date: Mon, 11 Jun 2012 11:27:19 -0600 Message-Id: <1339435640-20171-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.0.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Stephen Warren 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 --- 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,