Re: [PATCH v2 3/3] iio: flow: add Sensirion SLF3S liquid flow sensor driver
From: Rodrigo Alencar
Date: Thu May 28 2026 - 10:03:04 EST
On 26/05/28 12:22PM, Jonathan Cameron wrote:
> On Wed, 27 May 2026 20:42:54 +0200
> Wadim Mueller <wafgo01@xxxxxxxxx> wrote:
>
> > Add a driver for the Sensirion SLF3S family of digital liquid-flow
> > sensors (SLF3S-0600F, SLF3S-1300F and SLF3S-4000B). The sensors
> > communicate over I2C and return a 16-bit signed flow value, a 16-bit
> > signed temperature reading and a status word - each protected by a
> > CRC-8 byte - in every measurement frame.
> >
> > The driver exposes:
> >
> > in_volumeflow_raw - signed raw counts
> > in_volumeflow_scale - litres per second per LSB (per variant)
> > in_temp_raw - signed raw counts
> > in_temp_scale - millidegrees Celsius per LSB
> >
> > The variant is auto-detected from the product-info word read at
> > probe time. All three SLF3S devices are factory-calibrated for both
> > water and isopropyl alcohol; the calibration medium is selected via
> > the sensirion,medium device property and defaults to water.
> >
> > Scale factors are taken from the respective datasheets (Table 16
> > for SLF3S-0600F, Table 15 for SLF3S-1300F and SLF3S-4000B):
> >
> > SLF3S-0600F: 10 (ul/min)^-1 -> 1/600 000 000 (l/s)/LSB
> > SLF3S-1300F: 500 (ml/min)^-1 -> 1/30 000 000 (l/s)/LSB
> > SLF3S-4000B: 32 (ml/min)^-1 -> 1/1 920 000 (l/s)/LSB
...
> > +static int slf3s_read_raw(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan, int *val,
> > + int *val2, long mask)
> > +{
> > + struct slf3s_data *sf = iio_priv(indio_dev);
> > + int flow, temp, ret;
> > +
> > + switch (mask) {
> > + case IIO_CHAN_INFO_RAW:
> > + if (!iio_device_claim_direct(indio_dev))
> > + return -EBUSY;
> > +
> > + ret = slf3s_read_sample(sf, &flow, &temp);
> > + iio_device_release_direct(indio_dev);
> > + if (ret)
> > + return ret;
> > +
> > + *val = (chan->type == IIO_VOLUMEFLOW) ? flow : temp;
> > + return IIO_VAL_INT;
> > + case IIO_CHAN_INFO_SCALE:
> > + if (chan->type == IIO_VOLUMEFLOW) {
> > + *val = sf->variant->scale_num;
> > + *val2 = sf->variant->scale_den;
>
> Sashiko (probably correctly) identifies that the formatting that the IIO core
> does for an IIO_VAL_FRACTIONAL only goes to 9 decimal places. That means
> in some cases the scale is truncated to 1 digit losing much of its usefulness.
> https://sashiko.dev/#/patchset/20260527184257.141635-1-wafgo01%40gmail.com
>
> As such we need to increase the number of digits or maybe switch to using
> https://lore.kernel.org/all/20260524-adf41513-iio-driver-v14-6-06824d9c15f4@xxxxxxxxxx/
>
> Which defines IIO_VAL_DECIMAL64_PICO
yes, pico would be enough, but IIO_VAL_DECIMAL64_FEMTO could also be defined if needed.
There will be a v15, then let me know if any changes are needed.
--
Kind regards,
Rodrigo Alencar