From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Guenter Roeck <groeck@google.com>
Cc: bleung@chromium.org, groeck@chromium.org,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 08/15] platform/chrome: cros_ec_proto: handle empty payload in getting proto info
Date: Wed, 8 Jun 2022 02:16:58 +0000 [thread overview]
Message-ID: <YqAGmpdTfZsa7Lux@google.com> (raw)
In-Reply-To: <CABXOdTdx7jKLbHa3X7aOz3wUMpwWWHkncfKuRyGzonkA92Rg=w@mail.gmail.com>
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@kernel.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)?
>
> > Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.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;
}
next prev parent reply other threads:[~2022-06-08 5:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 14:56 [PATCH v2 00/15] platform/chrome: Kunit tests and refactor for cros_ec_query_all() Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 01/15] platform/chrome: cros_ec_commands: fix compile errors Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 02/15] platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_query_all() Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 03/15] platform/chrome: use macros for passthru indexes Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 04/15] platform/chrome: cros_ec_proto: assign buffer size from protocol info Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 05/15] platform/chrome: cros_ec_proto: remove redundant NULL check Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 06/15] platform/chrome: cros_ec_proto: use cros_ec_map_error() Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 07/15] platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info() Tzung-Bi Shih
2022-06-07 18:45 ` Guenter Roeck
2022-06-07 14:56 ` [PATCH v2 08/15] platform/chrome: cros_ec_proto: handle empty payload in getting proto info Tzung-Bi Shih
2022-06-07 18:47 ` Guenter Roeck
2022-06-08 2:16 ` Tzung-Bi Shih [this message]
2022-06-08 14:37 ` Guenter Roeck
2022-06-07 14:56 ` [PATCH v2 09/15] platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info_legacy() Tzung-Bi Shih
2022-06-07 18:50 ` Guenter Roeck
2022-06-07 14:56 ` [PATCH v2 10/15] platform/chrome: cros_ec_proto: handle empty payload in getting info legacy Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 11/15] platform/chrome: cros_ec: don't allocate `din` and `dout` in cros_ec_register() Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 12/15] platform/chrome: use krealloc() for `din` and `dout` Tzung-Bi Shih
2022-06-07 19:06 ` Guenter Roeck
2022-06-08 2:17 ` Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 13/15] platform/chrome: cros_ec_proto: don't show MKBP version if unsupported Tzung-Bi Shih
2022-06-07 19:08 ` Guenter Roeck
2022-06-07 14:56 ` [PATCH v2 14/15] platform/chrome: cros_ec_proto: return 0 on getting version mask success Tzung-Bi Shih
2022-06-07 19:11 ` Guenter Roeck
2022-06-08 2:17 ` Tzung-Bi Shih
2022-06-07 14:56 ` [PATCH v2 15/15] platform/chrome: cros_ec_proto: return 0 on getting wake " Tzung-Bi Shih
2022-06-07 19:12 ` Guenter Roeck
2022-06-08 2:17 ` Tzung-Bi Shih
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=YqAGmpdTfZsa7Lux@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=groeck@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