Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()
@ 2026-09-02 10:06 Tzung-Bi Shih
  2026-09-04  7:56 ` Tzung-Bi Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Tzung-Bi Shih @ 2026-09-02 10:06 UTC (permalink / raw)
  To: Benson Leung; +Cc: chrome-platform, tzungbi

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()
  2026-09-02 10:06 [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete() Tzung-Bi Shih
@ 2026-09-04  7:56 ` Tzung-Bi Shih
  0 siblings, 0 replies; 2+ messages in thread
From: Tzung-Bi Shih @ 2026-09-04  7:56 UTC (permalink / raw)
  To: Benson Leung; +Cc: chrome-platform

On Wed, Sep 02, 2026 at 10:06:51AM +0000, Tzung-Bi Shih wrote:
> 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`.
>
> [...]

Applied to

    https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/1] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()
      commit: 7b6344a49cf5fed1879ee5c125d01a2535fbd725

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-04  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 10:06 [PATCH] platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete() Tzung-Bi Shih
2026-09-04  7:56 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox