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>
This commit is contained in:
Jett Rink
2018-04-04 08:31:17 -07:00
committed by chrome-bot
parent a796f04b1a
commit 33e91c211f

View File

@@ -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