summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2019-07-19 16:42:36 +0800
committerCommit Bot <commit-bot@chromium.org>2019-07-24 07:41:17 +0000
commit29f91d7dd10ec2ffd08e60abd0618ddb3c99d57d (patch)
treecfe87ffd9b5d9a798188c74db23b54f729b0d8fc
parent26d7adb2fd72635cde56199b025c200a125dcb78 (diff)
downloadchrome-ec-29f91d7dd10ec2ffd08e60abd0618ddb3c99d57d.tar.gz
driver/tcpm: block bad config combinations at compile time
The unimplemented fields in tcpm_drv may cause ec jumping into some undefined address. Prevent this happen by checking flags at compile time. BUG=None TEST=make buildall -j BRANCH=master Change-Id: I68f47cdc34046e7551f00f72267850b4f0464200 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1710211 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--driver/tcpm/anx7688.c6
-rw-r--r--driver/tcpm/fusb302.c6
-rw-r--r--driver/tcpm/it83xx.c1
3 files changed, 13 insertions, 0 deletions
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index b450245a76..fe1d2498d4 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -11,6 +11,12 @@
#include "timer.h"
#include "usb_mux.h"
+#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
+ defined(CONFIG_USB_PD_TCPC_LOW_POWER) || \
+ defined(CONFIG_USB_PD_DISCHARGE_TCPC)
+#error "Unsupported config options of anx7688 PD driver"
+#endif
+
#define ANX7688_VENDOR_ALERT BIT(15)
#define ANX7688_REG_STATUS 0x82
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c
index 24f7fb6388..f8196a586f 100644
--- a/driver/tcpm/fusb302.c
+++ b/driver/tcpm/fusb302.c
@@ -18,6 +18,12 @@
#include "usb_pd_tcpc.h"
#include "util.h"
+#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
+ defined(CONFIG_USB_PD_TCPC_LOW_POWER) || \
+ defined(CONFIG_USB_PD_DISCHARGE_TCPC)
+#error "Unsupported config options of fusb302 PD driver"
+#endif
+
#define PACKET_IS_GOOD_CRC(head) (PD_HEADER_TYPE(head) == PD_CTRL_GOOD_CRC && \
PD_HEADER_CNT(head) == 0)
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index ac0383f719..b0ea91f89e 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -20,6 +20,7 @@
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) || \
+ defined(CONFIG_USB_PD_TCPC_LOW_POWER) || \
defined(CONFIG_USB_PD_DISCHARGE_TCPC)
#error "Unsupported config options of IT83xx PD driver"
#endif