From 33e91c211f0d5331d5b0dda1297f3a7c42c46a26 Mon Sep 17 00:00:00 2001 From: Jett Rink Date: Wed, 4 Apr 2018 08:31:17 -0700 Subject: [PATCH] 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 Reviewed-on: https://chromium-review.googlesource.com/995959 Reviewed-by: Divya S Sasidharan Reviewed-by: Furquan Shaikh Reviewed-by: Vincent Palatin --- driver/tcpm/tcpci.c | 8 +++++--- 1 file 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, ®); - /* Update VBUS status */ - return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0; + if (tcpci_tcpm_get_power_status(port, ®) == EC_SUCCESS) + return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0; + + /* If read failed, report that Vbus is off */ + return 0; } #endif