From ca2ec79d639bb0af5ce6ae56b48a9d109489613b Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Mon, 16 Jan 2023 20:20:30 -0800 Subject: common/mkbp_event: Fix EC_CMD_GET_NEXT_EVENT response The EC_CMD_GET_NEXT_EVENT host command returns a 'struct ec_response_get_next_event' and should be implemented as such. So, replace 'uint8_t *' casting/dereferencing with struct member accesses. Callers (unit tests, kernel) already use 'struct ec_response_get_next_event' for this host command, so it makes sense to "fix" the implementation. No functional change in the data format is introduced. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes 'make buildall' passes Change-Id: I4cd1a30d1503cac9c7fd3add09b0b317a343cbcb Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171496 Reviewed-by: Tristan Honscheid Reviewed-by: Boris Mittelberg --- common/mkbp_event.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/mkbp_event.c b/common/mkbp_event.c index eb57a11656..2a00cae17b 100644 --- a/common/mkbp_event.c +++ b/common/mkbp_event.c @@ -397,7 +397,7 @@ static enum ec_status mkbp_get_next_event(struct host_cmd_handler_args *args) { static int last; int i, evt; - uint8_t *resp = args->response; + struct ec_response_get_next_event *r = args->response; const struct mkbp_event_source *src; int data_size = -EC_ERROR_BUSY; @@ -427,7 +427,7 @@ static enum ec_status mkbp_get_next_event(struct host_cmd_handler_args *args) if (src == NULL) return EC_RES_ERROR; - resp[0] = evt; /* Event type */ + r->event_type = evt; /* * get_data() can return -EC_ERROR_BUSY which indicates that the @@ -437,7 +437,7 @@ static enum ec_status mkbp_get_next_event(struct host_cmd_handler_args *args) * event instead. Therefore, we have to service that button * event first. */ - data_size = src->get_data(resp + 1); + data_size = src->get_data((uint8_t *)&r->data); if (data_size == -EC_ERROR_BUSY) { mutex_lock(&state.lock); state.events |= BIT(evt); @@ -447,7 +447,7 @@ static enum ec_status mkbp_get_next_event(struct host_cmd_handler_args *args) /* If there are no more events and we support the "more" flag, set it */ if (!set_inactive_if_no_events() && args->version >= 2) - resp[0] |= EC_MKBP_HAS_MORE_EVENTS; + r->event_type |= EC_MKBP_HAS_MORE_EVENTS; if (data_size < 0) return EC_RES_ERROR; -- cgit v1.2.1