summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorMartin Roth <martinroth@chromium.org>2016-08-11 14:11:04 -0600
committerchrome-bot <chrome-bot@chromium.org>2016-08-12 13:45:19 -0700
commit0b16cd761a374c37a64192d07f85ab610496844a (patch)
tree0214dd65a1fab3875f0f62dfc6f2b52eb10ae9bc /driver
parent079a0f0e680ca0a150696ed7a310700fe1f8646a (diff)
downloadchrome-ec-0b16cd761a374c37a64192d07f85ab610496844a.tar.gz
charger/bd99955.c: Simplify flow in console_command_bd99955
It looks to static analyzers as if the variable val could be used without being initialized. That isn't actually the case because of all the checks that are being done, but the flow can be simplified to only get the value to write when we're on the write path. BRANCH=None TEST=Build and boot Reef BUG=None Change-Id: I9f6ce3c9dcbab74f3c6de18dbd1f2e07bc1c4a13 Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/368302 Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/charger/bd99955.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c
index cac77ab322..e5cff28c8b 100644
--- a/driver/charger/bd99955.c
+++ b/driver/charger/bd99955.c
@@ -980,15 +980,13 @@ static int console_command_bd99955(int argc, char **argv)
if (*e || cmd < 0)
return EC_ERROR_PARAM3;
- if (argc == 5) {
+ if (rw == 'r')
+ rv = ch_raw_read16(reg, &data, cmd);
+ else {
val = strtoi(argv[4], &e, 16);
if (*e || val < 0)
return EC_ERROR_PARAM4;
- }
- if (rw == 'r')
- rv = ch_raw_read16(reg, &data, cmd);
- else {
rv = ch_raw_write16(reg, val, cmd);
if (rv == EC_SUCCESS)
rv = ch_raw_read16(reg, &data, cmd);