[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ_BA_D0S1oFQiH2odVgfnd9dL76_t5Tzc_0n5B+fVis21+sAw@mail.gmail.com>
Date: Fri, 6 Dec 2024 09:55:31 +0100
From: Dawid Niedźwiecki <dawidn@...gle.com>
To: Tzung-Bi Shih <tzungbi@...nel.org>
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 Fri, Dec 6, 2024 at 3:09 AM Tzung-Bi Shih <tzungbi@...nel.org> wrote:
>
> 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 >= ...)
Good point. I'll change that.
Powered by blists - more mailing lists