From patchwork Tue May 2 13:33:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 9708037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07F306021C for ; Tue, 2 May 2017 13:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0AA2841C for ; Tue, 2 May 2017 13:33:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E044F28449; Tue, 2 May 2017 13:33:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A4E22841C for ; Tue, 2 May 2017 13:33:19 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EACF7266BA6; Tue, 2 May 2017 15:33:16 +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 38EDF266D5E; Tue, 2 May 2017 15:33:15 +0200 (CEST) Received: from smtp-proxy004.phy.lolipop.jp (smtp-proxy004.phy.lolipop.jp [157.7.104.45]) by alsa0.perex.cz (Postfix) with ESMTP id 4A76A266BA6 for ; Tue, 2 May 2017 15:33:08 +0200 (CEST) Received: from smtp-proxy004.phy.lolipop.lan (HELO smtp-proxy004.phy.lolipop.jp) (172.19.44.45) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp-proxy004.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Tue, 02 May 2017 22:33:05 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp-proxy004.phy.lolipop.jp (LOLIPOP-Fsecure); Tue, 02 May 2017 22:33:03 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: tiwai@suse.de, broonie@kernel.org Date: Tue, 2 May 2017 22:33:00 +0900 Message-Id: <20170502133303.19622-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170502133303.19622-1-o-takashi@sakamocchi.jp> References: <20170502133303.19622-1-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, Adam Thomson , "# 4 . 4+" Subject: [alsa-devel] [PATCH 1/4] ASoC: codecs: da7213: fix invalid usage of bitwise operation in loop condition 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-Virus-Scanned: ClamAV using ClamSMTP AND bitwise operation is used for retry counter and lock status, however in this case, it's invalid as condition statement. This commit fixes this bug with simpler representation. This bug is detected by sparse with below warning: sound/soc/codecs/da7213.c:775:57: warning: dubious: x & !y Fixes: d575b0b0f01a ("ASoC: da7213: Add checking of SRM lock status before enabling DAI") Cc: # 4.4+ Cc: Adam Thomson Signed-off-by: Takashi Sakamoto --- sound/soc/codecs/da7213.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 6dd7578..11d257c 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -737,7 +737,6 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); u8 pll_ctrl, pll_status; int i = 0; - bool srm_lock = false; switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -766,15 +765,12 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, /* Check SRM has locked */ do { pll_status = snd_soc_read(codec, DA7213_PLL_STATUS); - if (pll_status & DA7219_PLL_SRM_LOCK) { - srm_lock = true; - } else { - ++i; - msleep(50); - } - } while ((i < DA7213_SRM_CHECK_RETRIES) & (!srm_lock)); + if (pll_status & DA7219_PLL_SRM_LOCK) + break; + msleep(50); + } while (++i < DA7213_SRM_CHECK_RETRIES); - if (!srm_lock) + if (i >= DA7213_SRM_CHECK_RETRIES) dev_warn(codec->dev, "SRM failed to lock\n"); return 0;