Re: [PATCH v2 1/3] iio: types: add IIO_VOLUMEFLOW channel type

From: Jonathan Cameron

Date: Thu May 28 2026 - 06:22:42 EST


On Wed, 27 May 2026 20:42:52 +0200
Wadim Mueller <wafgo01@xxxxxxxxx> wrote:

> Add a new IIO channel type for liquid volumetric flow sensors. The
> unit exposed via the standard _scale attribute is litres per second
> (l/s), so drivers reporting smaller native units (e.g. ml/min) only
> need to set a fractional scale.

Hi Wadim

You (I think) raised a useful point in v1. Given the SI units thing should
we actually be doing m^3/sec? for this new type? That would be more
inline with existing units including distance.

There is a slight inconsistency for Ph which is log_10(ions per litre)

I'd like more opinions on this as I've made some less than idea decisions
on units in the past!

One other thing inline.


Jonathan


>
> Update iio-core's name table, the iio_event_monitor whitelist and
> the sysfs-bus-iio ABI document to match. The new _scale attribute is
> folded into the existing shared _scale block; only the per-type _raw
> needs a fresh entry.
>
> Signed-off-by: Wadim Mueller <wafgo01@xxxxxxxxx>
> Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
> Cc: Jean Delvare <jdelvare@xxxxxxxx>
> Cc: Andreas Klinger <ak@xxxxxxxxxxxxx>
> Cc: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Cc: linux-hwmon@xxxxxxxxxxxxxxx
> Cc: Maxwell Doose <m32285159@xxxxxxxxx>
> ---
> Documentation/ABI/testing/sysfs-bus-iio | 11 +++++++++++
> drivers/iio/industrialio-core.c | 1 +
> include/uapi/linux/iio/types.h | 1 +
> tools/iio/iio_event_monitor.c | 2 ++
> 4 files changed, 15 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 5f87dcee7..2188557cb 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -507,6 +507,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_intensity_red_scale
> What: /sys/bus/iio/devices/iio:deviceX/in_intensity_green_scale
> What: /sys/bus/iio/devices/iio:deviceX/in_intensity_blue_scale
> What: /sys/bus/iio/devices/iio:deviceX/in_concentration_co2_scale
> +What: /sys/bus/iio/devices/iio:deviceX/in_volumeflow_scale
> +What: /sys/bus/iio/devices/iio:deviceX/in_volumeflowY_scale

I'm going to assume this driver only uses one of these. Generally we only introduce
stuff on first use, so drop the one you aren't using.

> KernelVersion: 2.6.35
> Contact: linux-iio@xxxxxxxxxxxxxxx
> Description:
> @@ -2458,3 +2460,12 @@ Description:
> seconds, expressed as:
>
> - a range specified as "[min step max]"
> +
> +What: /sys/bus/iio/devices/iio:deviceX/in_volumeflow_raw
> +What: /sys/bus/iio/devices/iio:deviceX/in_volumeflowY_raw
> +KernelVersion: 6.19
> +Contact: linux-iio@xxxxxxxxxxxxxxx
> +Description:
> + Raw (unscaled) volumetric flow rate reading from the channel.
> + To convert to standard units (litres per second) apply the
> + channel's _scale (and _offset, when present).
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 22eefd048..aa34fcd8e 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -98,6 +98,7 @@ static const char * const iio_chan_type_name_spec[] = {
> [IIO_CHROMATICITY] = "chromaticity",
> [IIO_ATTENTION] = "attention",
> [IIO_ALTCURRENT] = "altcurrent",
> + [IIO_VOLUMEFLOW] = "volumeflow",
> };
>
> static const char * const iio_modifier_names[] = {
> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
> index 6d269b844..49480f321 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -53,6 +53,7 @@ enum iio_chan_type {
> IIO_CHROMATICITY,
> IIO_ATTENTION,
> IIO_ALTCURRENT,
> + IIO_VOLUMEFLOW,
> };
>
> enum iio_modifier {
> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
> index 03ca33869..078004750 100644
> --- a/tools/iio/iio_event_monitor.c
> +++ b/tools/iio/iio_event_monitor.c
> @@ -65,6 +65,7 @@ static const char * const iio_chan_type_name_spec[] = {
> [IIO_CHROMATICITY] = "chromaticity",
> [IIO_ATTENTION] = "attention",
> [IIO_ALTCURRENT] = "altcurrent",
> + [IIO_VOLUMEFLOW] = "volumeflow",
> };
>
> static const char * const iio_ev_type_text[] = {
> @@ -193,6 +194,7 @@ static bool event_is_known(struct iio_event_data *event)
> case IIO_CHROMATICITY:
> case IIO_ATTENTION:
> case IIO_ALTCURRENT:
> + case IIO_VOLUMEFLOW:
> break;
> default:
> return false;