Lines Matching full:msg
57 struct cros_ec_command *msg) in prepare_tx() argument
64 if (msg->outsize + sizeof(*request) > ec_dev->dout_size) in prepare_tx()
71 request->command = msg->command; in prepare_tx()
72 request->command_version = msg->version; in prepare_tx()
74 request->data_len = msg->outsize; in prepare_tx()
80 memcpy(out + sizeof(*request), msg->data, msg->outsize); in prepare_tx()
81 for (i = 0; i < msg->outsize; i++) in prepare_tx()
82 csum += msg->data[i]; in prepare_tx()
86 return sizeof(*request) + msg->outsize; in prepare_tx()
90 struct cros_ec_command *msg) in prepare_tx_legacy() argument
96 if (msg->outsize > EC_PROTO2_MAX_PARAM_SIZE) in prepare_tx_legacy()
100 out[0] = EC_CMD_VERSION0 + msg->version; in prepare_tx_legacy()
101 out[1] = msg->command; in prepare_tx_legacy()
102 out[2] = msg->outsize; in prepare_tx_legacy()
104 for (i = 0; i < msg->outsize; i++) in prepare_tx_legacy()
105 csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->data[i]; in prepare_tx_legacy()
106 out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = csum; in prepare_tx_legacy()
108 return EC_MSG_TX_PROTO_BYTES + msg->outsize; in prepare_tx_legacy()
111 static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_xfer_command() argument
114 int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); in cros_ec_xfer_command()
131 trace_cros_ec_request_start(msg); in cros_ec_xfer_command()
132 ret = (*xfer_fxn)(ec_dev, msg); in cros_ec_xfer_command()
133 trace_cros_ec_request_done(msg, ret); in cros_ec_xfer_command()
141 struct cros_ec_command msg; in cros_ec_wait_until_complete() member
144 struct cros_ec_command *msg = &buf.msg; in cros_ec_wait_until_complete() local
148 msg->version = 0; in cros_ec_wait_until_complete()
149 msg->command = EC_CMD_GET_COMMS_STATUS; in cros_ec_wait_until_complete()
150 msg->insize = sizeof(*status); in cros_ec_wait_until_complete()
151 msg->outsize = 0; in cros_ec_wait_until_complete()
157 ret = cros_ec_xfer_command(ec_dev, msg); in cros_ec_wait_until_complete()
163 *result = msg->result; in cros_ec_wait_until_complete()
164 if (msg->result != EC_RES_SUCCESS) in cros_ec_wait_until_complete()
182 static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_send_command() argument
184 int ret = cros_ec_xfer_command(ec_dev, msg); in cros_ec_send_command()
186 if (msg->result == EC_RES_IN_PROGRESS) in cros_ec_send_command()
187 ret = cros_ec_wait_until_complete(ec_dev, &msg->result); in cros_ec_send_command()
195 * @msg: Message to write.
203 struct cros_ec_command *msg) in cros_ec_prepare_tx() argument
206 return prepare_tx(ec_dev, msg); in cros_ec_prepare_tx()
208 return prepare_tx_legacy(ec_dev, msg); in cros_ec_prepare_tx()
215 * @msg: Message to check.
226 struct cros_ec_command *msg) in cros_ec_check_result() argument
228 switch (msg->result) { in cros_ec_check_result()
233 msg->command); in cros_ec_check_result()
237 msg->command, msg->result); in cros_ec_check_result()
257 struct cros_ec_command *msg; in cros_ec_get_host_event_wake_mask() local
261 msg = kzalloc(sizeof(*msg) + sizeof(*r), GFP_KERNEL); in cros_ec_get_host_event_wake_mask()
262 if (!msg) in cros_ec_get_host_event_wake_mask()
265 msg->command = EC_CMD_HOST_EVENT_GET_WAKE_MASK; in cros_ec_get_host_event_wake_mask()
266 msg->insize = sizeof(*r); in cros_ec_get_host_event_wake_mask()
268 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_host_event_wake_mask()
272 mapped = cros_ec_map_error(msg->result); in cros_ec_get_host_event_wake_mask()
283 r = (struct ec_response_host_event_mask *)msg->data; in cros_ec_get_host_event_wake_mask()
287 kfree(msg); in cros_ec_get_host_event_wake_mask()
293 struct cros_ec_command *msg; in cros_ec_get_proto_info() local
301 msg = kzalloc(sizeof(*msg) + sizeof(*info), GFP_KERNEL); in cros_ec_get_proto_info()
302 if (!msg) in cros_ec_get_proto_info()
305 msg->command = EC_CMD_PASSTHRU_OFFSET(devidx) | EC_CMD_GET_PROTOCOL_INFO; in cros_ec_get_proto_info()
306 msg->insize = sizeof(*info); in cros_ec_get_proto_info()
308 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info()
317 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info()
326 mapped = cros_ec_map_error(msg->result); in cros_ec_get_proto_info()
337 info = (struct ec_response_get_protocol_info *)msg->data; in cros_ec_get_proto_info()
365 kfree(msg); in cros_ec_get_proto_info()
371 struct cros_ec_command *msg; in cros_ec_get_proto_info_legacy() local
378 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*response)), GFP_KERNEL); in cros_ec_get_proto_info_legacy()
379 if (!msg) in cros_ec_get_proto_info_legacy()
382 msg->command = EC_CMD_HELLO; in cros_ec_get_proto_info_legacy()
383 msg->insize = sizeof(*response); in cros_ec_get_proto_info_legacy()
384 msg->outsize = sizeof(*params); in cros_ec_get_proto_info_legacy()
386 params = (struct ec_params_hello *)msg->data; in cros_ec_get_proto_info_legacy()
389 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info_legacy()
395 mapped = cros_ec_map_error(msg->result); in cros_ec_get_proto_info_legacy()
398 dev_err(ec_dev->dev, "EC responded to v2 hello with error: %d\n", msg->result); in cros_ec_get_proto_info_legacy()
407 response = (struct ec_response_hello *)msg->data; in cros_ec_get_proto_info_legacy()
426 kfree(msg); in cros_ec_get_proto_info_legacy()
449 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
452 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
454 if (!msg) in cros_ec_get_host_command_version_mask()
457 msg->version = 0; in cros_ec_get_host_command_version_mask()
458 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
459 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
460 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
462 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
465 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
469 mapped = cros_ec_map_error(msg->result); in cros_ec_get_host_command_version_mask()
480 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
484 kfree(msg); in cros_ec_get_host_command_version_mask()
589 * @msg: Message to write.
601 * reported in msg->result. The result will be EC_RES_SUCCESS if the
606 int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_cmd_xfer() argument
621 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer()
623 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer()
626 if (msg->command < EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX)) { in cros_ec_cmd_xfer()
627 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer()
630 msg->outsize, in cros_ec_cmd_xfer()
636 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer()
639 msg->outsize, in cros_ec_cmd_xfer()
646 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_cmd_xfer()
656 * @msg: Message to write.
667 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
671 ret = cros_ec_cmd_xfer(ec_dev, msg); in cros_ec_cmd_xfer_status()
675 mapped = cros_ec_map_error(msg->result); in cros_ec_cmd_xfer_status()
678 msg->result, mapped); in cros_ec_cmd_xfer_status()
687 struct cros_ec_command *msg, in get_next_event_xfer() argument
693 msg->version = version; in get_next_event_xfer()
694 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
695 msg->insize = size; in get_next_event_xfer()
696 msg->outsize = 0; in get_next_event_xfer()
698 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in get_next_event_xfer()
710 struct cros_ec_command msg; in get_next_event() member
713 struct cros_ec_command *msg = &buf.msg; in get_next_event() local
718 memset(msg, 0, sizeof(*msg)); in get_next_event()
737 return get_next_event_xfer(ec_dev, msg, event, cmd_version, size); in get_next_event()
744 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
746 msg->version = 0; in get_keyboard_state_event()
747 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
748 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
749 msg->outsize = 0; in get_keyboard_state_event()
751 ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); in get_keyboard_state_event()
753 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()
951 struct cros_ec_command *msg; in cros_ec_get_sensor_count() local
955 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*resp)), in cros_ec_get_sensor_count()
957 if (!msg) in cros_ec_get_sensor_count()
960 msg->version = 1; in cros_ec_get_sensor_count()
961 msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset; in cros_ec_get_sensor_count()
962 msg->outsize = sizeof(*params); in cros_ec_get_sensor_count()
963 msg->insize = sizeof(*resp); in cros_ec_get_sensor_count()
965 params = (struct ec_params_motion_sense *)msg->data; in cros_ec_get_sensor_count()
968 ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); in cros_ec_get_sensor_count()
972 resp = (struct ec_response_motion_sense *)msg->data; in cros_ec_get_sensor_count()
975 kfree(msg); in cros_ec_get_sensor_count()
1022 struct cros_ec_command *msg; in cros_ec_cmd() local
1025 msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); in cros_ec_cmd()
1026 if (!msg) in cros_ec_cmd()
1029 msg->version = version; in cros_ec_cmd()
1030 msg->command = command; in cros_ec_cmd()
1031 msg->outsize = outsize; in cros_ec_cmd()
1032 msg->insize = insize; in cros_ec_cmd()
1035 memcpy(msg->data, outdata, outsize); in cros_ec_cmd()
1037 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in cros_ec_cmd()
1042 memcpy(indata, msg->data, insize); in cros_ec_cmd()
1044 kfree(msg); in cros_ec_cmd()