All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	james.schulman@cirrus.com, lgirdwood@gmail.com,
	david.rhodes@cirrus.com
Subject: [PATCH 2/6] ASoC: cs35l41: Use regmap_read_poll_timeout to wait for OTP boot
Date: Tue, 14 Sep 2021 15:13:45 +0100	[thread overview]
Message-ID: <20210914141349.30218-2-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20210914141349.30218-1-ckeepax@opensource.cirrus.com>

Just clean up the code a little by using the helper rather than open
coding waiting for OTP_BOOT_DONE.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l41.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index d2a11cc336833..8c2c695813cd7 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1323,7 +1323,6 @@ int cs35l41_probe(struct cs35l41_private *cs35l41,
 {
 	u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match;
 	int irq_pol = 0;
-	int timeout;
 	int ret;
 
 	if (pdata) {
@@ -1377,18 +1376,14 @@ int cs35l41_probe(struct cs35l41_private *cs35l41,
 
 	usleep_range(2000, 2100);
 
-	timeout = 100;
-	do {
-		if (timeout == 0) {
-			dev_err(cs35l41->dev,
-				"Timeout waiting for OTP_BOOT_DONE\n");
-			ret = -EBUSY;
-			goto err;
-		}
-		usleep_range(1000, 1100);
-		regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS4, &int_status);
-		timeout--;
-	} while (!(int_status & CS35L41_OTP_BOOT_DONE));
+	ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4,
+				       int_status, int_status & CS35L41_OTP_BOOT_DONE,
+				       1000, 100000);
+	if (ret) {
+		dev_err(cs35l41->dev,
+			"Failed waiting for OTP_BOOT_DONE: %d\n", ret);
+		goto err;
+	}
 
 	regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status);
 	if (int_status & CS35L41_OTP_BOOT_ERR) {
-- 
2.11.0


  reply	other threads:[~2021-09-14 14:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 14:13 [PATCH 1/6] ASoC: cs35l41: Fix use of an uninitialised variable Charles Keepax
2021-09-14 14:13 ` Charles Keepax [this message]
2021-09-14 14:13 ` [PATCH 3/6] ASoC: cs35l41: Combine adjacent register writes Charles Keepax
2021-09-14 14:13 ` [PATCH 4/6] ASoC: cs35l41: Don't overwrite returned error code Charles Keepax
2021-09-14 14:13 ` [PATCH 5/6] ASoC: cs35l41: Fixup the error messages Charles Keepax
2021-09-14 14:13 ` [PATCH 6/6] ASoC: cs35l41: Fix a bunch of trivial code formating/style issues Charles Keepax
2021-09-14 14:23   ` Mark Brown
2021-09-15 10:53     ` Charles Keepax
2021-09-15 11:38       ` Mark Brown
2021-09-15 15:21 ` [PATCH 1/6] ASoC: cs35l41: Fix use of an uninitialised variable 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=20210914141349.30218-2-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=james.schulman@cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=patches@opensource.cirrus.com \
    /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.