mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joshua Crofts <crofts@kernel.org>
To: "Rupesh Majhi" <zoone.rupert@gmail.com>,
	"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>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/7] iio: pressure: dps310: use time unit macros for sleeps and timeouts
Date: Thu, 26 Nov 2026 14:17:34 +0100	[thread overview]
Message-ID: <065da662-2670-4f7c-93dd-410e9c11d18a@kernel.org> (raw)
In-Reply-To: <20261126121331.10438-6-zoone.rupert@gmail.com>

On 26-Nov-26 13:13, Rupesh Majhi wrote:
> Write the microsecond values as multiples of USEC_PER_MSEC, like the
> poll timeout next to them already uses USEC_PER_SEC.
> 
> After a reset wait 20 ms with msleep() instead of 15 to 55 ms. The
> specification says 15 ms, so this keeps some margin.
> 
> Signed-off-by: Rupesh Majhi <zoone.rupert@gmail.com>
> ---
> v2:
> - wrap the poll call on logical boundaries (Andy)
> - msleep(20) after a reset (Andy)
> 
>  drivers/iio/pressure/dps310.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
> index f802c2c59072..1d46817ad04a 100644
> --- a/drivers/iio/pressure/dps310.c
> +++ b/drivers/iio/pressure/dps310.c
> @@ -20,6 +20,7 @@
>  
>  #include <linux/bitfield.h>
>  #include <linux/cleanup.h>
> +#include <linux/delay.h>
>  #include <linux/devm-helpers.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> @@ -103,7 +104,7 @@
>  #define DPS310_DRAIN_MAX_MS	(2 * MSEC_PER_SEC)
>  
>  /* Make sure sleep time is <= 30ms for usleep_range */
> -#define DPS310_POLL_SLEEP_US(t)		min(30000, (t) / 8)
> +#define DPS310_POLL_SLEEP_US(t)		min(30 * USEC_PER_MSEC, (t) / 8)
>  /* 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))
>  
> @@ -369,8 +370,9 @@ static int dps310_startup(struct dps310_data *data)
>  	 * Calibration coefficients required for reporting temperature.
>  	 * They are available 40ms after the device has started
>  	 */
> -	rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready,
> -				      ready & DPS310_COEF_RDY, 10000, 40000);
> +	rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG,
> +				      ready, ready & DPS310_COEF_RDY,
> +				      10 * USEC_PER_MSEC, 40 * USEC_PER_MSEC);
>  	if (rc)
>  		return rc;
>  
> @@ -558,7 +560,7 @@ static int dps310_reset_wait(struct dps310_data *data)
>  		return rc;
>  
>  	/* Wait for device chip access: 15ms in specification */
> -	usleep_range(15000, 55000);
> +	msleep(20);
I think it's safe to use 15 as specified in the datasheet, as msleep()
guarantees sleep for the specified time + a max of 12.5% slack.

This can be tweaked whilst applying though (or not, at it's pretty minuscule).

Either way,

Reviewed-by: Joshua Crofts <crofts@kernel.org>

-- 
Kind regards,
Joshua Crofts


  reply	other threads:[~2026-11-26 13:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 12:13 [PATCH v2 0/7] iio: pressure: dps310: cleanups Rupesh Majhi
2026-11-26 12:13 ` [PATCH v2 1/7] iio: pressure: dps310: sort register field defines high to low Rupesh Majhi
2026-11-26 13:20   ` Joshua Crofts
2026-11-26 13:44   ` Andy Shevchenko
2026-11-26 12:13 ` [PATCH v2 2/7] iio: pressure: dps310: read the coefficients with get_unaligned_be*() Rupesh Majhi
2026-11-26 12:13 ` [PATCH v2 3/7] iio: pressure: dps310: use min() instead of min_t() Rupesh Majhi
2026-11-26 13:18   ` Joshua Crofts
2026-11-26 13:44   ` Andy Shevchenko
2026-11-26 12:13 ` [PATCH v2 4/7] iio: pressure: dps310: use KILO for the Pa to kPa conversion Rupesh Majhi
2026-11-26 12:13 ` [PATCH v2 5/7] iio: pressure: dps310: use time unit macros for sleeps and timeouts Rupesh Majhi
2026-11-26 13:17   ` Joshua Crofts [this message]
2026-11-26 13:49     ` Andy Shevchenko
2026-11-26 14:19       ` Joshua Crofts
2026-11-26 14:37         ` Andy Shevchenko
2026-11-26 13:49   ` Andy Shevchenko
2026-11-26 12:13 ` [PATCH v2 6/7] iio: pressure: dps310: drop the unused i2c_set_clientdata() Rupesh Majhi
2026-11-26 12:13 ` [PATCH v2 7/7] iio: pressure: dps310: include what the driver uses Rupesh Majhi
2026-11-26 13:12   ` Joshua Crofts

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=065da662-2670-4f7c-93dd-410e9c11d18a@kernel.org \
    --to=crofts@kernel.org \
    --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=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®