iio: pressure: dps310: don't wait for new temperature in trigger handler
Subsystems (2)
PATCH 1/1 iio: pressure: dps310: don't wait for new temperature in trigger handler
Each scan waits for a new temperature result before reading pressure. With pressure sampled faster than temperature, scans then come at the temperature rate: an 8 Hz trigger with temperature at its default 1 Hz gives one scan a second.
Read pressure first and take the latest temperature, as a direct pressure read already does. Wait for temperature only when pressure is not in the scan.
--- drivers/iio/pressure/dps310.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/iio/pressure/dps310.c +12 -8
@@ -910,10 +910,18 @@ static int dps310_fill_channels(struct dps310_data *data,unsigned int i;int rc; -/* Compensation needs a temperature, so it is sampled either way */ - rc =dps310_read_temp_raw_locked (data); -if (rc) -return rc; +if (test_bit (DPS310_SCAN_PRESSURE , scan_mask)) { + rc =dps310_read_pres_raw_locked (data); +if (rc) +return rc; + +/* Waiting here would hold scans to the temperature rate */ +dps310_refresh_temp_locked (data); + }else { + rc =dps310_read_temp_raw_locked (data); +if (rc) +return rc; + } i =0 ;if (test_bit (DPS310_SCAN_TEMP , scan_mask)) {
@@ -924,10 +932,6 @@ static int dps310_fill_channels(struct dps310_data *data, }if (test_bit (DPS310_SCAN_PRESSURE , scan_mask)) { - rc =dps310_read_pres_raw_locked (data); -if (rc) -return rc; -/* Pascals, see the channel definition */ rc =dps310_calculate_pressure (data, &channels[i++]);if (rc)
base-commit: 79c8dffd84e9784ec05bea68dbe5e71f7ec9941a
Signature · 1 line
2.43.0
drivers/iio/pressure/dps310.c static int dps310_fill_channels(struct dps310_data *data, · line 919
Quoted 7 lines · Rupesh Majhi
drivers/iio/pressure/dps310.c +7
-0+if (test_bit (DPS310_SCAN_PRESSURE , scan_mask)) { + rc =dps310_read_pres_raw_locked (data); +if (rc) +return rc; + +/* Waiting here would hold scans to the temperature rate */ +dps310_refresh_temp_locked (data);
Maybe I'm getting this wrong, but isn't there a case the new path doesn't cover? Nothing reads a temperature at probe, so if a pressure only buffer is enabled shortly after probe and the first pressure result is ready before any temperature result, dps310_refresh_temp_locked() finds TMP_RDY clear and the pressure is compensated with temp_raw still 0.
I think the FIFO path handles this case by dps310_fifo_hold() keeping pressure entries until fifo_temp_valid is set by the first temperature. Would it make sense to do the same here with a flag set when a temperature has been read, and wait for one temperature in dps310_refresh_temp_locked() only while it's unset? That would cover direct pressure reads and after the first sample the scans stay at the pressure rate as your patch intends.
Thanks,
Arnav
Quoted 6 lines · On Fri, 13 Nov 2026 03:19:29 +0530 Arnav Kapoor <[email protected]> wrote:
Maybe I'm getting this wrong, but isn't there a case the new path doesn't cover? Nothing reads a temperature at probe, so if a pressure only buffer is enabled shortly after probe and the first pressure result is ready before any temperature result,
dps310_refresh_temp_locked()findsTMP_RDYclear and the pressure is compensated withtemp_rawstill 0.
You're right. After a reset the chip has pressure ready about 3 ms after measurement starts and temperature about 7 ms. On my board probe takes longer than that, so I could only see it by dropping the first temperature result in a test build. The first scan then reads 1.2 kPa high.
Quoted 5 lines
Would it make sense to do the same here with a flag set when a temperature has been read, and wait for one temperature in
dps310_refresh_temp_locked()only while it's unset? That would cover direct pressure reads and after the first sample the scans stay at the pressure rate as your patch intends.
I'd rather read one temperature in probe. That covers direct reads too, costs a few ms at most and needs no flag. I'll send v2 with that.
Thanks,
Rupesh