From 161ef2f24c16eb94f6dd7b790d895abfc0e02e27 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Thu, 17 Mar 2022 18:21:36 -0600 Subject: sn5s330: return when PP FET cannot be enabled Bug fixed identified while writing unit tests: the init function should return an error code when the sn5s330_pp_fet_enable() function fails. The fixed code is the intended behavior according to Aseda (aaboagye@google.com), who wrote the original driver. BRANCH=None BUG=b:225245353 TEST=zmake -D configure --test test-drivers Signed-off-by: Tristan Honscheid Change-Id: Ib85b67da98832cef6b0f820323eae270392bc4f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3535000 Reviewed-by: Denis Brockus Reviewed-by: Aseda Aboagye --- driver/ppc/sn5s330.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c index 0e5934533e..6a157b005e 100644 --- a/driver/ppc/sn5s330.c +++ b/driver/ppc/sn5s330.c @@ -160,8 +160,10 @@ static int sn5s330_pp_fet_enable(uint8_t port, enum sn5s330_pp_idx pp, pp_bit = SN5S330_PP1_EN; else if (pp == SN5S330_PP2) pp_bit = SN5S330_PP2_EN; + /* LCOV_EXCL_START - this branch unreachable in unit tests. */ else return EC_ERROR_INVAL; + /* LCOV_EXCL_STOP */ status = enable ? set_flags(port, SN5S330_FUNC_SET3, pp_bit) : clr_flags(port, SN5S330_FUNC_SET3, pp_bit); @@ -348,6 +350,7 @@ static int sn5s330_init(int port) status = sn5s330_pp_fet_enable(port, SN5S330_PP1, 0); if (status) { ppc_prints("Failed to turn off PP1 FET!", port); + return status; } /* -- cgit v1.2.1