diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2021-03-23 14:38:56 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-15 00:14:54 +0000 |
commit | e5f09dc23a0d31dee317b744168d28cf3574a61d (patch) | |
tree | 3a77aad72f72fb46b488a22efb532c65f4202a92 | |
parent | 6de51563d642027774e73d4720af5ccc15285fbf (diff) | |
download | chrome-ec-e5f09dc23a0d31dee317b744168d28cf3574a61d.tar.gz |
zephyr: provide a definition of K_MUTEX_DEFINE for CrOS EC OS
Create a compatible K_MUTEX_DEFINE() for CrOS EC OS. This allows us
to use K_MUTEX_DEFINE() in shared code without needing special
Zephyr-only guards.
K_MUTEX_DEFINE() will allow us to stop much of our usage of
k_mutex_init(), which can often be forgotten, leaving mutexes
uninitialized.
BUG=b:177677037
BRANCH=none
TEST=follow up CLs do some conversion to K_MUTEX_DEFINE
they compile in both CrOS EC OS and Zephyr OS
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I11a9bcf1648447a7f1cb587bb0ebdf0c62381346
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2782231
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3700695
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Commit-Queue: Shelley Chen <shchen@chromium.org>
Tested-by: Shelley Chen <shchen@chromium.org>
-rw-r--r-- | include/task.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/task.h b/include/task.h index eb2105805a..d1efc6ffd1 100644 --- a/include/task.h +++ b/include/task.h @@ -329,6 +329,14 @@ struct mutex { typedef struct mutex mutex_t; /** + * K_MUTEX_DEFINE is a macro normally provided by the Zephyr kernel, + * and allows creation of a static mutex without the need to + * initialize it. We provide the same macro for CrOS EC OS so that we + * can use it in shared code. + */ +#define K_MUTEX_DEFINE(name) static mutex_t name = { } + +/** * Lock a mutex. * * This tries to lock the mutex mtx. If the mutex is already locked by another |