Lines Matching refs:msg
27 struct cros_ec_command *msg) in prepare_packet() argument
35 BUG_ON(msg->outsize + sizeof(*request) > ec_dev->dout_size); in prepare_packet()
41 request->command = msg->command; in prepare_packet()
42 request->command_version = msg->version; in prepare_packet()
44 request->data_len = msg->outsize; in prepare_packet()
50 memcpy(out + sizeof(*request), msg->data, msg->outsize); in prepare_packet()
51 for (i = 0; i < msg->outsize; i++) in prepare_packet()
52 csum += msg->data[i]; in prepare_packet()
56 return sizeof(*request) + msg->outsize; in prepare_packet()
60 struct cros_ec_command *msg) in send_command() argument
63 int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); in send_command()
70 ret = (*xfer_fxn)(ec_dev, msg); in send_command()
71 if (msg->result == EC_RES_IN_PROGRESS) { in send_command()
99 msg->result = status_msg->result; in send_command()
116 struct cros_ec_command *msg) in cros_ec_prepare_tx() argument
123 return prepare_packet(ec_dev, msg); in cros_ec_prepare_tx()
125 BUG_ON(msg->outsize > EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_prepare_tx()
127 out[0] = EC_CMD_VERSION0 + msg->version; in cros_ec_prepare_tx()
128 out[1] = msg->command; in cros_ec_prepare_tx()
129 out[2] = msg->outsize; in cros_ec_prepare_tx()
131 for (i = 0; i < msg->outsize; i++) in cros_ec_prepare_tx()
132 csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->data[i]; in cros_ec_prepare_tx()
133 out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = csum; in cros_ec_prepare_tx()
135 return EC_MSG_TX_PROTO_BYTES + msg->outsize; in cros_ec_prepare_tx()
140 struct cros_ec_command *msg) in cros_ec_check_result() argument
142 switch (msg->result) { in cros_ec_check_result()
147 msg->command); in cros_ec_check_result()
151 msg->command, msg->result); in cros_ec_check_result()
171 struct cros_ec_command *msg, in cros_ec_get_host_event_wake_mask() argument
177 msg->command = EC_CMD_HOST_EVENT_GET_WAKE_MASK; in cros_ec_get_host_event_wake_mask()
178 msg->version = 0; in cros_ec_get_host_event_wake_mask()
179 msg->outsize = 0; in cros_ec_get_host_event_wake_mask()
180 msg->insize = sizeof(*r); in cros_ec_get_host_event_wake_mask()
182 ret = send_command(ec_dev, msg); in cros_ec_get_host_event_wake_mask()
184 r = (struct ec_response_host_event_mask *)msg->data; in cros_ec_get_host_event_wake_mask()
193 struct cros_ec_command *msg) in cros_ec_host_command_proto_query() argument
206 memset(msg, 0, sizeof(*msg)); in cros_ec_host_command_proto_query()
207 msg->command = EC_CMD_PASSTHRU_OFFSET(devidx) | EC_CMD_GET_PROTOCOL_INFO; in cros_ec_host_command_proto_query()
208 msg->insize = sizeof(struct ec_response_get_protocol_info); in cros_ec_host_command_proto_query()
210 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query()
219 if (devidx > 0 && msg->result == EC_RES_INVALID_COMMAND) in cros_ec_host_command_proto_query()
221 else if (msg->result != EC_RES_SUCCESS) in cros_ec_host_command_proto_query()
222 return msg->result; in cros_ec_host_command_proto_query()
229 struct cros_ec_command *msg; in cros_ec_host_command_proto_query_v2() local
235 msg = kmalloc(sizeof(*msg) + len, GFP_KERNEL); in cros_ec_host_command_proto_query_v2()
236 if (!msg) in cros_ec_host_command_proto_query_v2()
239 msg->version = 0; in cros_ec_host_command_proto_query_v2()
240 msg->command = EC_CMD_HELLO; in cros_ec_host_command_proto_query_v2()
241 hello_params = (struct ec_params_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
242 msg->outsize = sizeof(*hello_params); in cros_ec_host_command_proto_query_v2()
243 hello_response = (struct ec_response_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
244 msg->insize = sizeof(*hello_response); in cros_ec_host_command_proto_query_v2()
248 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query_v2()
255 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_host_command_proto_query_v2()
258 msg->result); in cros_ec_host_command_proto_query_v2()
259 ret = msg->result; in cros_ec_host_command_proto_query_v2()
272 kfree(msg); in cros_ec_host_command_proto_query_v2()
297 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
300 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
302 if (!msg) in cros_ec_get_host_command_version_mask()
305 msg->version = 0; in cros_ec_get_host_command_version_mask()
306 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
307 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
308 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
310 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
313 ret = send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
315 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
319 kfree(msg); in cros_ec_get_host_command_version_mask()
446 struct cros_ec_command *msg) in cros_ec_cmd_xfer() argument
461 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer()
463 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer()
466 if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) { in cros_ec_cmd_xfer()
467 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer()
470 msg->outsize, in cros_ec_cmd_xfer()
476 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer()
479 msg->outsize, in cros_ec_cmd_xfer()
485 ret = send_command(ec_dev, msg); in cros_ec_cmd_xfer()
493 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
497 ret = cros_ec_cmd_xfer(ec_dev, msg); in cros_ec_cmd_xfer_status()
500 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_cmd_xfer_status()
501 dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result); in cros_ec_cmd_xfer_status()
510 struct cros_ec_command *msg, in get_next_event_xfer() argument
515 msg->version = version; in get_next_event_xfer()
516 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
517 msg->insize = size; in get_next_event_xfer()
518 msg->outsize = 0; in get_next_event_xfer()
520 ret = cros_ec_cmd_xfer(ec_dev, msg); in get_next_event_xfer()
523 memcpy(&ec_dev->event_data, msg->data, ret); in get_next_event_xfer()
532 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_next_event() local
542 ret = get_next_event_xfer(ec_dev, msg, cmd_version, in get_next_event()
544 if (ret < 0 || msg->result != EC_RES_INVALID_VERSION) in get_next_event()
551 ret = get_next_event_xfer(ec_dev, msg, cmd_version, in get_next_event()
561 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
563 msg->version = 0; in get_keyboard_state_event()
564 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
565 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
566 msg->outsize = 0; in get_keyboard_state_event()
568 ec_dev->event_size = cros_ec_cmd_xfer(ec_dev, msg); in get_keyboard_state_event()
570 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()