[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z1Jc4XC9z5lnYc4H@google.com>
Date: Fri, 6 Dec 2024 02:09:37 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Dawid Niedzwiecki <dawidn@...gle.com>
Cc: Benson Leung <bleung@...omium.org>, chrome-platform@...ts.linux.dev,
linux-kernel@...r.kernel.org, chromeos-krk-upstreaming@...gle.com
Subject: Re: [PATCH v2 1/2] platform/chrome: cros_ec: jump to RW before
probing
On Wed, Dec 04, 2024 at 10:45:13AM +0000, Dawid Niedzwiecki wrote:
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
[...]
> +int cros_ec_rwsig_continue(struct cros_ec_device *ec_dev)
> +{
[...]
> + for (int i = 0; i < RWSIG_CONTINUE_RETRIES; i++) {
> + ret = cros_ec_send_command(ec_dev, msg);
> +
> + if (ret < 0) {
> + error_count++;
> + } else if (msg->result == EC_RES_INVALID_COMMAND) {
> + /*
> + * If EC_RES_INVALID_COMMAND is retured, it means RWSIG
> + * is not supported or EC is already in RW, so there is
> + * nothing left to do.
> + */
> + break;
> + } else if (msg->result != EC_RES_SUCCESS) {
> + /* Unexpected command error. */
> + ret = cros_ec_map_error(msg->result);
> + break;
> + } else {
> + /*
> + * The EC_CMD_RWSIG_ACTION succeed. Send the command
> + * more times, to make sure EC is in RW. A following
> + * command can timeout, because EC may need some time to
> + * initialize after jump to RW.
> + */
> + error_count = 0;
> + }
> +
> + if (error_count >= RWSIG_CONTINUE_MAX_ERRORS_IN_ROW)
> + break;
Only if `ret < 0` makes the condition true. How about move the statement to
where `error_count` increases to make the intent more obvious? I.e.:
if (++error_count >= ...)
Powered by blists - more mailing lists