From patchwork Mon Nov 10 21:45:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 5269691 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 8413EC11AC for ; Mon, 10 Nov 2014 21:57:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE3E22012F for ; Mon, 10 Nov 2014 21:57:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 854FE2010E for ; Mon, 10 Nov 2014 21:57:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9B772265894; Mon, 10 Nov 2014 22:57:19 +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,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F2B426147A; Mon, 10 Nov 2014 22:53:20 +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 9EBFF261ADE; Mon, 10 Nov 2014 22:53:19 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 3DAE6261543 for ; Mon, 10 Nov 2014 22:45:51 +0100 (CET) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ABF0CABC6; Mon, 10 Nov 2014 21:45:50 +0000 (UTC) Date: Tue, 11 Nov 2014 08:45:37 +1100 From: NeilBrown To: Lars-Peter Clausen Message-ID: <20141111084537.1b4e726c@notabene.brown> In-Reply-To: <54606446.7030907@metafoo.de> References: <20141108002637.6561.19002.stgit@notabene.brown> <20141108003803.6561.42934.stgit@notabene.brown> <20141108092242.GB2722@sirena.org.uk> <20141110114518.715dcd4e@notabene.brown> <54606446.7030907@metafoo.de> 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 , Peter Ujfalusi , alsa-devel@alsa-project.org, Pawel Moll , Ian Campbell , Liam Girdwood , Rob Herring , linux-kernel@vger.kernel.org, GTA04 owners , devicetree@vger.kernel.org, Mark Brown 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 Mon, 10 Nov 2014 08:07:50 +0100 Lars-Peter Clausen wrote: > On 11/10/2014 01:45 AM, NeilBrown wrote: > > 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; > > > > snd_ctl_elem_value is a bit to big to be put onto the kernel stack. Just > using twl4030_read() should be fine. That's a shame, it looked so neat.... Using twl4030_read forces i2c access and misses out on the regmap caching. What do you think of this? Thanks, NeilBrown diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index b6b0cb399599..bdb47a045aa5 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -957,6 +957,18 @@ 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); + const struct soc_enum *e = &twl4030_op_modes_enum; + unsigned int reg_val; + int ret; + + ret = snd_soc_component_read(snd_kcontrol_chip(kcontrol), + e->reg, ®_val); + if (ret) + return ret; + if (ucontrol->value.enumerated.item[0] == + ((reg_val >> e->shift_l) & e->mask)) + /* no change requested, so do nothing */ + return 0; if (twl4030->configured) { dev_err(codec->dev,