From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rupesh Majhi <zoone.rupert@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Eddie James" <eajames@linux.ibm.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] iio: pressure: dps310: fix overflow in pressure compensation
Date: Tue, 29 Sep 2026 01:00:20 +0300 [thread overview]
Message-ID: <arrjdFUA3iVa0TVB@ashevche-desk.local> (raw)
In-Reply-To: <20260928101803.547005-1-zoone.rupert@gmail.com>
On Mon, Sep 28, 2026 at 01:18:03PM +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.
...
> +/* Fixed point one for the compensation fractions */
> +#define DPS310_CALC_ONE ((s64)BIT_ULL(20))
What's the point in having _ULL in this case?
...
> - *val = (int)min_t(s64, pressure, INT_MAX);
> + *val = min_t(s64, pressure, INT_MAX);
Avoid using min_t(). It's prone to errors that will be hard to debug.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-09-28 22:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 10:18 Rupesh Majhi
2026-09-28 22:00 ` Andy Shevchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arrjdFUA3iVa0TVB@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=eajames@linux.ibm.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=zoone.rupert@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®