diff options
author | Tristan Honscheid <honscheid@google.com> | 2022-03-17 18:21:36 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-18 19:01:45 +0000 |
commit | 161ef2f24c16eb94f6dd7b790d895abfc0e02e27 (patch) | |
tree | 1e6e7dab75857d780673a2df0b435dbf73982c74 | |
parent | 3e5f6ae7b9c783493736bda9d11ddc01f4c5bfac (diff) | |
download | chrome-ec-161ef2f24c16eb94f6dd7b790d895abfc0e02e27.tar.gz |
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 <honscheid@google.com>
Change-Id: Ib85b67da98832cef6b0f820323eae270392bc4f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3535000
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | driver/ppc/sn5s330.c | 3 |
1 files changed, 3 insertions, 0 deletions
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; } /* |