diff options
author | Mark Hasemeyer <markhas@google.com> | 2022-10-17 16:40:17 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-18 21:25:44 +0000 |
commit | 55f07db74c6f3242958e436189d1bfd92717d868 (patch) | |
tree | b31c90d6750d24f17c52afd88c3c64b90d241651 | |
parent | 4d493c2f5de36ff41afb72a15391f74bdc5ef38d (diff) | |
download | chrome-ec-55f07db74c6f3242958e436189d1bfd92717d868.tar.gz |
hooks: Update rc handling for deferred calls
The old Zephyr workqueue api was deprecated in 2.6, and recenty removed:
https://github.com/zephyrproject-rtos/zephyr/pull/46812
The hooks module is using the new api, but the return code handling
needs updating.
k_work_schedule() replaces k_delayed_work_submit_to_queue(), and its
return values are different.
In the old api, `-EINVAL` is returned when a "Work item is being
processed or has completed its work.":
https://docs.zephyrproject.org/2.5.0/reference/kernel/threads/index.html#c.k_delayed_work_submit_to_queue
In the new api, a value >= 0 is returned when work has been (or is)
properly scheduled:
https://docs.zephyrproject.org/3.2.0/kernel/services/threads/workqueue.html#c.k_work_schedule_for_queue
Update the return code handling in hook_call_deferred() to correctly
process the return values produced by the new workqueue api.
BUG=b:251872865
BRANCH=none
TEST=`chargen 36 50000` with chromium:3943262 cherry-picked
Change-Id: I4511e9bd5a9f50caa3473e78619ab042026970ca
Signed-off-by: Mark Hasemeyer <markhas@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3964352
Commit-Queue: Keith Short <keithshort@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/shim/src/hooks.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index da981dea6b..3f11a578c5 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -165,17 +165,14 @@ int hook_call_deferred(const struct deferred_data *data, int us) k_work_cancel_delayable(work); } else if (us >= 0) { rv = k_work_reschedule(work, K_USEC(us)); - if (rv == -EINVAL) { - /* Already processing or completed. */ - return 0; - } else if (rv < 0) { + if (rv < 0) { work_queue_error(data, rv); } } else { return EC_ERROR_PARAM2; } - return rv; + return rv >= 0 ? EC_SUCCESS : rv; } /* |