[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5835e21b-0b27-41f5-8c92-762cac327b40@baylibre.com>
Date: Sun, 18 Jan 2026 14:10:30 -0600
From: David Lechner <dlechner@...libre.com>
To: Marcelo Schmitt <marcelo.schmitt1@...il.com>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: jic23@...nel.org, Jonathan.Cameron@...wei.com, nuno.sa@...log.com,
andy@...nel.org
Subject: Re: [RFC PATCH v1 7/9] iio: Expand IIO event interface for real-world
unit handling
On 1/18/26 12:21 PM, Marcelo Schmitt wrote:
> The IIO event ABI documentation distinguishes between interfaces that
> handle values in device-specific units (_raw) and event interfaces that
> handle values in real-world units (e.g. meters, Joules, lux, etc).
> However, the IIO event code infrastructure had never really implemented the
> bits to distinguish between those two types of interfaces and had always
> presumed events to handle raw device values.
>
> For most current use cases, assuming events to handle values in device raw
> units is reasonable because it often matches the type of the associated IIO
> channel. There are a few cases where drivers provide events along side
> channels with both _raw and _input interfaces, though. Also, when
> real-world values can be mapped back to device configurations, it enables
> drivers to provide event interfaces that are arguably easier to use.
>
> Expand the IIO events support, enabling IIO drivers to provide event
> interfaces that handle values in real-world units.
>
...
> @@ -399,15 +410,23 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
> for_each_set_bit(i, mask, sizeof(*mask)*8) {
> if (i >= ARRAY_SIZE(iio_ev_info_text))
> return -EINVAL;
> - if (dir != IIO_EV_DIR_NONE)
> - postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
> - iio_ev_type_text[type],
> - iio_ev_dir_text[dir],
> - iio_ev_info_text[i]);
> - else
> + if (dir != IIO_EV_DIR_NONE) {
> + if (i == IIO_EV_INFO_ENABLE)
> + postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
> + iio_ev_type_text[type],
> + iio_ev_dir_text[dir],
> + iio_ev_info_text[i]);
> + else
> + postfix = kasprintf(GFP_KERNEL, "%s_%s_%s_%s",
> + iio_ev_unit_text[unit],
> + iio_ev_type_text[type],
> + iio_ev_dir_text[dir],
> + iio_ev_info_text[i]);
> + } else {
I think that the units only make sense on IIO_EV_INFO_VALUE and
IIO_EV_INFO_HYSTERESIS. Everything else has it's own unit, not just
IIO_EV_INFO_ENABLE.
> postfix = kasprintf(GFP_KERNEL, "%s_%s",
> iio_ev_type_text[type],
> iio_ev_info_text[i]);
> + }
> if (postfix == NULL)
> return -ENOMEM;
>
Powered by blists - more mailing lists