diff options
author | Robert Zieba <robertzieba@google.com> | 2022-04-26 11:22:06 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-05 17:19:43 +0000 |
commit | ab0976af3371547511fa37c9e769faa509eddd1c (patch) | |
tree | a79b45a5fc0a73e68ae77673a70da8ab384a4667 /include/battery_smart.h | |
parent | 8f7ec2f4d15b811d37dddad4f25334a41fc5f113 (diff) | |
download | chrome-ec-ab0976af3371547511fa37c9e769faa509eddd1c.tar.gz |
smart battery: Fix mfgacc access function reading wrong number of bytes
`sb_read_mfgacc` currently uses `sb_read_string`. This function reads a
null-terminated string. However, the data that is being read is not a
null-terminated string. This is causing N-1 bytes to be read instead of
N bytes. This commit adds an `sb_read_sized_block` function that is used
instead. Only PARAM_SAFETY_STATUS and PARAM_OPERATION_STATUS are read
with `sb_read_mfgacc` and neither of these values are a string.
BUG=b:228589840
TEST=Ran i2ctrace to verify that right number of bytes are now being
read, tested with CL:3578293 to ensure no errors
BRANCH=guybrush
Change-Id: Iaedb4d28274bda8b6d1ee6d2021ebd04f83767f8
Signed-off-by: Robert Zieba <robertzieba@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3606146
Reviewed-by: Rob Barnes <robbarnes@google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/battery_smart.h')
-rw-r--r-- | include/battery_smart.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/battery_smart.h b/include/battery_smart.h index b97d681223..9b373f7c8a 100644 --- a/include/battery_smart.h +++ b/include/battery_smart.h @@ -169,9 +169,22 @@ /* Read from battery */ int sb_read(int cmd, int *param); -/* Read sequence from battery */ +/** + * Read null-terminated string from battery + * @param offset Battery register to read from + * @param data Buffer to hold the string + * @param len Length of data buffer + */ int sb_read_string(int offset, uint8_t *data, int len); +/** + * Read sized block of data from battery + * @param offset Battery register to read from + * @param data Buffer to hold read data + * @param len Length of data buffer + */ +int sb_read_sized_block(int offset, uint8_t *data, int len); + /* Write to battery */ int sb_write(int cmd, int param); |