[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200130203106.201894-10-pmalani@chromium.org>
Date: Thu, 30 Jan 2020 12:30:52 -0800
From: Prashant Malani <pmalani@...omium.org>
To: linux-kernel@...r.kernel.org
Cc: Prashant Malani <pmalani@...omium.org>,
Jiri Kosina <jikos@...nel.org>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
linux-input@...r.kernel.org (open list:HID CORE LAYER)
Subject: [PATCH 09/17] hid: google-hammer: Use cros_ec_send_cmd_msg()
Replace cros_ec_cmd_xfer_status() with cros_ec_send_cmd_msg() which does
the message buffer setup and cleanup.
Signed-off-by: Prashant Malani <pmalani@...omium.org>
---
drivers/hid/hid-google-hammer.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 2aa4ed157aec87..428762a6a4993f 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -53,38 +53,25 @@ static bool cbas_parse_base_state(const void *data)
static int cbas_ec_query_base(struct cros_ec_device *ec_dev, bool get_state,
bool *state)
{
- struct ec_params_mkbp_info *params;
- struct cros_ec_command *msg;
+ struct ec_params_mkbp_info params = {0};
int ret;
- msg = kzalloc(sizeof(*msg) + max(sizeof(u32), sizeof(*params)),
- GFP_KERNEL);
- if (!msg)
- return -ENOMEM;
-
- msg->command = EC_CMD_MKBP_INFO;
- msg->version = 1;
- msg->outsize = sizeof(*params);
- msg->insize = sizeof(u32);
- params = (struct ec_params_mkbp_info *)msg->data;
- params->info_type = get_state ?
+ params.info_type = get_state ?
EC_MKBP_INFO_CURRENT : EC_MKBP_INFO_SUPPORTED;
- params->event_type = EC_MKBP_EVENT_SWITCH;
+ params.event_type = EC_MKBP_EVENT_SWITCH;
- ret = cros_ec_cmd_xfer_status(ec_dev, msg);
+ ret = cros_ec_send_cmd_msg(ec_dev, 1, EC_CMD_MKBP_INFO,
+ ¶ms, sizeof(params), state, sizeof(u32));
if (ret >= 0) {
if (ret != sizeof(u32)) {
dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n",
ret, sizeof(u32));
ret = -EPROTO;
} else {
- *state = cbas_parse_base_state(msg->data);
ret = 0;
}
}
- kfree(msg);
-
return ret;
}
--
2.25.0.341.g760bfbb309-goog
Powered by blists - more mailing lists