From 6794147bb960d9b0668741e6bd7d82f7cadf7eba Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 28 Dec 2020 12:47:48 -0700 Subject: tpcmv2: Fix compile error for Zephyr builds Fix Type-C max source mutex for compatibility with Zephyr environment. BUG=none BRANCH=none TEST=make buildall TEST=build zephyr-chrome for volteer Signed-off-by: Keith Short Change-Id: Ibae899b8c937e0ed673ce9661584091440d40c1f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2605327 Reviewed-by: Simon Glass Commit-Queue: Simon Glass --- common/usbc/usb_pd_dpm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 6643fed42c..a64d31d841 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -358,7 +358,11 @@ void dpm_run(int port) * them */ static uint32_t max_current_claimed; -static struct mutex max_current_claimed_lock; +static mutex_t max_current_claimed_lock; + +#ifdef CONFIG_ZEPHYR +static bool dpm_mutex_initialized; +#endif static uint32_t sink_max_pdo_requested; /* Ports with PD sink needing > 1.5A */ @@ -383,6 +387,13 @@ static void balance_source_ports(void) { uint32_t removed_ports, new_ports; +#ifdef CONFIG_ZEPHYR + if (!dpm_mutex_initialized) { + (void)k_mutex_init(&max_current_claimed_lock); + dpm_mutex_initialized = true; + } +#endif + mutex_lock(&max_current_claimed_lock); /* Remove any ports which no longer require 3.0 A */ -- cgit v1.2.1