Lines Matching refs:msg
19 struct cros_ec_command *msg) in prepare_packet() argument
27 BUG_ON(msg->outsize + sizeof(*request) > ec_dev->dout_size); in prepare_packet()
33 request->command = msg->command; in prepare_packet()
34 request->command_version = msg->version; in prepare_packet()
36 request->data_len = msg->outsize; in prepare_packet()
42 memcpy(out + sizeof(*request), msg->data, msg->outsize); in prepare_packet()
43 for (i = 0; i < msg->outsize; i++) in prepare_packet()
44 csum += msg->data[i]; in prepare_packet()
48 return sizeof(*request) + msg->outsize; in prepare_packet()
52 struct cros_ec_command *msg) in send_command() argument
55 int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); in send_command()
57 trace_cros_ec_cmd(msg); in send_command()
75 ret = (*xfer_fxn)(ec_dev, msg); in send_command()
76 if (msg->result == EC_RES_IN_PROGRESS) { in send_command()
104 msg->result = status_msg->result; in send_command()
121 struct cros_ec_command *msg) in cros_ec_prepare_tx() argument
128 return prepare_packet(ec_dev, msg); in cros_ec_prepare_tx()
130 BUG_ON(msg->outsize > EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_prepare_tx()
132 out[0] = EC_CMD_VERSION0 + msg->version; in cros_ec_prepare_tx()
133 out[1] = msg->command; in cros_ec_prepare_tx()
134 out[2] = msg->outsize; in cros_ec_prepare_tx()
136 for (i = 0; i < msg->outsize; i++) in cros_ec_prepare_tx()
137 csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->data[i]; in cros_ec_prepare_tx()
138 out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = csum; in cros_ec_prepare_tx()
140 return EC_MSG_TX_PROTO_BYTES + msg->outsize; in cros_ec_prepare_tx()
145 struct cros_ec_command *msg) in cros_ec_check_result() argument
147 switch (msg->result) { in cros_ec_check_result()
152 msg->command); in cros_ec_check_result()
156 msg->command, msg->result); in cros_ec_check_result()
176 struct cros_ec_command *msg, in cros_ec_get_host_event_wake_mask() argument
182 msg->command = EC_CMD_HOST_EVENT_GET_WAKE_MASK; in cros_ec_get_host_event_wake_mask()
183 msg->version = 0; in cros_ec_get_host_event_wake_mask()
184 msg->outsize = 0; in cros_ec_get_host_event_wake_mask()
185 msg->insize = sizeof(*r); in cros_ec_get_host_event_wake_mask()
187 ret = send_command(ec_dev, msg); in cros_ec_get_host_event_wake_mask()
189 r = (struct ec_response_host_event_mask *)msg->data; in cros_ec_get_host_event_wake_mask()
198 struct cros_ec_command *msg) in cros_ec_host_command_proto_query() argument
211 memset(msg, 0, sizeof(*msg)); in cros_ec_host_command_proto_query()
212 msg->command = EC_CMD_PASSTHRU_OFFSET(devidx) | EC_CMD_GET_PROTOCOL_INFO; in cros_ec_host_command_proto_query()
213 msg->insize = sizeof(struct ec_response_get_protocol_info); in cros_ec_host_command_proto_query()
215 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query()
224 if (devidx > 0 && msg->result == EC_RES_INVALID_COMMAND) in cros_ec_host_command_proto_query()
226 else if (msg->result != EC_RES_SUCCESS) in cros_ec_host_command_proto_query()
227 return msg->result; in cros_ec_host_command_proto_query()
234 struct cros_ec_command *msg; in cros_ec_host_command_proto_query_v2() local
240 msg = kmalloc(sizeof(*msg) + len, GFP_KERNEL); in cros_ec_host_command_proto_query_v2()
241 if (!msg) in cros_ec_host_command_proto_query_v2()
244 msg->version = 0; in cros_ec_host_command_proto_query_v2()
245 msg->command = EC_CMD_HELLO; in cros_ec_host_command_proto_query_v2()
246 hello_params = (struct ec_params_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
247 msg->outsize = sizeof(*hello_params); in cros_ec_host_command_proto_query_v2()
248 hello_response = (struct ec_response_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
249 msg->insize = sizeof(*hello_response); in cros_ec_host_command_proto_query_v2()
253 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query_v2()
260 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_host_command_proto_query_v2()
263 msg->result); in cros_ec_host_command_proto_query_v2()
264 ret = msg->result; in cros_ec_host_command_proto_query_v2()
277 kfree(msg); in cros_ec_host_command_proto_query_v2()
302 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
305 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
307 if (!msg) in cros_ec_get_host_command_version_mask()
310 msg->version = 0; in cros_ec_get_host_command_version_mask()
311 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
312 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
313 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
315 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
318 ret = send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
320 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
324 kfree(msg); in cros_ec_get_host_command_version_mask()
457 struct cros_ec_command *msg) in cros_ec_cmd_xfer() argument
472 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer()
474 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer()
477 if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) { in cros_ec_cmd_xfer()
478 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer()
481 msg->outsize, in cros_ec_cmd_xfer()
487 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer()
490 msg->outsize, in cros_ec_cmd_xfer()
496 ret = send_command(ec_dev, msg); in cros_ec_cmd_xfer()
504 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
508 ret = cros_ec_cmd_xfer(ec_dev, msg); in cros_ec_cmd_xfer_status()
511 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_cmd_xfer_status()
512 dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result); in cros_ec_cmd_xfer_status()
521 struct cros_ec_command *msg, in get_next_event_xfer() argument
526 msg->version = version; in get_next_event_xfer()
527 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
528 msg->insize = size; in get_next_event_xfer()
529 msg->outsize = 0; in get_next_event_xfer()
531 ret = cros_ec_cmd_xfer(ec_dev, msg); in get_next_event_xfer()
534 memcpy(&ec_dev->event_data, msg->data, ret); in get_next_event_xfer()
543 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_next_event() local
553 ret = get_next_event_xfer(ec_dev, msg, cmd_version, in get_next_event()
555 if (ret < 0 || msg->result != EC_RES_INVALID_VERSION) in get_next_event()
562 ret = get_next_event_xfer(ec_dev, msg, cmd_version, in get_next_event()
572 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
574 msg->version = 0; in get_keyboard_state_event()
575 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
576 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
577 msg->outsize = 0; in get_keyboard_state_event()
579 ec_dev->event_size = cros_ec_cmd_xfer(ec_dev, msg); in get_keyboard_state_event()
581 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()