summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-05-05 14:38:33 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-05 05:49:24 +0000
commit7f221bc654a91fd475301317e24b51278cc62d17 (patch)
treebacad3d18e912b8cc85913017cb83bca3af5dace
parentda3db5b7a00bac2e7923719524a2fc280539bdde (diff)
downloadchrome-ec-7f221bc654a91fd475301317e24b51278cc62d17.tar.gz
zephyr/usba: unconstify usb_port_enable if needed
The changes in commit 7dc9537d7a56dab267e4facb3c1398e1d0e44175 added support in Zephyr for CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC with the same semantics as the equivalent option in the legacy EC, but failed to change the definition in the shim code to remove the const qualifier. This would cause code that believed it could write to the usb_port_enable array to instead trigger undefined behavior. BUG=b:231512828 TEST=Nereid no longer hangs at boot when CBI fw_config is set to 0 (unknown sub-board) BRANCH=none Change-Id: I747c9f1c1f02847cc367da38da1d4c7a12037516 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3627094 Reviewed-by: Andrew McRae <amcrae@google.com>
-rw-r--r--zephyr/shim/src/usba.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/zephyr/shim/src/usba.c b/zephyr/shim/src/usba.c
index bb88437f87..d3191a4f8d 100644
--- a/zephyr/shim/src/usba.c
+++ b/zephyr/shim/src/usba.c
@@ -17,7 +17,10 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 0,
#define USBA_ENABLE_PINS(inst) DT_INST_FOREACH_PROP_ELEM(inst, enable_pins, PIN)
-const int usb_port_enable[] = {
+#if !IS_ENABLED(CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC)
+const
+#endif
+int usb_port_enable[] = {
DT_INST_FOREACH_STATUS_OKAY(USBA_ENABLE_PINS)
};