[PATCH 5/7] iio: pressure: dps310: use time unit macros for sleeps and timeouts
From: Rupesh Majhi
Date: Mon Nov 23 2026 - 17:07:20 EST
Write the microsecond values as multiples of USEC_PER_MSEC, like the
poll timeout next to them already uses USEC_PER_SEC. Wait the 15 ms
after a reset with fsleep(), which allows less slack than the old
55 ms upper bound.
Signed-off-by: Rupesh Majhi <zoone.rupert@xxxxxxxxx>
---
drivers/iio/pressure/dps310.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
index e5a89dac1325..eb5715f75e9e 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))
@@ -370,7 +371,8 @@ static int dps310_startup(struct dps310_data *data)
* 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);
+ 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);
+ fsleep(15 * USEC_PER_MSEC);
return 0;
}
--
2.43.0