mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Rupesh Majhi" <zoone.rupert@gmail.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Eddie James" <eajames@linux.ibm.com>,
	"Joel Stanley" <joel@jms.id.au>, "Nuno Sá" <nuno.sa@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] iio: pressure: dps310: wait for a new sample after a ratio change
Date: Mon, 26 Oct 2026 02:46:05 +0000	[thread overview]
Message-ID: <20261026024605.3286702f@jic23-hlaptop> (raw)
In-Reply-To: <atZqSXI14WojGso5@ashevche-desk.local>

On Mon, 19 Oct 2026 22:06:49 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Oct 19, 2026 at 06:33:28PM +0300, Rupesh Majhi wrote:
> > After an oversampling ratio change, the sample waiting in the result
> > registers and the one being measured are both from the old ratio, but
> > are scaled with the new one. Pressure ratio 2 to 16 reads 192 kPa instead
> > of 103 kPa, and temperature is off by hundreds of degrees. Pressure is
> > also wrong after a temperature ratio change, as it is compensated with
> > the cached temperature.
> > 
> > Discard those two samples on a ratio change, and for temperature cache
> > the one after. The ratio write now blocks until then.
> > 
> > That wait can be longer than the 1/rate timeout, after which the driver
> > resets the chip and the ratio silently goes back to 1. Allow two periods.  
> 
> ...
> 
> >  /* Make sure sleep time is <= 30ms for usleep_range */
> >  #define DPS310_POLL_SLEEP_US(t)		min(30000, (t) / 8)  
> 
> Seems the use of USEC_PER_SEC below should be postponed to a regular cleanup.
> Because otherwise it will be inconsistent with the above where it would need
> to be 30 * USEC_PER_MSEC
Do we want to have the extra churn on the below?
I'm not that bothered by a temporary state of different styles.
Nice indeed to have a follow up tidying up other cases though!

There is quite a bit going on around this driver, so I'm going to pick this
one up for the testing branch of iio.git rather than the faster path.

Thanks,

Jonathan

> 
> > -/* Silently handle error in rate value here */
> > -#define DPS310_POLL_TIMEOUT_US(rc)	((rc) <= 0 ? 1000000 : 1000000 / (rc))
> > +/* A period plus a measurement time; silently handle error in rate value */
> > +#define DPS310_POLL_TIMEOUT_US(rc)	(2 * USEC_PER_SEC / max(rc, 1))  
> 


  reply	other threads:[~2026-10-26  2:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 15:33 Rupesh Majhi
2026-10-19 19:06 ` Andy Shevchenko
2026-10-26  2:46   ` Jonathan Cameron [this message]
2026-10-26  9:05     ` Andy Shevchenko
2026-10-26 17:39       ` Rupesh Majhi
2026-10-27  0:28         ` Jonathan Cameron

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=20261026024605.3286702f@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=eajames@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --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®