summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/platform/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/platform/chrome')
-rw-r--r--kernel/drivers/platform/chrome/cros_ec_dev.c8
-rw-r--r--kernel/drivers/platform/chrome/cros_ec_proto.c17
2 files changed, 24 insertions, 1 deletions
diff --git a/kernel/drivers/platform/chrome/cros_ec_dev.c b/kernel/drivers/platform/chrome/cros_ec_dev.c
index d45cd254e..2b331d5b9 100644
--- a/kernel/drivers/platform/chrome/cros_ec_dev.c
+++ b/kernel/drivers/platform/chrome/cros_ec_dev.c
@@ -147,13 +147,19 @@ static long ec_device_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg)
goto exit;
}
+ if (u_cmd.outsize != s_cmd->outsize ||
+ u_cmd.insize != s_cmd->insize) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
s_cmd->command += ec->cmd_offset;
ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd);
/* Only copy data to userland if data was received. */
if (ret < 0)
goto exit;
- if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + u_cmd.insize))
+ if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + s_cmd->insize))
ret = -EFAULT;
exit:
kfree(s_cmd);
diff --git a/kernel/drivers/platform/chrome/cros_ec_proto.c b/kernel/drivers/platform/chrome/cros_ec_proto.c
index 990308ca3..92430f781 100644
--- a/kernel/drivers/platform/chrome/cros_ec_proto.c
+++ b/kernel/drivers/platform/chrome/cros_ec_proto.c
@@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
return ret;
}
EXPORT_SYMBOL(cros_ec_cmd_xfer);
+
+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
+ struct cros_ec_command *msg)
+{
+ int ret;
+
+ 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_SUCCESS) {
+ dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
+ return -EPROTO;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(cros_ec_cmd_xfer_status);