Skip to contentSkip to conversation

iio: pressure: dps310: read the first temperature in probe

PATCH In review Rupesh Majhi 2 participants 2 messages Nov 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: pressure: dps310: read the first temperature in probe

The first temperature read is in dps310_fifo_interval() instead of probe. That function is called with data->lock held and takes it again, so enabling the buffer without a trigger deadlocks.

Move the read to probe.

Fixes 903941a9b06a ("iio: pressure: dps310: don't wait for new temperature in trigger handler")

---
v2: return inside the guard scope (Andy)
v1: https://lore.kernel.org/linux-iio/[email protected]/

Based on iio togreg, fine to squash into 903941a9b06a instead.

Tested on a DPS310 on a BeagleBone Black: enabling the buffer without a trigger works.

Cc Arnav Kapoor <[email protected]>
Cc Jonathan Cameron <[email protected]>
 drivers/iio/pressure/dps310.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/pressure/dps310.c +7 -7
index 9b52cbc2372a..fc727e5fcd59 100644
@@ -1058,16 +1058,9 @@ static unsigned int dps310_fifo_interval(struct dps310_data *data,
 {
 	unsigned int drain_interval_ms, fill_ms, want_ms;
 	int scan_rate;
-	int rc;
 
 	fill_ms = MSEC_PER_SEC * DPS310_FIFO_DEPTH / (prs_rate + tmp_rate);
 
-	/* Pressure compensation needs a temperature from the start */
-	scoped_guard(mutex, &data->lock)
-		rc = dps310_read_temp_raw_locked(data);
-	if (rc)
-		return rc;
-
 	/*
 	 * There is no hardware watermark, so take it as the number of scans
 	 * the user will wait for and drain at that rate. Scans come from
@@ -1478,6 +1471,13 @@ static int dps310_probe(struct i2c_client *client)
 	if (rc)
 		return rc;
 
+	/* Pressure compensation needs a temperature from the start */
+	scoped_guard(mutex, &data->lock) {
+		rc = dps310_read_temp_raw_locked(data);
+		if (rc)
+			return rc;
+	}
+
 	/*
 	 * The device measures continuously in background mode, so a triggered
 	 * capture is just a read of the latest results. The setup ops run the

base-commit: 903941a9b06ae445c70646ab061b604c2dea17d3

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 6 lines · On Sat, 21 Nov 2026 20:25:27 +0200 Rupesh Majhi <[email protected]> wrote:

The first temperature read is in dps310_fifo_interval() instead of probe. That function is called with data->lock held and takes it again, so enabling the buffer without a trigger deadlocks.

Move the read to probe.

Quoted 8 lines
Fixes 903941a9b06a ("iio: pressure: dps310: don't wait for new temperature in trigger handler")

---
v2: return inside the guard scope (Andy)
v1: https://lore.kernel.org/linux-iio/[email protected]/

Based on iio togreg, fine to squash into 903941a9b06a instead.

Squashed and fresh togreg pushed out.

Quoted 47 lines

Tested on a DPS310 on a BeagleBone Black: enabling the buffer without a trigger works.

Cc Arnav Kapoor <[email protected]>
Cc Jonathan Cameron <[email protected]>
 drivers/iio/pressure/dps310.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/pressure/dps310.c +7 -7
index 9b52cbc2372a..fc727e5fcd59 100644
@@ -1058,16 +1058,9 @@ static unsigned int dps310_fifo_interval(struct dps310_data *data,
 {
 	unsigned int drain_interval_ms, fill_ms, want_ms;
 	int scan_rate;
-	int rc;
 
 	fill_ms = MSEC_PER_SEC * DPS310_FIFO_DEPTH / (prs_rate + tmp_rate);
 
-	/* Pressure compensation needs a temperature from the start */
-	scoped_guard(mutex, &data->lock)
-		rc = dps310_read_temp_raw_locked(data);
-	if (rc)
-		return rc;
-
 	/*
 	 * There is no hardware watermark, so take it as the number of scans
 	 * the user will wait for and drain at that rate. Scans come from
@@ -1478,6 +1471,13 @@ static int dps310_probe(struct i2c_client *client)
 	if (rc)
 		return rc;
 
+	/* Pressure compensation needs a temperature from the start */
+	scoped_guard(mutex, &data->lock) {
+		rc = dps310_read_temp_raw_locked(data);
+		if (rc)
+			return rc;
+	}
+
 	/*
 	 * The device measures continuously in background mode, so a triggered
 	 * capture is just a read of the latest results. The setup ops run the

base-commit: 903941a9b06ae445c70646ab061b604c2dea17d3