Skip to contentSkip to conversation

platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()

PATCH In review Tzung-Bi Shih 1 participant 2 messages Sep 2 – Sep 4

Subsystems (2)
lore
Share & tools
lore

Tzung-Bi Shih

author maintainer
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()

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.

---
 drivers/platform/chrome/cros_ec_proto.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/platform/chrome/cros_ec_proto.c +3 -8
index 724d1313f6b2..2046ac29a473 100644
@@ -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)
Signature · 1 line
2.55.0.970.g62bdec98f9-goog
author maintainer
#1 lore raw
Quoted 8 lines · Tzung-Bi Shih

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!