diff options
author | Yuval Peress <peress@chromium.org> | 2021-06-22 12:47:01 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-22 20:52:47 +0000 |
commit | a312deca2a2e9ce941d089d24136061af2569c8d (patch) | |
tree | d0245485704a40c41dc2ce3040bfe7c22cc818fd | |
parent | 5b57c4bc8bf48e03e7bb9c511970ea4136d306a7 (diff) | |
download | chrome-ec-a312deca2a2e9ce941d089d24136061af2569c8d.tar.gz |
zephyr: Migrate to v2.6 deferred work APIs
Update deferred work API calls to work with v2.6. Currently, these
will give warnings, but most of these have been replaced completely
in upstream Zephyr's main branch.
BRANCH=none
BUG=b:190731415
TEST=zmake configure -b zephyr/projects/trogodr/lazor
Change-Id: I99e71089439656a8a45ff35ce489e21ad60f2143
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2980433
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r-- | zephyr/shim/include/zephyr_hooks_shim.h | 18 | ||||
-rw-r--r-- | zephyr/shim/src/hooks.c | 14 |
2 files changed, 29 insertions, 3 deletions
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h index a3115a7b76..6edfdfe0a9 100644 --- a/zephyr/shim/include/zephyr_hooks_shim.h +++ b/zephyr/shim/include/zephyr_hooks_shim.h @@ -13,12 +13,17 @@ #include <zephyr.h> #include "common.h" +#include "cros_version.h" /** * The internal data structure stored for a deferred function. */ struct deferred_data { - struct k_delayed_work *delayed_work; +#if IS_ZEPHYR_VERSION(2, 6) + struct k_work_delayable *work; +#else + struct k_delayed_work *work; +#endif }; /** @@ -26,12 +31,21 @@ struct deferred_data { */ int hook_call_deferred(const struct deferred_data *data, int us); +#if IS_ZEPHYR_VERSION(2, 6) +#define DECLARE_DEFERRED(routine) \ + K_WORK_DELAYABLE_DEFINE(routine##_work_data, \ + (void (*)(struct k_work *))routine); \ + __maybe_unused const struct deferred_data routine##_data = { \ + .work = &routine##_work_data, \ + } +#else #define DECLARE_DEFERRED(routine) \ K_DELAYED_WORK_DEFINE(routine##_work_data, \ (void (*)(struct k_work *))routine); \ __maybe_unused const struct deferred_data routine##_data = { \ - .delayed_work = &routine##_work_data, \ + .work = &routine##_work_data, \ } +#endif /** * Internal linked-list structure used to store hook lists. diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index e11b28e88a..9d196d40ef 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -15,13 +15,25 @@ int hook_call_deferred(const struct deferred_data *data, int us) { - struct k_delayed_work *work = data->delayed_work; +#if IS_ZEPHYR_VERSION(2, 6) + struct k_work_delayable *work = data->work; +#else + struct k_delayed_work *work = data->work; +#endif int rv = 0; if (us == -1) { +#if IS_ZEPHYR_VERSION(2, 6) + k_work_cancel_delayable(work); +#else k_delayed_work_cancel(work); +#endif } else if (us >= 0) { +#if IS_ZEPHYR_VERSION(2, 6) + rv = k_work_schedule(work, K_USEC(us)); +#else rv = k_delayed_work_submit(work, K_USEC(us)); +#endif if (rv == -EINVAL) { /* Already processing or completed. */ return 0; |