Re: [PATCH v2 1/2] platform/chrome: cros_ec: jump to RW before probing
From: Dawid Niedźwiecki
Date: Fri Dec 06 2024 - 03:55:53 EST
On Fri, Dec 6, 2024 at 3:09 AM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> 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.