mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 22:24:09 +08:00
platform/chrome: cros_ec_proto: Report command not supported
In practice most drivers that use the EC protocol what really care is if the result was successful or not, hence, we introduced a cros_ec_cmd_xfer_status() function that converts EC errors to standard Linux error codes. On some few cases, though, we are interested on know if the command is supported or not, and in such cases, just ignore the error. To achieve this, return a -ENOTSUPP error when the command is not supported. This will allow us to finish the conversion of all users to use the cros_ec_cmd_xfer_status() function instead of cros_ec_cmd_xfer() and make the latest private to the protocol driver, so users of the protocol are not confused in which function they should use. Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Tested-by: Prashant Malani <pmalani@chromium.org>
This commit is contained in:
parent
7d3ca507fd
commit
c5cd2b47b2
@ -553,7 +553,10 @@ EXPORT_SYMBOL(cros_ec_cmd_xfer);
|
||||
* replied with success status. It's not necessary to check msg->result when
|
||||
* using this function.
|
||||
*
|
||||
* Return: The number of bytes transferred on success or negative error code.
|
||||
* Return:
|
||||
* >=0 - The number of bytes transferred
|
||||
* -ENOTSUPP - Operation not supported
|
||||
* -EPROTO - Protocol error
|
||||
*/
|
||||
int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
|
||||
struct cros_ec_command *msg)
|
||||
@ -563,6 +566,10 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
|
||||
ret = cros_ec_cmd_xfer(ec_dev, msg);
|
||||
if (ret < 0) {
|
||||
dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
|
||||
} else if (msg->result == EC_RES_INVALID_VERSION) {
|
||||
dev_dbg(ec_dev->dev, "Command invalid version (err:%d)\n",
|
||||
msg->result);
|
||||
return -ENOTSUPP;
|
||||
} else if (msg->result != EC_RES_SUCCESS) {
|
||||
dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
|
||||
return -EPROTO;
|
||||
|
Loading…
Reference in New Issue
Block a user