summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-21 16:17:06 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-23 22:18:30 +0000
commit1668a5e22c7e70e6de86d66548580b22035dd248 (patch)
treead419768dc5ae95d59e21036d7b69a527ef56915
parent5cdc4a3eb17923b6cb02a2b375af36c8dad0d9e9 (diff)
downloadchrome-ec-1668a5e22c7e70e6de86d66548580b22035dd248.tar.gz
zephyr: usb: Init mutexes in pd_set_vbus_discharge()
Zephyr needs these to be inited before use. Add the code for this. It is harmless for ECOS but increases code size, so put it behind an #ifdef BUG=b:175434113 BRANCH=none TEST=build zephyr for volteer Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I874c02e143b9d6987ab52036652897f384540def Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600226 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--common/usb_common.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index 5ff8777ff2..36e94dd540 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -738,8 +738,15 @@ static void gpio_discharge_vbus(int port, int enable)
void pd_set_vbus_discharge(int port, int enable)
{
- static struct mutex discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT];
+ static mutex_t discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT];
+#ifdef CONFIG_ZEPHYR
+ static bool inited[CONFIG_USB_PD_PORT_MAX_COUNT];
+ if (!inited[port]) {
+ (void)k_mutex_init(&discharge_lock[port]);
+ inited[port] = true;
+ }
+#endif
if (port >= board_get_usb_pd_port_count())
return;