Re: [PATCH v10 2/4] iio: pressure: dps310: derive the drain interval from the watermark
From: Andy Shevchenko
Date: Wed Sep 30 2026 - 10:11:35 EST
On Wed, Sep 30, 2026 at 01:01:56PM +0300, Rupesh Majhi wrote:
> The drain interval only tracked how fast the FIFO fills, so a small
> watermark still waited half a FIFO for its samples. Take the watermark
> as the number of scans to wait for, but never drain slower than half a
> fill.
...
> - unsigned int fill_ms;
> + unsigned int fill_ms, want_ms;
What about
unsigned int drain_interval_ms, fill_ms, want_ms;
> + int scan_rate;
> fill_ms = MSEC_PER_SEC * DPS310_FIFO_DEPTH / (prs_rate + tmp_rate);
>
> - return clamp(fill_ms / 2, DPS310_DRAIN_MIN_MS, DPS310_DRAIN_MAX_MS);
> + /*
> + * 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
> + * whichever measurement drives them.
> + */
> + if (test_bit(DPS310_SCAN_PRESSURE, data->iio->active_scan_mask))
> + scan_rate = prs_rate;
> + else
> + scan_rate = tmp_rate;
> +
> + want_ms = data->watermark * MSEC_PER_SEC / scan_rate;
> + return clamp(min(want_ms, fill_ms / 2), DPS310_DRAIN_MIN_MS,
> + DPS310_DRAIN_MAX_MS);
drain_interval_ms = min(want_ms, fill_ms / 2);
return clamp(drain_interval_ms, DPS310_DRAIN_MIN_MS, DPS310_DRAIN_MAX_MS);
?
--
With Best Regards,
Andy Shevchenko