diff options
author | Yuval Peress <peress@chromium.org> | 2020-10-29 12:11:43 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-15 00:14:53 +0000 |
commit | 6de51563d642027774e73d4720af5ccc15285fbf (patch) | |
tree | 2cf63a37b413bac3cdf17c8c5fef21f40d16c1a2 | |
parent | 6662280bbde7514434f72b9779f3907a3b4229d9 (diff) | |
download | chrome-ec-6de51563d642027774e73d4720af5ccc15285fbf.tar.gz |
Zephyr: add support for shimming the mutex struct
This changes creates a common mutex_t which can be used in both
platform/ec and zephyr code. It also adds an empty #define for
k_mutex_init(mutex) such that the zephyr function can be used
without affecting platform/ec.
BRANCH=none
BUG=b:171896666
TEST=Built platform/ec for boards: volteer & eve
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I6a711252732697ab120515d916bf388fdcd9544f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508414
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3700694
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 | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/include/task.h b/include/task.h index 897ba79f34..eb2105805a 100644 --- a/include/task.h +++ b/include/task.h @@ -315,11 +315,19 @@ int task_reset(task_id_t id, int wait); */ void task_clear_pending_irq(int irq); +#ifdef CONFIG_ZEPHYR +typedef struct k_mutex mutex_t; + +#define mutex_lock(mtx) (k_mutex_lock(mtx, K_FOREVER)) +#define mutex_unlock(mtx) (k_mutex_unlock(mtx)) +#else struct mutex { uint32_t lock; uint32_t waiters; }; +typedef struct mutex mutex_t; + /** * Lock a mutex. * @@ -328,12 +336,16 @@ struct mutex { * * Must not be used in interrupt context! */ -void mutex_lock(struct mutex *mtx); +void mutex_lock(mutex_t *mtx); /** * Release a mutex previously locked by the same task. */ -void mutex_unlock(struct mutex *mtx); +void mutex_unlock(mutex_t *mtx); + +/** Zephyr will try to init the mutex using `k_mutex_init()`. */ +#define k_mutex_init(mutex) 0 +#endif /* CONFIG_ZEPHYR */ struct irq_priority { uint8_t irq; |