[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABXOdTexvEoaRvOdoTeoHoGpHqHPPHvJAL8sYSBS4fn7eLkCgA@mail.gmail.com>
Date: Wed, 8 Jun 2022 07:37:10 -0700
From: Guenter Roeck <groeck@...gle.com>
To: Tzung-Bi Shih <tzungbi@...nel.org>
Cc: Benson Leung <bleung@...omium.org>,
Guenter Roeck <groeck@...omium.org>,
"open list:CHROME HARDWARE PLATFORM SUPPORT"
<chrome-platform@...ts.linux.dev>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 08/15] platform/chrome: cros_ec_proto: handle empty
payload in getting proto info
On Tue, Jun 7, 2022 at 7:17 PM Tzung-Bi Shih <tzungbi@...nel.org> wrote:
>
> On Tue, Jun 07, 2022 at 11:47:56AM -0700, Guenter Roeck wrote:
> > On Tue, Jun 7, 2022 at 7:57 AM Tzung-Bi Shih <tzungbi@...nel.org> wrote:
> > >
> > > cros_ec_get_proto_info() expects to receive
> > > sizeof(struct ec_response_get_protocol_info) from send_command(). The
> > > payload is valid only if the return value is positive.
> > >
> > > Add Kunit tests for returning 0 in send_command() and handle the case in
> > > cros_ec_get_proto_info().
> > >
> > That should be two separate patches.
>
> Ack, will separate them in next version. I put them together because I wrote
> Kunit test first to make sure the second half takes effect (somehow TDD).
>
> Could I still put the Kunit patch first (even if it introduces Kunit test
> failure)?
>
Sorry, I am running behind with e-mails.
If you want to, but why not let the fix come first ? If the unit test
patch is first, mayle add a note after --- indicating that it is
expected to fail and will be fixed with the next patch.
Thanks,
Guenter
> >
> > > Signed-off-by: Tzung-Bi Shih <tzungbi@...nel.org>
> > > ---
> > > No v1. New in the series.
> > >
> > > drivers/platform/chrome/cros_ec_proto.c | 5 +
> > > drivers/platform/chrome/cros_ec_proto_test.c | 132 +++++++++++++++++++
> > > 2 files changed, 137 insertions(+)
> > >
> > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> > > index 893b76703da6..6f5be9e5ede4 100644
> > > --- a/drivers/platform/chrome/cros_ec_proto.c
> > > +++ b/drivers/platform/chrome/cros_ec_proto.c
> > > @@ -314,6 +314,11 @@ static int cros_ec_get_proto_info(struct cros_ec_device *ec_dev, int devidx)
> > > goto exit;
> > > }
> > >
> > > + if (ret == 0) {
> > > + ret = -EPROTO;
> > > + goto exit;
> > > + }
> > > +
> >
> > I think you can move that into the if() statement above (which already
> > checks for ret >=0),
> > making it a special case of that situation.
>
> Nope, there is no "ret >= 0" (you could be confusing with
> cros_ec_get_host_event_wake_mask()).
>
> The result flow roughly like:
>
> ret = send_command(...);
> if (ret < 0)
> goto exit;
>
> mapped = cros_ec_map_error(...);
> if (mapped) {
> ...
> goto exit;
> }
>
> if (ret == 0) {
> ...
> goto exit;
> }
Powered by blists - more mailing lists