mbox series

[v2,0/4] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes

Message ID 20200720202243.180230-1-linux@roeck-us.net (mailing list archive)
Headers show
Series platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes | expand

Message

Guenter Roeck July 20, 2020, 8:22 p.m. UTC
The EC reports a variety of error codes. Most of those, with the exception
of EC_RES_INVALID_VERSION, are converted to -EPROTO. As result, the actual
error code gets lost. In cros_ec_cmd_xfer_status(), convert all EC errors
to Linux error codes to report a more meaningful error to the caller to aid
debugging.

To prepare for this change, handle error codes other than -EPROTO for all
callers of cros_ec_cmd_xfer_status(). Specifically, no longer assume that
-EPROTO reflects an error from the EC and all other error codes reflect a
transfer error.

v2: Add patches 1/4 to 3/4 to handle callers of cros_ec_cmd_xfer_status()

----------------------------------------------------------------
Guenter Roeck (4):
      iio: cros_ec: Accept -EOPNOTSUPP as 'not supported' error code
      cros_ec_lightbar: Accept more error codes from cros_ec_cmd_xfer_status
      platform/chrome: cros_ec_sysfs: Report range of error codes from EC
      platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes

 .../iio/common/cros_ec_sensors/cros_ec_sensors.c   |  2 +-
 drivers/platform/chrome/cros_ec_lightbar.c         | 10 +++---
 drivers/platform/chrome/cros_ec_proto.c            | 37 +++++++++++++++++-----
 drivers/platform/chrome/cros_ec_sysfs.c            | 24 ++++++--------
 4 files changed, 43 insertions(+), 30 deletions(-)

Comments

Brian Norris July 22, 2020, 10:03 p.m. UTC | #1
Hi Guenter,

On Mon, Jul 20, 2020 at 01:22:39PM -0700, Guenter Roeck wrote:
> The EC reports a variety of error codes. Most of those, with the exception
> of EC_RES_INVALID_VERSION, are converted to -EPROTO. As result, the actual
> error code gets lost. In cros_ec_cmd_xfer_status(), convert all EC errors
> to Linux error codes to report a more meaningful error to the caller to aid
> debugging.
> 
> To prepare for this change, handle error codes other than -EPROTO for all
> callers of cros_ec_cmd_xfer_status(). Specifically, no longer assume that
> -EPROTO reflects an error from the EC and all other error codes reflect a
> transfer error.
> 
> v2: Add patches 1/4 to 3/4 to handle callers of cros_ec_cmd_xfer_status()

I did a rough grep to see what you might be missing:

  git grep -n EPROTO | grep -e cros -e '-ec'

I think cros-ec-pwm / cros_ec_num_pwms() might need fixing too? Boy, I
wrote that, but it sure ain't easy to read...(*checks watch*)...4 years
later.

Apart from the notes already made, I think the series looks good:

Reviewed-by: Brian Norris <briannorris@chromium.org>

Feel free to CC me on v3, if you want another look

Brian
Guenter Roeck July 22, 2020, 10:31 p.m. UTC | #2
Hi Brian,

On 7/22/20 3:03 PM, Brian Norris wrote:
> Hi Guenter,
> 
> On Mon, Jul 20, 2020 at 01:22:39PM -0700, Guenter Roeck wrote:
>> The EC reports a variety of error codes. Most of those, with the exception
>> of EC_RES_INVALID_VERSION, are converted to -EPROTO. As result, the actual
>> error code gets lost. In cros_ec_cmd_xfer_status(), convert all EC errors
>> to Linux error codes to report a more meaningful error to the caller to aid
>> debugging.
>>
>> To prepare for this change, handle error codes other than -EPROTO for all
>> callers of cros_ec_cmd_xfer_status(). Specifically, no longer assume that
>> -EPROTO reflects an error from the EC and all other error codes reflect a
>> transfer error.
>>
>> v2: Add patches 1/4 to 3/4 to handle callers of cros_ec_cmd_xfer_status()
> 
> I did a rough grep to see what you might be missing:
> 
>   git grep -n EPROTO | grep -e cros -e '-ec'
> 
> I think cros-ec-pwm / cros_ec_num_pwms() might need fixing too? Boy, I

Yes, you are correct. And there was me thinking I got them all. Thanks a lot !

> wrote that, but it sure ain't easy to read...(*checks watch*)...4 years
> later.
> 
Usually I am quite embarrassed by code I wrote more than a couple of years
ago :-)

> Apart from the notes already made, I think the series looks good:
> 
> Reviewed-by: Brian Norris <briannorris@chromium.org>
> > Feel free to CC me on v3, if you want another look
> 
I'll be happy to do that. I did make a couple of changes, so I'll add
your Reviewed-by: only to unchanged patches.

Thanks,
Guenter