Re: [PATCH v2] iio: pressure: dps310: fix overflow in pressure compensation
From: Andy Shevchenko
Date: Wed Sep 30 2026 - 06:31:20 EST
On Wed, Sep 30, 2026 at 11:58:19AM +0300, Rupesh Majhi wrote:
> p^3 * c30 and t * p^2 * c21 overflow s64 at most oversampling ratios,
> and pressure comes out about 150 Pa low on a DPS310 here.
>
> Use Horner form, dividing by scale factor at each step. Overflow then
> needs a raw value far outside sensor range and returns -ERANGE.
>
> Checked against datasheet formula at all eight ratios.
...
> - *val = (int)min_t(s64, pressure, INT_MAX);
> + *val = min(pressure, INT_MAX);
So, in the original form the new one doesn't seem to change behaviour.
With this being said, I think this part should be split to a separate
(non-fix) change.
--
With Best Regards,
Andy Shevchenko