summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-04-04 08:31:17 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-10 10:57:38 -0700
commit33e91c211f0d5331d5b0dda1297f3a7c42c46a26 (patch)
treed7e1de72d4a21e3e09dad1cc456fb5bfb4f2f114
parenta796f04b1acd6602266e210a4eb571b778c56721 (diff)
downloadchrome-ec-33e91c211f0d5331d5b0dda1297f3a7c42c46a26.tar.gz
tcpc: verify that i2c_read for vbus succeeds
If we cannot contact the TCPC, then we need to assume the safer value of VBus level (i.e. off) BRANCH=none BUG=b:77458917 TEST=yorp C1 still works Change-Id: I1fc1898a7dc554d050cd3612616531cb74de7261 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/995959 Reviewed-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--driver/tcpm/tcpci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 40bcc7765d..6eaf2cd8cd 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -206,9 +206,11 @@ int tcpci_tcpm_get_vbus_level(int port)
int reg;
/* Read Power Status register */
- tcpci_tcpm_get_power_status(port, &reg);
- /* Update VBUS status */
- return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
+ if (tcpci_tcpm_get_power_status(port, &reg) == EC_SUCCESS)
+ return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
+
+ /* If read failed, report that Vbus is off */
+ return 0;
}
#endif