Re: [PATCH 13/13] platform/chrome: cros_ec_proto: fix get_host_event_wake_mask() returns
From: Tzung-Bi Shih
Date: Mon Jun 06 2022 - 20:56:06 EST
On Mon, Jun 06, 2022 at 09:14:26AM -0700, Guenter Roeck wrote:
> On Mon, Jun 6, 2022 at 7:12 AM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
> > @@ -256,19 +256,16 @@ static int get_host_event_wake_mask(struct cros_ec_device *ec_dev, uint32_t *mas
> > msg->insize = sizeof(*r);
> >
> > ret = send_command(ec_dev, msg);
> > - if (ret >= 0) {
> > + if (ret > 0) {
>
> The idea here was to (potentially) return an error if ret == 0. This
> is no longer the case after this change. Instead, the caller has to
> check for ret == 0 and treat it as an error. I think it would make
> more sense to explicitly check for ret ==0, eg with something like
>
> mapped = cros_ec_map_error(msg->result);
> if (mapped) {
> ret = mapped;
> goto exit;
> }
> if (ret == 0) {
> ret = -EPROTO;
> goto exit;
> }
> ....
Ack, will fix in next version.