Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: adc: ad7280a: use IIO_DIFF_EVENT_CODE macro helper

The IIO_DIFF_EVENT_CODE macro helper was introduced to provide a more
specific alternative to the generic IIO_EVENT_CODE macro for handling
differential channels. This commit updates the code to use
IIO_DIFF_EVENT_CODE for better clarity and maintainability.

However, the current implementation 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>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-2-b452c90f7ea6@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Julien Stephan and committed by
Jonathan Cameron
7f4f3c4e 5d8173b8

+6 -8
+6 -8
drivers/iio/adc/ad7280a.c
··· 822 822 if (FIELD_GET(AD7280A_TRANS_READ_CONV_CHANADDR_MSK, channels[i]) <= 823 823 AD7280A_CELL_VOLTAGE_6_REG) { 824 824 if (val >= st->cell_threshhigh) { 825 - u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, 826 - IIO_EV_DIR_RISING, 827 - IIO_EV_TYPE_THRESH, 828 - 0, 0, 0); 825 + u64 tmp = IIO_DIFF_EVENT_CODE(IIO_VOLTAGE, 0, 0, 826 + IIO_EV_TYPE_THRESH, 827 + IIO_EV_DIR_RISING); 829 828 iio_push_event(indio_dev, tmp, 830 829 iio_get_time_ns(indio_dev)); 831 830 } else if (val <= st->cell_threshlow) { 832 - u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, 833 - IIO_EV_DIR_FALLING, 834 - IIO_EV_TYPE_THRESH, 835 - 0, 0, 0); 831 + u64 tmp = IIO_DIFF_EVENT_CODE(IIO_VOLTAGE, 0, 0, 832 + IIO_EV_TYPE_THRESH, 833 + IIO_EV_DIR_FALLING); 836 834 iio_push_event(indio_dev, tmp, 837 835 iio_get_time_ns(indio_dev)); 838 836 }