summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen-Tsung Hsieh <chentsung@chromium.org>2021-10-06 11:40:03 +0800
committerCommit Bot <commit-bot@chromium.org>2021-10-07 02:17:13 +0000
commite6bca969c00169664fe6885d234f1129ae3580aa (patch)
tree0bff06a425c6a4c8c7ee831b55921e8ff2d46f87
parentde506307ca883fd60bda63dfe53752be6ee50036 (diff)
downloadchrome-ec-e6bca969c00169664fe6885d234f1129ae3580aa.tar.gz
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 <chentsung@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205437 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Commit-Queue: Li-jen Chen <lijen@google.com>
-rw-r--r--driver/accel_bma4xx.c2
1 files changed, 1 insertions, 1 deletions
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);