From patchwork Thu May 8 08:29:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 4133801 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A0A1C9F1E1 for ; Thu, 8 May 2014 08:30:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB2FF202DD for ; Thu, 8 May 2014 08:30:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 767AE201B4 for ; Thu, 8 May 2014 08:30:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7966726550C; Thu, 8 May 2014 10:30:15 +0200 (CEST) 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, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 982FD2654EC; Thu, 8 May 2014 10:30:06 +0200 (CEST) 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 D7F552654E0; Thu, 8 May 2014 10:30:04 +0200 (CEST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by alsa0.perex.cz (Postfix) with ESMTP id AB8032654E0 for ; Thu, 8 May 2014 10:29:56 +0200 (CEST) Received: by mail-vc0-f171.google.com with SMTP id lc6so2831285vcb.16 for ; Thu, 08 May 2014 01:29:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=I2er2+ai/i0BjHwJBFZRW1aNuTATw0O5PLYMwsYqR80=; b=hWFO6urVO+rlr4H/wo4Fmt+oPqXe+B0k4q934bNj6CTMz+CxOt1vjQ7oKq8whN+8C3 3zTJS9pfYe+QaD5uiv14B/jagLeLqWe9YIO0tUIVLsdER91q5RY3OpqZpW3Q8RmA7BTe k56ngEOOK92ht0CjTmFZjHeXQWZDWGIi+kDLGZBHAZTlCyMnaE3pTJSLTWP9eaVA+/13 DspLHF1kJzHWiWAg3CYXOk2F3dIK6GMIHV2trQPBvkPa+hTNWfGs9Y6FoSUpDnZXgd+T WQjrERRh2HRt+NZYc/9SYGOan45oj+1kar9MwRmI30A0j/yQEtd8iqOG6sDqW58VH/0C Q+9A== X-Gm-Message-State: ALoCoQmjd8JgBWv2yZmDoCfRXHwg0mk8HedVfcK6Vrnlkk8WXCiusA5A3siQyEnQrcWKdYLKBdOF X-Received: by 10.52.145.211 with SMTP id sw19mr43618vdb.75.1399537795465; Thu, 08 May 2014 01:29:55 -0700 (PDT) Received: from [192.168.0.102] (218-164-134-252.dynamic.hinet.net. [218.164.134.252]) by mx.google.com with ESMTPSA id iu10sm530697vdb.4.2014.05.08.01.29.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 01:29:54 -0700 (PDT) Message-ID: <1399537789.21710.1.camel@phoenix> From: Axel Lin To: Mark Brown Date: Thu, 08 May 2014 16:29:49 +0800 X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Cc: Rongjun Ying , Barry Song , Liam Girdwood , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits 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 Having the binary ones complement operator in the new bitmak value makes the code hard to read. Signed-off-by: Axel Lin --- I think the binary ones complement operator in such use case is error prone: For example: To set BIT(1) and clear both BIT(2) and BIT(3): The following code has wrong result: regmap_update_bits(regmap, the_register, BIT(1), BIT(2), BIT(3), BIT(1) | ~BIT(2) | ~BIT(3)); Axel sound/soc/codecs/sirf-audio-codec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index c5177bc..d90cb0f 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c @@ -109,7 +109,7 @@ static void enable_and_reset_codec(struct regmap *regmap, { regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, codec_enable_bits | codec_reset_bits, - codec_enable_bits | ~codec_reset_bits); + codec_enable_bits); msleep(20); regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, codec_reset_bits, codec_reset_bits); @@ -128,8 +128,7 @@ static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: regmap_update_bits(sirf_audio_codec->regmap, - AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS, - ~ATLAS6_CODEC_ENABLE_BITS); + AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS, 0); break; default: break; @@ -151,8 +150,7 @@ static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: regmap_update_bits(sirf_audio_codec->regmap, - AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS, - ~PRIMA2_CODEC_ENABLE_BITS); + AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS, 0); break; default: break;