summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorReka Norman <rekanorman@google.com>2023-05-04 11:11:19 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-04 08:08:58 +0000
commit1bde3ee34417c5e06451db18f4a2d3d541fa4376 (patch)
tree4939a1a16a68d268b9e2225424e0322d18c82e99 /chip
parent3ae782467a7f86415fcf1d4bdfd3414027900be3 (diff)
downloadchrome-ec-1bde3ee34417c5e06451db18f4a2d3d541fa4376.tar.gz
it83xx/adc: Use 64-bit int for voltage calculation
For some voltage dividers, factor_mul is large enough that the intermediate value can overflow, so use a 64-bit int. BRANCH=None BUG=b:271941405 TEST=VBUS ADC calculation doesn't overflow on dibbi Change-Id: I993e62e7c0ae31c70f962303e7a618841f2bc772 Signed-off-by: Reka Norman <rekanorman@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506010 Commit-Queue: Reka Norman <rekanorman@chromium.org> Tested-by: Reka Norman <rekanorman@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/it83xx/adc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/chip/it83xx/adc.c b/chip/it83xx/adc.c
index c666fc4e88..7b08a8beb1 100644
--- a/chip/it83xx/adc.c
+++ b/chip/it83xx/adc.c
@@ -167,7 +167,7 @@ int adc_read_channel(enum adc_channel ch)
else
IT83XX_ADC_ADCDVSTS2 = (1 << (adc_ch - CHIP_ADC_CH13));
- mv = adc_raw_data * adc_channels[ch].factor_mul /
+ mv = (uint64_t)adc_raw_data * adc_channels[ch].factor_mul /
adc_channels[ch].factor_div +
adc_channels[ch].shift;
valid = 1;