From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Benson Leung <bleung@chromium.org>
Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org
Subject: [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()
Date: Wed, 2 Sep 2026 10:06:51 +0000 [thread overview]
Message-ID: <20260902100651.274749-1-tzungbi@kernel.org> (raw)
There is no need to defer the return out of the loop. Replace the
`break` with an immediate `return -EPROTO`.
With the `break` removed, execution only reaches the end of the function
if it exhausts all EC_COMMAND_RETRIES. The post-loop check is therefore
redundant and replaced with an unconditional `return -EAGAIN`.
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
drivers/platform/chrome/cros_ec_proto.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index 724d1313f6b2..2046ac29a473 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -165,19 +165,14 @@ static int cros_ec_wait_until_complete(struct cros_ec_device *ec_dev, uint32_t *
if (msg->result != EC_RES_SUCCESS)
return ret;
- if (ret == 0) {
- ret = -EPROTO;
- break;
- }
+ if (ret == 0)
+ return -EPROTO;
if (!(status->flags & EC_COMMS_STATUS_PROCESSING))
return ret;
}
- if (i >= EC_COMMAND_RETRIES)
- ret = -EAGAIN;
-
- return ret;
+ return -EAGAIN;
}
static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg)
--
2.55.0.970.g62bdec98f9-goog
next reply other threads:[~2026-09-02 10:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 10:06 Tzung-Bi Shih [this message]
2026-09-04 7:56 ` [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete() Tzung-Bi Shih
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=20260902100651.274749-1-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
/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