Skip to content

Commit 5d8173b

Browse files
justephjic23
authored andcommitted
iio: events.h: add event identifier macros for differential channel
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). To prevent such issues in future drivers, a new helper macro, IIO_DIFF_EVENT_CODE, is introduced to specifically create event identifiers for differential channels. 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, Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-1-b452c90f7ea6@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 3c9b6fd commit 5d8173b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

include/linux/iio/events.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030

3131

3232
/**
33-
* IIO_MOD_EVENT_CODE() - create event identifier for modified channels
33+
* IIO_MOD_EVENT_CODE() - create event identifier for modified (non
34+
* differential) channels
3435
* @chan_type: Type of the channel. Should be one of enum iio_chan_type.
3536
* @number: Channel number.
3637
* @modifier: Modifier for the channel. Should be one of enum iio_modifier.
@@ -43,7 +44,8 @@
4344
IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
4445

4546
/**
46-
* IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
47+
* IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified (non
48+
* differential) channels
4749
* @chan_type: Type of the channel. Should be one of enum iio_chan_type.
4850
* @number: Channel number.
4951
* @type: Type of the event. Should be one of enum iio_event_type.
@@ -53,4 +55,16 @@
5355
#define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \
5456
IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
5557

58+
/**
59+
* IIO_DIFF_EVENT_CODE() - create event identifier for differential channels
60+
* @chan_type: Type of the channel. Should be one of enum iio_chan_type.
61+
* @chan1: First channel number for differential channels.
62+
* @chan2: Second channel number for differential channels.
63+
* @type: Type of the event. Should be one of enum iio_event_type.
64+
* @direction: Direction of the event. One of enum iio_event_direction.
65+
*/
66+
67+
#define IIO_DIFF_EVENT_CODE(chan_type, chan1, chan2, type, direction) \
68+
IIO_EVENT_CODE(chan_type, 1, 0, direction, type, 0, chan1, chan2)
69+
5670
#endif

0 commit comments

Comments
 (0)