Re: [PATCH v2 5/7] iio: core: Add IIO_COVERAGE_PERCENT channel type
From: Jonathan Cameron
Date: Sat May 16 2026 - 12:58:35 EST
On Thu, 14 May 2026 17:46:52 +0300
Liviu Stan <liviu.stan@xxxxxxxxxx> wrote:
> Add a new channel type for sensors that report fractional coverage as
> a percentage. The first user is the ADT7604 leak detector, where the
> value represents the portion of the sensing element that is wetted.
>
> Signed-off-by: Liviu Stan <liviu.stan@xxxxxxxxxx>
Few things from sashiko that you should address.
One I want to talk more about...
> ---
> Changes in v2:
> - New patch.
>
> Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
> drivers/iio/industrialio-core.c | 1 +
> include/uapi/linux/iio/types.h | 1 +
> tools/iio/iio_event_monitor.c | 1 +
> 4 files changed, 13 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 925a33fd309a..0570e8b8f5e5 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -1980,6 +1980,16 @@ Description:
> Raw (unscaled no offset etc.) resistance reading.
> Units after application of scale and offset are ohms.
>
> +What: /sys/bus/iio/devices/iio:deviceX/in_coveragepercentX_raw
The bot raises a valid concern about having the unit in the _raw attribute name.
If there is a scale (which incidentally probably needs adding to the ABI - as
_raw on its own is a bit meaningless) then it only becomes percent after
that is applied.
Perhaps
in_coverageX_raw is the way to go?
> +KernelVersion: 6.15
> +Contact: linux-iio@xxxxxxxxxxxxxxx
> +Description:
> + Raw (unscaled no offset etc.) coverage reading. Used for sensors
> + that report fractional coverage as a percentage, such as leak
> + detectors where the value represents what portion of the sensing
> + element is wetted. Units after application of scale and offset are
> + percent.
> +
> What: /sys/bus/iio/devices/iio:deviceX/heater_enable
> KernelVersion: 4.1.0
> Contact: linux-iio@xxxxxxxxxxxxxxx
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index bd6f4f9f4533..ee8ffa2cfbc5 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_COVERAGE_PERCENT] = "coveragepercent",
> };
>
> static const char * const iio_modifier_names[] = {
> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
> index d7c2bb223651..39830dc0cfb1 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_COVERAGE_PERCENT,
> };
>
> enum iio_modifier {
> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
> index df6c43d7738d..3339be7fe32c 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_COVERAGE_PERCENT] = "coveragepercent",
> };
>
> static const char * const iio_ev_type_text[] = {