[PATCH 02/17] platform/chrome: chardev: Use send_cmd_msg()

From: Prashant Malani
Date: Thu Jan 30 2020 - 15:32:40 EST


Update the Chrome OS character device driver to use the newly introduced
cros_ec_send_cmd_msg() function instead of cros_ec_cmd_xfer_status(),
thus avoiding message buffer set up work which is already done by the
new function.

Signed-off-by: Prashant Malani <pmalani@xxxxxxxxxxxx>
---
drivers/platform/chrome/cros_ec_chardev.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index 74ded441bb5006..f8136addb8b3f7 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -58,25 +58,21 @@ static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen)
"unknown", "read-only", "read-write", "invalid",
};
struct ec_response_get_version *resp;
- struct cros_ec_command *msg;
int ret;

- msg = kzalloc(sizeof(*msg) + sizeof(*resp), GFP_KERNEL);
- if (!msg)
+ resp = kzalloc(sizeof(*resp), GFP_KERNEL);
+ if (!resp)
return -ENOMEM;

- msg->command = EC_CMD_GET_VERSION + ec->cmd_offset;
- msg->insize = sizeof(*resp);
-
- ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ ret = cros_ec_send_cmd_msg(ec->ec_dev, 0,
+ ec->cmd_offset + EC_CMD_GET_VERSION, NULL, 0,
+ resp, sizeof(*resp));
if (ret < 0) {
snprintf(str, maxlen,
- "Unknown EC version, returned error: %d\n",
- msg->result);
+ "Unknown EC version, returned error: %d\n", ret);
goto exit;
}

- resp = (struct ec_response_get_version *)msg->data;
if (resp->current_image >= ARRAY_SIZE(current_image_name))
resp->current_image = 3; /* invalid */

@@ -86,7 +82,7 @@ static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen)

ret = 0;
exit:
- kfree(msg);
+ kfree(resp);
return ret;
}

--
2.25.0.341.g760bfbb309-goog