All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: tiwai@suse.de, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, "# 4 . 4+" <stable@vger.kernel.org>,
	Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Subject: [PATCH 1/4] ASoC: codecs: da7213: fix invalid usage of bitwise operation in loop condition
Date: Tue,  2 May 2017 22:33:00 +0900	[thread overview]
Message-ID: <20170502133303.19622-2-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20170502133303.19622-1-o-takashi@sakamocchi.jp>

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: <stable@vger.kernel.org> # 4.4+
Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 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;
-- 
2.9.3

  reply	other threads:[~2017-05-02 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 13:32 [PATCH 0/4] ALSA/ASoC: fix after merging ASoC PR for v4.12-rc1 Takashi Sakamoto
2017-05-02 13:33 ` Takashi Sakamoto [this message]
2017-05-02 14:02   ` [PATCH 1/4] ASoC: codecs: da7213: fix invalid usage of bitwise operation in loop condition Adam Thomson
2017-05-02 13:33 ` [PATCH 2/4] ASoC: codecs: msm8916: fix invalid cast to bool type Takashi Sakamoto
2017-05-14  9:59   ` Mark Brown
2017-05-15  8:14     ` Takashi Iwai
2017-05-15  8:17       ` Mark Brown
2017-05-15  8:17         ` Mark Brown
2017-05-15  8:43         ` Takashi Iwai
2017-05-15  8:02   ` Applied "ASoC: codecs: msm8916: fix invalid cast to bool type" to the asoc tree Mark Brown
2017-05-02 13:33 ` [PATCH 3/4] ASoC: hisilicon: localize functions without external linkage Takashi Sakamoto
2017-05-15  8:02   ` Applied "ASoC: hisilicon: localize functions without external linkage" to the asoc tree Mark Brown
2017-05-02 13:33 ` [PATCH 4/4] ASoC: intel: atom: localize variable without external linkage Takashi Sakamoto
2017-05-15  8:02   ` Applied "ASoC: intel: atom: localize variable without external linkage" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170502133303.19622-2-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=Adam.Thomson.Opensource@diasemi.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.