Re: [RESEND PATCH 05/11] platform/chrome: cros_ec_proto: separate cros_ec_wait_until_complete()

From: Tzung-Bi Shih
Date: Sun Jul 17 2022 - 23:50:36 EST


On Thu, Jul 14, 2022 at 07:29:45AM -0700, Guenter Roeck wrote:
> On Wed, Jul 13, 2022 at 8:33 PM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
> > On Wed, Jul 13, 2022 at 11:15:47AM -0700, Guenter Roeck wrote:
> > > On Mon, Jun 27, 2022 at 7:49 PM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
> > > > + ret = cros_ec_xfer_command(ec_dev, msg);
> > > > + if (ret == -EAGAIN)
> > > > + continue;
> > > > + if (ret < 0)
> > > > + break;
> > >
> > > With the command allocated on the stack, this can return immediately.
> >
> > Nack, the function has no goto labels. `return ret` follows the loop
> > immediately. The `break` here doesn't make it to become too complicated.
> > I would prefer to keep it.
>
> Sorry, you lost me here. The code after the loop does
>
> kfree(msg);
> return ret;
>
> If kfree() is no longer necessary, only the return statement is left. So break;
> is identical to return ret;. Am I missing something ?

You are correct.

I meant personally I would prefer to use `break`:
* The loop is short so that it won't become too complicated.
* Keep the function has a single exit point.

But, anyway, let's use `return ret` to make it explicit.