diff options
author | Caveh Jalali <caveh@chromium.org> | 2023-01-16 20:20:30 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-20 09:32:20 +0000 |
commit | ca2ec79d639bb0af5ce6ae56b48a9d109489613b (patch) | |
tree | 8567897a6f9e1276cf51e319853ae47a6b067d6c | |
parent | 12036800b8a92319e6124e9ce5b2dc4cf5bf5825 (diff) | |
download | chrome-ec-ca2ec79d639bb0af5ce6ae56b48a9d109489613b.tar.gz |
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 <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171496
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r-- | common/mkbp_event.c | 8 |
1 files 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; |