Re: [PATCH v4 2/5] iio: add power and energy measurement modifiers

From: Jonathan Cameron
Date: Sat Aug 16 2025 - 12:40:50 EST


On Fri, 15 Aug 2025 09:56:35 +0000
Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx> wrote:

> Add new IIO modifiers to support power and energy measurement devices:
>
> Power modifiers:
> - IIO_MOD_ACTIVE: Real power consumed by the load
> - IIO_MOD_REACTIVE: Power that oscillates between source and load
> - IIO_MOD_APPARENT: Magnitude of complex power
> - IIO_MOD_FUND_REACTIVE: Reactive power at fundamental frequency
> - IIO_MOD_FACTOR: Power factor (ratio of active to apparent power)
>
> Signal quality modifiers:
> - IIO_MOD_RMS: Root Mean Square value
>
> These modifiers enable proper representation of power measurement
> devices like energy meters and power analyzers.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
> ---
> changes in v4:
> - add proper KernelVersion and Contact fields to ABI documentation
> - add detailed description for power factor measurement
> - add altcurrent RMS measurement support
> Documentation/ABI/testing/sysfs-bus-iio | 27 +++++++++++++++++++++++++
> drivers/iio/industrialio-core.c | 5 +++++
> include/linux/iio/types.h | 1 +
> include/uapi/linux/iio/types.h | 4 ++++
> 4 files changed, 37 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 2fb2cea4b192..9d283b23d3c0 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -167,7 +167,17 @@ Description:
> is required is a consistent labeling. Units after application
> of scale and offset are millivolts.
>
> +What: /sys/bus/iio/devices/iio:deviceX/in_altvoltageY_rms_raw
> +KernelVersion: 6.15

That was a while back. Will be at least 6.18 unless this was hiding in use in
a driver that I didn't notice.

> +Contact: linux-iio@xxxxxxxxxxxxxxx
> +Description:
> + Raw (unscaled) RMS voltage measurement from

Spell out RMS so
Raw (unscaled) Root Mean Square (RMS) voltge measurement from

Also wrapping is odd. Match rest of file.


> +What: /sys/bus/iio/devices/iio:deviceX/in_powerY_powerfactor
> +KernelVersion: 6.15

6.18

> +Contact: linux-iio@xxxxxxxxxxxxxxx
> +Description:
> + Power factor measurement from channel Y. Power factor is the
> + ratio of active power to apparent power. The value is unitless.
> +
> What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
> KernelVersion: 3.2
> Contact: linux-iio@xxxxxxxxxxxxxxx
> @@ -1569,6 +1586,9 @@ Description:

>
> +What: /sys/bus/iio/devices/iio:deviceX/in_altcurrentY_rms_raw
> +KernelVersion: 6.15
> +Contact: linux-iio@xxxxxxxxxxxxxxx
> +Description:
> + Raw (unscaled no bias removal etc.) RMS current measurement from
> + channel Y. Units after application of scale and offset are milliamps.
As above.

Otherwise all looks good to me.

Jonathan

> +
> What: /sys/.../iio:deviceX/in_energy_en
> What: /sys/.../iio:deviceX/in_distance_en
> What: /sys/.../iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_en