From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Dawid Niedzwiecki <dawidn@google.com>
Cc: Benson Leung <bleung@chromium.org>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
chromeos-krk-upstreaming@google.com
Subject: Re: [PATCH v2 1/2] platform/chrome: cros_ec: jump to RW before probing
Date: Fri, 6 Dec 2024 02:09:37 +0000 [thread overview]
Message-ID: <Z1Jc4XC9z5lnYc4H@google.com> (raw)
In-Reply-To: <20241204104514.1541964-1-dawidn@google.com>
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 >= ...)
next prev parent reply other threads:[~2024-12-06 2:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 10:45 [PATCH v2 1/2] platform/chrome: cros_ec: jump to RW before probing Dawid Niedzwiecki
2024-12-04 10:45 ` [PATCH v2 2/2] platform/chrome: cros_ec_proto: remove unnecessary retries Dawid Niedzwiecki
2024-12-06 2:09 ` Tzung-Bi Shih [this message]
2024-12-06 8:55 ` [PATCH v2 1/2] platform/chrome: cros_ec: jump to RW before probing Dawid Niedźwiecki
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=Z1Jc4XC9z5lnYc4H@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=chromeos-krk-upstreaming@google.com \
--cc=dawidn@google.com \
--cc=linux-kernel@vger.kernel.org \
/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