[PATCH 3/3] iio: pressure: dps310: keep the user's settings across a timeout reset
From: Rupesh Majhi
Date: Thu Oct 29 2026 - 18:07:50 EST
When a sample never becomes ready, the driver resets the chip and runs
startup again, which writes the default rate and ratio. With 64x at
4 Hz set and the chip put in standby, the next read recovers, but both
channels are silently back to 1x at 1 Hz.
The register cache still holds the user's values. Write them back
after the reset, before measuring starts again, and move the defaults
out of dps310_startup() so only probe writes them.
A rate and ratio the chip cannot keep up with, such as 128x at 128 Hz,
now keep timing out instead of falling back to 1x at 1 Hz.
Fixes: 7b4ab4abcea4 ("iio: pressure: dps310: Reset chip after timeout")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://sashiko.dev/#/patchset/20260921183132.233136-1-zoone.rupert%40gmail.com
Signed-off-by: Rupesh Majhi <zoone.rupert@xxxxxxxxx>
---
Cc: Paulius Zaleckas <paulius.zaleckas@xxxxxxxxx>
drivers/iio/pressure/dps310.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
index 29778f25bb33..c364fbaeb3fe 100644
--- a/drivers/iio/pressure/dps310.c
+++ b/drivers/iio/pressure/dps310.c
@@ -306,10 +306,9 @@ static int dps310_temp_workaround(struct dps310_data *data)
return regmap_write(data->regmap, 0x0f, 0x00);
}
-static int dps310_startup(struct dps310_data *data)
+static int dps310_set_defaults(struct dps310_data *data)
{
int rc;
- int ready;
/*
* Set up pressure sensor in single sample, one measurement per second
@@ -328,10 +327,14 @@ static int dps310_startup(struct dps310_data *data)
return rc;
/* Temp and pressure shifts are disabled when PRC <= 8 */
- rc = regmap_write_bits(data->regmap, DPS310_CFG_REG,
- DPS310_PRS_SHIFT_EN | DPS310_TMP_SHIFT_EN, 0);
- if (rc)
- return rc;
+ return regmap_write_bits(data->regmap, DPS310_CFG_REG,
+ DPS310_PRS_SHIFT_EN | DPS310_TMP_SHIFT_EN, 0);
+}
+
+static int dps310_startup(struct dps310_data *data)
+{
+ int rc;
+ int ready;
/* MEAS_CFG doesn't update correctly unless first written with 0 */
rc = regmap_write_bits(data->regmap, DPS310_MEAS_CFG,
@@ -551,6 +554,12 @@ static int dps310_reset_reinit(struct dps310_data *data)
if (rc)
return rc;
+ /* Put back the configuration the reset cleared */
+ regcache_mark_dirty(data->regmap);
+ rc = regcache_sync_region(data->regmap, DPS310_PRS_CFG, DPS310_CFG_REG);
+ if (rc)
+ return rc;
+
return dps310_startup(data);
}
@@ -1450,6 +1459,10 @@ static int dps310_probe(struct i2c_client *client)
if (rc)
return rc;
+ rc = dps310_set_defaults(data);
+ if (rc)
+ return rc;
+
rc = dps310_startup(data);
if (rc)
return rc;
--
2.43.0