mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-04 05:51:34 +00:00
rambi: fix potential bug in accelerometer init
Fixed a potential bug in accelerometer initialization that could result in failing to write the desired accelereometer settings. Before writing the desired settings, we first send a command to perform a software reset. While waiting for software reset to complete, if we have an I2C error, then we could interpret this as software reset complete and go on to write the accelerometer settings before the reset has actually completed. BUG=none BRANCH=rambi TEST=Code inspection. I haven't actually seen this bug, I just saw the potential for it. Change-Id: I78757106291ffbaeff27f94aa6f74c9cea81e0b9 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189064 (cherry picked from commit 521a99e38428fcfe928616f4932b5d1167e2f6cb) Reviewed-on: https://chromium-review.googlesource.com/189233 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
c42bf99402
commit
0e3ff013cc
@@ -183,10 +183,10 @@ int accel_init(enum accel_id id)
|
||||
|
||||
/* Wait until software reset is complete or timeout. */
|
||||
while (1) {
|
||||
raw_read8(accel_addr[id], KXCJ9_CTRL2, &ctrl2);
|
||||
ret = raw_read8(accel_addr[id], KXCJ9_CTRL2, &ctrl2);
|
||||
|
||||
/* Reset complete. */
|
||||
if (!(ctrl2 & KXCJ9_CTRL2_SRST))
|
||||
if (ret == EC_SUCCESS && !(ctrl2 & KXCJ9_CTRL2_SRST))
|
||||
break;
|
||||
|
||||
/* Check for timeout. */
|
||||
|
||||
Reference in New Issue
Block a user