[PATCH 0/2] iio: events.h: add event identifier macros for differential channel

Julien Stephan posted 2 patches 3 weeks, 6 days ago
drivers/iio/adc/ad7280a.c  | 14 ++++++--------
include/linux/iio/events.h | 18 ++++++++++++++++--
2 files changed, 22 insertions(+), 10 deletions(-)
[PATCH 0/2] iio: events.h: add event identifier macros for differential channel
Posted by Julien Stephan 3 weeks, 6 days ago
Hello,

This series adds a a new helper macro, IIO_DIFF_EVENT_CODE, to
specifically create event identifiers for differential channel.

Indeed, currently, there are 3 helper macros in iio/events.h to create
event identifiers:
- IIO_EVENT_CODE : create generic event identifier for differential and non
  differential channels
- IIO_MOD_EVENT_CODE : create event identifier for modified (non
  differential) channels
- IIO_UNMOD_EVENT_CODE : create event identifier for unmodified (non
  differential) channels

For differential channels, drivers are expected to use IIO_EVENT_CODE.
However, only one driver in drivers/iio currently uses it correctly,
leading to inconsistent event identifiers for differential channels that
don’t match the intended attributes (such as max1363.c that supports
differential channels, but only uses IIO_UNMOD_EVENT_CODE).

Adding this new macro to prevent such issues in future drivers.
Only one helper is needed for differential channels since they cannot have
modifiers.

Additionally, the descriptions for IIO_MOD_EVENT_CODE and
IIO_UNMOD_EVENT_CODE have been updated to clarify that they are intended
for non-differential channels,

This series also fix ad7280a driver to use the new helper.
However, the current implementation in ad7280a incorrectly sets both
chan1 and chan2 to 0. To maintain compatibility and avoid breaking
existing user space applications, this behavior is preserved for now.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
Julien Stephan (2):
      iio: events.h: add event identifier macros for differential channel
      iio: adc: ad7280a: use IIO_DIFF_EVENT_CODE macro helper

 drivers/iio/adc/ad7280a.c  | 14 ++++++--------
 include/linux/iio/events.h | 18 ++++++++++++++++--
 2 files changed, 22 insertions(+), 10 deletions(-)
---
base-commit: 9090ececac9ff1e22fb7e042f3c886990a8fb090
change-id: 20241024-iio-add-macro-for-even-identifier-for-differential-channels-1bd8afdacf42

Best regards,
-- 
Julien Stephan <jstephan@baylibre.com>

Re: [PATCH 0/2] iio: events.h: add event identifier macros for differential channel
Posted by David Lechner 3 weeks, 6 days ago
On 10/28/24 11:38 AM, Julien Stephan wrote:
> Hello,
> 
> This series adds a a new helper macro, IIO_DIFF_EVENT_CODE, to
> specifically create event identifiers for differential channel.
> 
Reviewed-by: David Lechner <dlechner@baylibre.com>