From patchwork Mon Nov 10 00:45:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 5262051 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 9D9E8C11AC for ; Mon, 10 Nov 2014 01:04:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7E4520166 for ; Mon, 10 Nov 2014 01:04:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1EF8F2011D for ; Mon, 10 Nov 2014 01:04:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9A6D52605D1; Mon, 10 Nov 2014 02:04:13 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6C8BD2605B6; Mon, 10 Nov 2014 02:04:02 +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 1A34A2605B8; Mon, 10 Nov 2014 02:04:01 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 113332605B5 for ; Mon, 10 Nov 2014 02:03:53 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 01B30AB07; Mon, 10 Nov 2014 00:45:29 +0000 (UTC) Date: Mon, 10 Nov 2014 11:45:18 +1100 From: NeilBrown To: Mark Brown Message-ID: <20141110114518.715dcd4e@notabene.brown> In-Reply-To: <20141108092242.GB2722@sirena.org.uk> References: <20141108002637.6561.19002.stgit@notabene.brown> <20141108003803.6561.42934.stgit@notabene.brown> <20141108092242.GB2722@sirena.org.uk> X-Mailer: Claws Mail 3.10.1-162-g4d0ed6 (GTK+ 2.24.24; x86_64-suse-linux-gnu) MIME-Version: 1.0 Cc: Mark Rutland , GTA04 owners , alsa-devel@alsa-project.org, Pawel Moll , Ian Campbell , Liam Girdwood , linux-kernel@vger.kernel.org, Peter Ujfalusi , devicetree@vger.kernel.org, Rob Herring Subject: Re: [alsa-devel] [PATCH 1/3] ASoC: twl4030: don't report EBUSY if no change requested. 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 8 Nov 2014 09:22:42 +0000 Mark Brown wrote: > On Sat, Nov 08, 2014 at 11:38:03AM +1100, NeilBrown wrote: > > > + int val = ucontrol->value.integer.value[0]; > > + > > + if (!!(twl4030_read(codec, TWL4030_REG_CODEC_MODE) > > + & TWL4030_OPTION_1) == !!val) > > + /* No change */ > > + return 0; > > We shouldn't be accepting attempts to set out of range values so there > should be no need for the !! on val (which confused me when I was > reading this). True, the '!!' on val isn't necessary. I took the opportunity to look around a bit more and discovered there was a snd_soc_get_enum_double, which I really should use in preference to twl4030_read. So here is the new version. Can it be taken out of the email, or should I resend stand-alone? Thanks, NeilBrown From: NeilBrown Date: Wed, 2 Oct 2013 14:45:52 +1000 Subject: [PATCH] ASoC: twl4030: don't report EBUSY if no change requested. "mode" must not be changed when active. However if a request is received to set the mode to what it currently is, that is also rejected when active, which causes confusing error messages. So check first and if no change is actually requested, don't report an error. Signed-off-by: NeilBrown diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index b6b0cb399599..613b61cee081 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -957,6 +957,16 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_ctl_elem_value currentval; + int ret; + + ret = snd_soc_get_enum_double(kcontrol, ¤tval); + if (ret) + return ret; + if (ucontrol->value.enumerated.item[0] == + currentval.value.enumerated.item[0]) + /* No change */ + return 0; if (twl4030->configured) { dev_err(codec->dev,