summaryrefslogtreecommitdiff
path: root/board/it8xxx2_pdevb
diff options
context:
space:
mode:
authorNikolai Artemiev <nartemiev@google.com>2021-07-02 16:43:08 +1000
committerCommit Bot <commit-bot@chromium.org>2021-07-29 22:47:26 +0000
commit9e38a616f13b99f70d042a8c569f77c58d8ac5ef (patch)
tree132961d04db4ea44e450eb2b6c79e6d6d7739366 /board/it8xxx2_pdevb
parent1f4d0c9302272e20dfb925bbb6a139167a49ddee (diff)
downloadchrome-ec-9e38a616f13b99f70d042a8c569f77c58d8ac5ef.tar.gz
dooly: refactor tcs3400_translate_to_xyz()
Refactor tcs3400_translate_to_xyz(): simplify calculations, reduce code duplication, avoid integer overflow, and guard against division by zero. Previously there were several places where integer values could overflow, such as converting 16-bit unsigned integers to fp_t values and multiplications with results exceeding the range of fp_t. In practice operations would overflow when holding a phone flashlight in front of the light sensor. BUG=b:179960346 BRANCH=none TEST=Flashed EC and tested sensor with a phone flashlight. Logging output values from old/new implementations showed no changes, except when the old implementation overflowed. Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Change-Id: I52c37414b5205beaefa2111b1737b0eb22b7235a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3007377 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'board/it8xxx2_pdevb')
0 files changed, 0 insertions, 0 deletions