platform/chrome: cros_ec_proto: Simplify cros_ec_wait_until_complete()
Subsystems (2)
Tzung-Bi Shih
maintainerPATCH 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
@@ -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
Tzung-Bi Shih
maintainerQuoted 8 lines · Tzung-Bi Shih
There is no need to defer the return out of the loop. Replace the
breakwith an immediatereturn -EPROTO.With the
breakremoved, execution only reaches the end of the function if it exhausts allEC_COMMAND_RETRIES. The post-loop check is therefore redundant and replaced with an unconditionalreturn -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!