Lines Matching refs:msg

56 			  struct cros_ec_command *msg)  in prepare_packet()  argument
64 BUG_ON(msg->outsize + sizeof(*request) > ec_dev->dout_size); in prepare_packet()
70 request->command = msg->command; in prepare_packet()
71 request->command_version = msg->version; in prepare_packet()
73 request->data_len = msg->outsize; in prepare_packet()
79 memcpy(out + sizeof(*request), msg->data, msg->outsize); in prepare_packet()
80 for (i = 0; i < msg->outsize; i++) in prepare_packet()
81 csum += msg->data[i]; in prepare_packet()
85 return sizeof(*request) + msg->outsize; in prepare_packet()
89 struct cros_ec_command *msg) in send_command() argument
92 int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); in send_command()
110 trace_cros_ec_request_start(msg); in send_command()
111 ret = (*xfer_fxn)(ec_dev, msg); in send_command()
112 trace_cros_ec_request_done(msg, ret); in send_command()
113 if (msg->result == EC_RES_IN_PROGRESS) { in send_command()
143 msg->result = status_msg->result; in send_command()
171 struct cros_ec_command *msg) in cros_ec_prepare_tx() argument
178 return prepare_packet(ec_dev, msg); in cros_ec_prepare_tx()
180 BUG_ON(msg->outsize > EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_prepare_tx()
182 out[0] = EC_CMD_VERSION0 + msg->version; in cros_ec_prepare_tx()
183 out[1] = msg->command; in cros_ec_prepare_tx()
184 out[2] = msg->outsize; in cros_ec_prepare_tx()
186 for (i = 0; i < msg->outsize; i++) in cros_ec_prepare_tx()
187 csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->data[i]; in cros_ec_prepare_tx()
188 out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = csum; in cros_ec_prepare_tx()
190 return EC_MSG_TX_PROTO_BYTES + msg->outsize; in cros_ec_prepare_tx()
205 struct cros_ec_command *msg) in cros_ec_check_result() argument
207 switch (msg->result) { in cros_ec_check_result()
212 msg->command); in cros_ec_check_result()
216 msg->command, msg->result); in cros_ec_check_result()
236 struct cros_ec_command *msg, in cros_ec_get_host_event_wake_mask() argument
242 msg->command = EC_CMD_HOST_EVENT_GET_WAKE_MASK; in cros_ec_get_host_event_wake_mask()
243 msg->version = 0; in cros_ec_get_host_event_wake_mask()
244 msg->outsize = 0; in cros_ec_get_host_event_wake_mask()
245 msg->insize = sizeof(*r); in cros_ec_get_host_event_wake_mask()
247 ret = send_command(ec_dev, msg); in cros_ec_get_host_event_wake_mask()
249 if (msg->result == EC_RES_INVALID_COMMAND) in cros_ec_get_host_event_wake_mask()
251 if (msg->result != EC_RES_SUCCESS) in cros_ec_get_host_event_wake_mask()
255 r = (struct ec_response_host_event_mask *)msg->data; in cros_ec_get_host_event_wake_mask()
264 struct cros_ec_command *msg) in cros_ec_host_command_proto_query() argument
277 memset(msg, 0, sizeof(*msg)); in cros_ec_host_command_proto_query()
278 msg->command = EC_CMD_PASSTHRU_OFFSET(devidx) | EC_CMD_GET_PROTOCOL_INFO; in cros_ec_host_command_proto_query()
279 msg->insize = sizeof(struct ec_response_get_protocol_info); in cros_ec_host_command_proto_query()
281 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query()
290 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query()
299 if (devidx > 0 && msg->result == EC_RES_INVALID_COMMAND) in cros_ec_host_command_proto_query()
301 else if (msg->result != EC_RES_SUCCESS) in cros_ec_host_command_proto_query()
302 return msg->result; in cros_ec_host_command_proto_query()
309 struct cros_ec_command *msg; in cros_ec_host_command_proto_query_v2() local
315 msg = kmalloc(sizeof(*msg) + len, GFP_KERNEL); in cros_ec_host_command_proto_query_v2()
316 if (!msg) in cros_ec_host_command_proto_query_v2()
319 msg->version = 0; in cros_ec_host_command_proto_query_v2()
320 msg->command = EC_CMD_HELLO; in cros_ec_host_command_proto_query_v2()
321 hello_params = (struct ec_params_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
322 msg->outsize = sizeof(*hello_params); in cros_ec_host_command_proto_query_v2()
323 hello_response = (struct ec_response_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
324 msg->insize = sizeof(*hello_response); in cros_ec_host_command_proto_query_v2()
328 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query_v2()
335 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_host_command_proto_query_v2()
338 msg->result); in cros_ec_host_command_proto_query_v2()
339 ret = msg->result; in cros_ec_host_command_proto_query_v2()
352 kfree(msg); in cros_ec_host_command_proto_query_v2()
377 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
380 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
382 if (!msg) in cros_ec_get_host_command_version_mask()
385 msg->version = 0; in cros_ec_get_host_command_version_mask()
386 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
387 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
388 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
390 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
393 ret = send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
395 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
399 kfree(msg); in cros_ec_get_host_command_version_mask()
576 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
591 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer_status()
593 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer_status()
596 if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) { in cros_ec_cmd_xfer_status()
597 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer_status()
600 msg->outsize, in cros_ec_cmd_xfer_status()
606 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer_status()
609 msg->outsize, in cros_ec_cmd_xfer_status()
616 ret = send_command(ec_dev, msg); in cros_ec_cmd_xfer_status()
619 mapped = cros_ec_map_error(msg->result); in cros_ec_cmd_xfer_status()
622 msg->result, mapped); in cros_ec_cmd_xfer_status()
631 struct cros_ec_command *msg, in get_next_event_xfer() argument
637 msg->version = version; in get_next_event_xfer()
638 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
639 msg->insize = size; in get_next_event_xfer()
640 msg->outsize = 0; in get_next_event_xfer()
642 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in get_next_event_xfer()
654 struct cros_ec_command msg; in get_next_event() member
657 struct cros_ec_command *msg = &buf.msg; in get_next_event() local
661 memset(msg, 0, sizeof(*msg)); in get_next_event()
668 return get_next_event_xfer(ec_dev, msg, event, 0, in get_next_event()
671 return get_next_event_xfer(ec_dev, msg, event, cmd_version, in get_next_event()
679 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
681 msg->version = 0; in get_keyboard_state_event()
682 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
683 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
684 msg->outsize = 0; in get_keyboard_state_event()
686 ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); in get_keyboard_state_event()
688 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()
851 struct cros_ec_command *msg; in cros_ec_get_sensor_count() local
855 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*resp)), in cros_ec_get_sensor_count()
857 if (!msg) in cros_ec_get_sensor_count()
860 msg->version = 1; in cros_ec_get_sensor_count()
861 msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset; in cros_ec_get_sensor_count()
862 msg->outsize = sizeof(*params); in cros_ec_get_sensor_count()
863 msg->insize = sizeof(*resp); in cros_ec_get_sensor_count()
865 params = (struct ec_params_motion_sense *)msg->data; in cros_ec_get_sensor_count()
868 ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); in cros_ec_get_sensor_count()
872 resp = (struct ec_response_motion_sense *)msg->data; in cros_ec_get_sensor_count()
875 kfree(msg); in cros_ec_get_sensor_count()
922 struct cros_ec_command *msg; in cros_ec_command() local
925 msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); in cros_ec_command()
926 if (!msg) in cros_ec_command()
929 msg->version = version; in cros_ec_command()
930 msg->command = command; in cros_ec_command()
931 msg->outsize = outsize; in cros_ec_command()
932 msg->insize = insize; in cros_ec_command()
935 memcpy(msg->data, outdata, outsize); in cros_ec_command()
937 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in cros_ec_command()
942 memcpy(indata, msg->data, insize); in cros_ec_command()
944 kfree(msg); in cros_ec_command()