diff options
author | Ting Shen <phoenixshen@google.com> | 2022-03-18 17:44:19 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-23 08:06:08 +0000 |
commit | a1f098ecd727634a7f7e243234d659d7dc919db6 (patch) | |
tree | e3dbaf34b5bcc2f05e558c87f871037628e75c7f /baseboard | |
parent | b83014e44a3dad7ced86c8c327eaa99140d604a7 (diff) | |
download | chrome-ec-a1f098ecd727634a7f7e243234d659d7dc919db6.tar.gz |
util: align the IN_RANGE implementation with zephyr
The design of IN_RANGE() is slightly different between CrosEC and
Zephyr's.
Zephyr IN_RANGE() includes both upper and lower bound. (Ref:
https://docs.zephyrproject.org/latest/reference/util/index.html#c.IN_RANGE)
Update legacy code to work with CONFIG_ZEPHYR.
BUG=none
TEST=manually verify that all occurarence of IN_RANGE is updated
BRANCH=none
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I67e83a92be574be96535a3fe1b14454754e32072
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3534749
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r-- | baseboard/asurada/board_id.c | 2 | ||||
-rw-r--r-- | baseboard/goroh/board_id.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/baseboard/asurada/board_id.c b/baseboard/asurada/board_id.c index a4590f3199..642785034c 100644 --- a/baseboard/asurada/board_id.c +++ b/baseboard/asurada/board_id.c @@ -79,7 +79,7 @@ static int adc_value_to_numeric_id(enum adc_channel ch) for (int i = 0; i < ARRAY_SIZE(voltage_map); i++) { if (IN_RANGE(mv, voltage_map[i] - threshold_mv, - voltage_map[i] + threshold_mv)) + voltage_map[i] + threshold_mv - 1)) return i; } diff --git a/baseboard/goroh/board_id.c b/baseboard/goroh/board_id.c index e90da11f57..fd2001d8a3 100644 --- a/baseboard/goroh/board_id.c +++ b/baseboard/goroh/board_id.c @@ -79,7 +79,7 @@ static int adc_value_to_numeric_id(enum adc_channel ch) for (int i = 0; i < ARRAY_SIZE(voltage_map); i++) { if (IN_RANGE(mv, voltage_map[i] - threshold_mv, - voltage_map[i] + threshold_mv)) + voltage_map[i] + threshold_mv - 1)) return i; } |