summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-03-23 14:38:56 -0600
committerCommit Bot <commit-bot@chromium.org>2021-03-23 23:21:51 +0000
commit2ff6477da30081edc3f396c60b0089ccc42a9f78 (patch)
treecb77bab54f16df7dd68ca5101b8f97c0e612d512 /include
parent854c16c9bdcb285b1258e1a88a29737f8f8d603a (diff)
downloadchrome-ec-2ff6477da30081edc3f396c60b0089ccc42a9f78.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>
Diffstat (limited to 'include')
-rw-r--r--include/task.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/task.h b/include/task.h
index cb6ddfa9ba..3b4549c955 100644
--- a/include/task.h
+++ b/include/task.h
@@ -367,6 +367,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