[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200125012105.59903-3-pmalani@chromium.org>
Date: Fri, 24 Jan 2020 17:21:05 -0800
From: Prashant Malani <pmalani@...omium.org>
To: enric.balletbo@...labora.com, bleung@...omium.org
Cc: linux-kernel@...r.kernel.org,
Prashant Malani <pmalani@...omium.org>
Subject: [PATCH 2/4] platform/chrome: Make chardev use send_cmd_msg
Update the Chrome OS character device driver to use the newly introduced
cros_ec_send_cmd_msg() wrapper instead of cros_ec_cmd_xfer_status(),
thus avoiding message buffer set up work which is already done by the
wrapper.
Signed-off-by: Prashant Malani <pmalani@...omium.org>
---
drivers/platform/chrome/cros_ec_chardev.c | 33 ++++++++---------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index 74ded441bb500..0c43f59184acb 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -57,37 +57,26 @@ static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen)
static const char * const current_image_name[] = {
"unknown", "read-only", "read-write", "invalid",
};
- struct ec_response_get_version *resp;
- struct cros_ec_command *msg;
+ struct ec_response_get_version resp = {0};
int ret;
- msg = kzalloc(sizeof(*msg) + sizeof(*resp), GFP_KERNEL);
- if (!msg)
- 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);
- goto exit;
+ "Unknown EC version, returned error: %d\n", ret);
+ return ret;
}
- resp = (struct ec_response_get_version *)msg->data;
- if (resp->current_image >= ARRAY_SIZE(current_image_name))
- resp->current_image = 3; /* invalid */
+ if (resp.current_image >= ARRAY_SIZE(current_image_name))
+ resp.current_image = 3; /* invalid */
snprintf(str, maxlen, "%s\n%s\n%s\n%s\n", CROS_EC_DEV_VERSION,
- resp->version_string_ro, resp->version_string_rw,
- current_image_name[resp->current_image]);
+ resp.version_string_ro, resp.version_string_rw,
+ current_image_name[resp.current_image]);
- ret = 0;
-exit:
- kfree(msg);
- return ret;
+ return 0;
}
static int cros_ec_chardev_mkbp_event(struct notifier_block *nb,
--
2.25.0.341.g760bfbb309-goog
Powered by blists - more mailing lists