diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2021-04-19 20:45:32 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-21 02:22:18 +0000 |
commit | 07a2b0e11684be396edf1f421b9e4dc2b8b30683 (patch) | |
tree | b4d2365a5812df30daeebe1e738eb5d8337c63b0 /driver/tcpm/tcpci.c | |
parent | 0f69cef4c4871d70f959eff2e54761acc0e0921b (diff) | |
download | chrome-ec-07a2b0e11684be396edf1f421b9e4dc2b8b30683.tar.gz |
TCPC: Cleanup: Get Sink & SRC state from PD or PPC
Added option to get the Sinking or Sourcing state from either
PD or PPC.
BUG=none
BRANCH=none
TEST=make buildall -j
Change-Id: Ibb21ef69b5825ea5722ceacd5d7ef6f535aad17c
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2838127
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/tcpm/tcpci.c')
-rw-r--r-- | driver/tcpm/tcpci.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 64707c67df..56af65cc75 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -575,17 +575,15 @@ int tcpci_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) } #ifdef CONFIG_USB_PD_PPC -int tcpci_tcpm_get_snk_ctrl(int port, bool *sinking) +bool tcpci_tcpm_get_snk_ctrl(int port) { int rv; int pwr_sts; rv = tcpci_tcpm_get_power_status(port, &pwr_sts); - *sinking = (rv != EC_SUCCESS) - ? 0 - : pwr_sts & TCPC_REG_POWER_STATUS_SINKING_VBUS; - return rv; + return rv == EC_SUCCESS && + pwr_sts & TCPC_REG_POWER_STATUS_SINKING_VBUS; } int tcpci_tcpm_set_snk_ctrl(int port, int enable) @@ -596,17 +594,15 @@ int tcpci_tcpm_set_snk_ctrl(int port, int enable) return tcpc_write(port, TCPC_REG_COMMAND, cmd); } -int tcpci_tcpm_get_src_ctrl(int port, bool *sourcing) +bool tcpci_tcpm_get_src_ctrl(int port) { int rv; int pwr_sts; rv = tcpci_tcpm_get_power_status(port, &pwr_sts); - *sourcing = (rv != EC_SUCCESS) - ? 0 - : pwr_sts & TCPC_REG_POWER_STATUS_SOURCING_VBUS; - return rv; + return rv == EC_SUCCESS && + pwr_sts & TCPC_REG_POWER_STATUS_SOURCING_VBUS; } int tcpci_tcpm_set_src_ctrl(int port, int enable) |