From b677e67afb50e67fa30cb7673a7bb5947c54ce57 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 2 Sep 2019 15:04:36 +0200 Subject: driver/wpc/p9221: Avoiding using uninitialized variable For this, restrict the variables' scope and move the print statements closer to the other variable use. Found by Coverity Scan #198955, #198960 BUG=none BRANCH=none TEST=none Change-Id: I947249e4fd36524de5065616d5bcd32203d8b7e4 Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1781469 Tested-by: Patrick Georgi Commit-Queue: Patrick Georgi Reviewed-by: Daisuke Nojiri --- driver/wpc/p9221.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/driver/wpc/p9221.c b/driver/wpc/p9221.c index 0225039c4d..7ba4271823 100644 --- a/driver/wpc/p9221.c +++ b/driver/wpc/p9221.c @@ -586,14 +586,14 @@ done: static int p9221_get_charge_supplier(void) { - uint32_t tx_id; - int txmf_id; - if (!wpc->online) return EC_ERROR_UNKNOWN; if (p9221_is_epp()) { + uint32_t tx_id; + int txmf_id; int ret; + wpc->charge_supplier = CHARGE_SUPPLIER_WPC_EPP; ret = p9221_read16(P9221R7_EPP_TX_MFG_CODE_REG, &txmf_id); @@ -608,12 +608,14 @@ static int p9221_get_charge_supplier(void) if (tx_id & P9221R7_PROP_TX_ID_GPP_MASK) wpc->charge_supplier = CHARGE_SUPPLIER_WPC_GPP; + + CPRINTS("txmf_id=0x%04x tx_id=0x%08x supplier=%d", + txmf_id, tx_id, wpc->charge_supplier); } else { wpc->charge_supplier = CHARGE_SUPPLIER_WPC_BPP; + CPRINTS("supplier=%d", wpc->charge_supplier); } - CPRINTS("txmf_id=0x%04x tx_id=0x%08x supplier=%d", - txmf_id, tx_id, wpc->charge_supplier); return EC_SUCCESS; } -- cgit v1.2.1