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 if (devidx > 0 && msg->result == EC_RES_INVALID_COMMAND) in cros_ec_host_command_proto_query()
292 else if (msg->result != EC_RES_SUCCESS) in cros_ec_host_command_proto_query()
293 return msg->result; in cros_ec_host_command_proto_query()
300 struct cros_ec_command *msg; in cros_ec_host_command_proto_query_v2() local
306 msg = kmalloc(sizeof(*msg) + len, GFP_KERNEL); in cros_ec_host_command_proto_query_v2()
307 if (!msg) in cros_ec_host_command_proto_query_v2()
310 msg->version = 0; in cros_ec_host_command_proto_query_v2()
311 msg->command = EC_CMD_HELLO; in cros_ec_host_command_proto_query_v2()
312 hello_params = (struct ec_params_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
313 msg->outsize = sizeof(*hello_params); in cros_ec_host_command_proto_query_v2()
314 hello_response = (struct ec_response_hello *)msg->data; in cros_ec_host_command_proto_query_v2()
315 msg->insize = sizeof(*hello_response); in cros_ec_host_command_proto_query_v2()
319 ret = send_command(ec_dev, msg); in cros_ec_host_command_proto_query_v2()
326 } else if (msg->result != EC_RES_SUCCESS) { in cros_ec_host_command_proto_query_v2()
329 msg->result); in cros_ec_host_command_proto_query_v2()
330 ret = msg->result; in cros_ec_host_command_proto_query_v2()
343 kfree(msg); in cros_ec_host_command_proto_query_v2()
368 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
371 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
373 if (!msg) in cros_ec_get_host_command_version_mask()
376 msg->version = 0; in cros_ec_get_host_command_version_mask()
377 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
378 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
379 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
381 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
384 ret = send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
386 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
390 kfree(msg); in cros_ec_get_host_command_version_mask()
565 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
580 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer_status()
582 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer_status()
585 if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) { in cros_ec_cmd_xfer_status()
586 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer_status()
589 msg->outsize, in cros_ec_cmd_xfer_status()
595 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer_status()
598 msg->outsize, in cros_ec_cmd_xfer_status()
605 ret = send_command(ec_dev, msg); in cros_ec_cmd_xfer_status()
608 mapped = cros_ec_map_error(msg->result); in cros_ec_cmd_xfer_status()
611 msg->result, mapped); in cros_ec_cmd_xfer_status()
620 struct cros_ec_command *msg, in get_next_event_xfer() argument
626 msg->version = version; in get_next_event_xfer()
627 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
628 msg->insize = size; in get_next_event_xfer()
629 msg->outsize = 0; in get_next_event_xfer()
631 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in get_next_event_xfer()
643 struct cros_ec_command msg; in get_next_event() member
646 struct cros_ec_command *msg = &buf.msg; in get_next_event() local
650 memset(msg, 0, sizeof(*msg)); in get_next_event()
657 return get_next_event_xfer(ec_dev, msg, event, 0, in get_next_event()
660 return get_next_event_xfer(ec_dev, msg, event, cmd_version, in get_next_event()
668 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
670 msg->version = 0; in get_keyboard_state_event()
671 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
672 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
673 msg->outsize = 0; in get_keyboard_state_event()
675 ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); in get_keyboard_state_event()
677 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()
800 struct cros_ec_command *msg; in cros_ec_check_features() local
805 msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); in cros_ec_check_features()
806 if (!msg) in cros_ec_check_features()
809 msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; in cros_ec_check_features()
810 msg->insize = sizeof(ec->features); in cros_ec_check_features()
812 ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); in cros_ec_check_features()
815 ret, msg->result); in cros_ec_check_features()
818 memcpy(ec->features, msg->data, sizeof(ec->features)); in cros_ec_check_features()
824 kfree(msg); in cros_ec_check_features()
847 struct cros_ec_command *msg; in cros_ec_get_sensor_count() local
851 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*resp)), in cros_ec_get_sensor_count()
853 if (!msg) in cros_ec_get_sensor_count()
856 msg->version = 1; in cros_ec_get_sensor_count()
857 msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset; in cros_ec_get_sensor_count()
858 msg->outsize = sizeof(*params); in cros_ec_get_sensor_count()
859 msg->insize = sizeof(*resp); in cros_ec_get_sensor_count()
861 params = (struct ec_params_motion_sense *)msg->data; in cros_ec_get_sensor_count()
864 ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); in cros_ec_get_sensor_count()
868 resp = (struct ec_response_motion_sense *)msg->data; in cros_ec_get_sensor_count()
871 kfree(msg); in cros_ec_get_sensor_count()