platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes
authorGuenter Roeck <linux@roeck-us.net>
Sat, 22 Aug 2020 15:08:56 +0000 (08:08 -0700)
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>
Mon, 24 Aug 2020 09:37:34 +0000 (11:37 +0200)
commit0d080459e813ce8076f183cc73a4c9b64a39a4d8
tree628f6a316b6ee66e5ac0b0bc486b060669d52d0f
parentb4e452b5e97dc70d529475168a37ad7394994b8b
platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes

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
EC error code gets lost. Introduce cros_ec_map_error() to map EC error
codes to Linux error codes, and use it in cros_ec_cmd_xfer_status() to
report more meaningful errors to the caller. With this change, callers of
cros_ec_cmd_xfer_status() can implement a more distinguished action without
having to rely on the EC error code. At the same time, debugging is improved
in situations where the Linux error code is reported to userspace and/or in
the kernel log.

Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Cc: Prashant Malani <pmalani@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
drivers/platform/chrome/cros_ec_proto.c