@@ -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;
}
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@chromium.org> --- drivers/hid/hid-google-hammer.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)