From patchwork Mon Feb 17 16:51:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 3664141 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 347FABF13A for ; Mon, 17 Feb 2014 17:03:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CC61201F7 for ; Mon, 17 Feb 2014 17:03:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2C14920131 for ; Mon, 17 Feb 2014 17:03:37 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2461A264F4A; Mon, 17 Feb 2014 18:03:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 40DAC264F45; Mon, 17 Feb 2014 18:00:51 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DF0F7264FBA; Mon, 17 Feb 2014 18:00:48 +0100 (CET) Received: from opensource.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id 4D29B264F45 for ; Mon, 17 Feb 2014 18:00:07 +0100 (CET) Received: from localhost.localdomain (unknown [87.246.78.26]) by opensource.wolfsonmicro.com (Postfix) with ESMTPSA id 5E0873B40FD; Mon, 17 Feb 2014 17:00:04 +0000 (GMT) From: Charles Keepax To: broonie@kernel.org Date: Mon, 17 Feb 2014 16:51:34 +0000 Message-Id: <1392655903-24537-7-git-send-email-ckeepax@opensource.wolfsonmicro.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1392655903-24537-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> References: <1392655903-24537-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> Cc: alsa-devel@alsa-project.org, lars@metafoo.de, eric.y.miao@gmail.com, dmitry.torokhov@gmail.com, lgirdwood@gmail.com, haojian.zhuang@gmail.com, linux-kernel@vger.kernel.org, peter.ujfalusi@ti.com, cw00.choi@samsung.com, myungjoo.ham@samsung.com, patches@opensource.wolfsonmicro.com, linux@arm.linux.org.uk, jarkko.nikula@bitmer.com Subject: [alsa-devel] [PATCH 06/15] ASoC: wm8994: Update locking around use of DAPM pin API X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Spam-Level: * X-Virus-Scanned: ClamAV using ClamSMTP The pin updates in this driver look like they are intended to be done atomically, update to do so. Signed-off-by: Charles Keepax --- sound/soc/codecs/wm8994.c | 40 ++++++++++++++++++++++++---------------- 1 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index b9be9cb..4788c4e 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -2552,38 +2552,46 @@ int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) switch (mode) { case WM8994_VMID_NORMAL: + mutex_lock(&codec->dapm.card->dapm_mutex); + if (wm8994->hubs.lineout1_se) { - snd_soc_dapm_disable_pin(&codec->dapm, - "LINEOUT1N Driver"); - snd_soc_dapm_disable_pin(&codec->dapm, - "LINEOUT1P Driver"); + snd_soc_dapm_disable_pin_locked(&codec->dapm, + "LINEOUT1N Driver"); + snd_soc_dapm_disable_pin_locked(&codec->dapm, + "LINEOUT1P Driver"); } if (wm8994->hubs.lineout2_se) { - snd_soc_dapm_disable_pin(&codec->dapm, - "LINEOUT2N Driver"); - snd_soc_dapm_disable_pin(&codec->dapm, - "LINEOUT2P Driver"); + snd_soc_dapm_disable_pin_locked(&codec->dapm, + "LINEOUT2N Driver"); + snd_soc_dapm_disable_pin_locked(&codec->dapm, + "LINEOUT2P Driver"); } + mutex_unlock(&codec->dapm.card->dapm_mutex); + /* Do the sync with the old mode to allow it to clean up */ snd_soc_dapm_sync(&codec->dapm); wm8994->vmid_mode = mode; break; case WM8994_VMID_FORCE: + mutex_lock(&codec->dapm.card->dapm_mutex); + if (wm8994->hubs.lineout1_se) { - snd_soc_dapm_force_enable_pin(&codec->dapm, - "LINEOUT1N Driver"); - snd_soc_dapm_force_enable_pin(&codec->dapm, - "LINEOUT1P Driver"); + snd_soc_dapm_force_enable_pin_locked(&codec->dapm, + "LINEOUT1N Driver"); + snd_soc_dapm_force_enable_pin_locked(&codec->dapm, + "LINEOUT1P Driver"); } if (wm8994->hubs.lineout2_se) { - snd_soc_dapm_force_enable_pin(&codec->dapm, - "LINEOUT2N Driver"); - snd_soc_dapm_force_enable_pin(&codec->dapm, - "LINEOUT2P Driver"); + snd_soc_dapm_force_enable_pin_locked(&codec->dapm, + "LINEOUT2N Driver"); + snd_soc_dapm_force_enable_pin_locked(&codec->dapm, + "LINEOUT2P Driver"); } + mutex_unlock(&codec->dapm.card->dapm_mutex); + wm8994->vmid_mode = mode; snd_soc_dapm_sync(&codec->dapm); break;