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:
parent
d7223e7bba
commit
6a4514ddc0
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue