From e6bca969c00169664fe6885d234f1129ae3580aa Mon Sep 17 00:00:00 2001 From: Chen-Tsung Hsieh Date: Wed, 6 Oct 2021 11:40:03 +0800 Subject: driver: bma4xx: Correct implementation for get offset Before writing the offset to the BMA sensor, if it is less than 0, we will add 256 to it. So after reading the offset, we should subtract 256 from it instead of -256. BRANCH=none BUG=b:201238498, b:192409667 TEST=run 'ectool motionsense offset 2 19 0 0' on Tomato Change-Id: I26e2e714a529347c2cdb6b051c1423b379ad5c0d Signed-off-by: Chen-Tsung Hsieh Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205437 Reviewed-by: Ting Shen Reviewed-by: Gwendal Grignou Reviewed-by: Bhanu Prakash Maiya Commit-Queue: Li-jen Chen --- driver/accel_bma4xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/accel_bma4xx.c b/driver/accel_bma4xx.c index e9502c20b4..9b383edf80 100644 --- a/driver/accel_bma4xx.c +++ b/driver/accel_bma4xx.c @@ -339,7 +339,7 @@ static int get_offset(const struct motion_sensor_t *s, int16_t *offset, } if (val > 0x7f) - val -= -256; + val -= 256; v[i] = round_divide((int64_t)val * BMA4_OFFSET_ACC_MULTI_MG, BMA4_OFFSET_ACC_DIV_MG); -- cgit v1.2.1