public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Michał Barnaś" <barnas@google.com>
To: u-boot@lists.denx.de
Cc: "Michał Barnaś" <barnas@google.com>, "Tom Rini" <trini@konsulko.com>
Subject: [PATCH 1/3] misc: atsha204a: remove broken for loop
Date: Mon, 19 Feb 2024 16:32:02 +0000	[thread overview]
Message-ID: <20240219163213.855667-2-barnas@google.com> (raw)
In-Reply-To: <20240219163213.855667-1-barnas@google.com>

Some previous commit changed the continue statement to return,
making the for loop used to retry waking up the chip to always
return after one iteration. This commit removes the loop, cleaning
the code a little.

Signed-off-by: Michał Barnaś <barnas@google.com>
---

 drivers/misc/atsha204a-i2c.c | 45 +++++++++++++++---------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
index d3c515828f..ab83bbc3e9 100644
--- a/drivers/misc/atsha204a-i2c.c
+++ b/drivers/misc/atsha204a-i2c.c
@@ -96,40 +96,33 @@ int atsha204a_wakeup(struct udevice *dev)
 {
 	u8 req[4];
 	struct atsha204a_resp resp;
-	int try, res;
+	int res;
 
 	debug("Waking up ATSHA204A\n");
 
-	for (try = 1; try <= 10; ++try) {
-		debug("Try %i... ", try);
-
-		/*
-		 * The device ignores any levels or transitions on the SCL pin
-		 * when the device is idle, asleep or during waking up.
-		 * Don't check for error when waking up the device.
-		 */
-		memset(req, 0, 4);
-		atsha204a_send(dev, req, 4);
+	/*
+	 * The device ignores any levels or transitions on the SCL pin
+	 * when the device is idle, asleep or during waking up.
+	 * Don't check for error when waking up the device.
+	 */
+	memset(req, 0, 4);
+	atsha204a_send(dev, req, 4);
 
-		udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
+	udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
 
-		res = atsha204a_recv_resp(dev, &resp);
-		if (res) {
-			debug("failed on receiving response, ending\n");
-			return res;
-		}
-
-		if (resp.code != ATSHA204A_STATUS_AFTER_WAKE) {
-			debug ("failed (responce code = %02x), ending\n",
-			       resp.code);
-			return -EBADMSG;
-		}
+	res = atsha204a_recv_resp(dev, &resp);
+	if (res) {
+		debug("failed on receiving response, ending\n");
+		return res;
+	}
 
-		debug("success\n");
-		return 0;
+	if (resp.code != ATSHA204A_STATUS_AFTER_WAKE) {
+		debug("failed (response code = %02x), ending\n", resp.code);
+		return -EBADMSG;
 	}
 
-	return -ETIMEDOUT;
+	debug("success\n");
+	return 0;
 }
 
 int atsha204a_idle(struct udevice *dev)
-- 
2.44.0.rc0.258.g7320e95886-goog


  reply	other threads:[~2024-02-19 16:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 16:32 [PATCH 0/3] Fix driver for misc/atsha204a Michał Barnaś
2024-02-19 16:32 ` Michał Barnaś [this message]
2024-02-19 16:32 ` [PATCH 2/3] misc: atsha204a: fix sleep function Michał Barnaś
2024-02-19 16:32 ` [PATCH 3/3] misc: atsha204a: fix wakeup function Michał Barnaś
2024-03-05 13:17 ` [PATCH 0/3] Fix driver for misc/atsha204a Tom Rini
2024-03-08 17:13   ` Michał Barnaś

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=20240219163213.855667-2-barnas@google.com \
    --to=barnas@google.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox