adc: Use int64_t in voltage divider calculation to avoid overflow

int32_t overflows above 1.3kOhm if using vref 3300 mV.

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
This commit is contained in:
Björn Stenberg 2024-03-06 13:52:57 +01:00 committed by Alberto Escolar
parent d7223e7bba
commit 6a4514ddc0

View file

@ -51,7 +51,7 @@ static inline int voltage_divider_scale_dt(const struct voltage_divider_dt_spec
}
/* voltage scaled by voltage divider values using DT binding */
*v_to_v = *v_to_v * spec->full_ohms / spec->output_ohms;
*v_to_v = (int64_t)*v_to_v * spec->full_ohms / spec->output_ohms;
return 0;
}