iio: adc: ad7780: define/use own IIO channel macros
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Sat, 21 Mar 2020 09:07:58 +0000 (11:07 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Apr 2020 15:56:10 +0000 (16:56 +0100)
This change gets rid of the AD_SD_*_CHANNEL macros in favor of defining
it's own. The ad7780 is quite simpler than it's other Sigma-Delta brothers.

It turned out that centralizing the AD_SD_*_CHANNEL macros doesn't scale
too well, especially with some more complicated drivers. Some of the
variations in the more complicated drivers require new macros, and that way
things can become harder to maintain.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7780.c

index 291c1a898129d22cfc51de34325fb5762ff61ee0..f47606ebbbbef489c42586e00e290705c838f57b 100644 (file)
@@ -206,10 +206,29 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
        .irq_flags = IRQF_TRIGGER_LOW,
 };
 
-#define AD7780_CHANNEL(bits, wordsize) \
-       AD_SD_CHANNEL(1, 0, 0, bits, 32, (wordsize) - (bits))
-#define AD7170_CHANNEL(bits, wordsize) \
-       AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, (wordsize) - (bits))
+#define _AD7780_CHANNEL(_bits, _wordsize, _mask_all)           \
+{                                                              \
+       .type = IIO_VOLTAGE,                                    \
+       .indexed = 1,                                           \
+       .channel = 0,                                           \
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |          \
+               BIT(IIO_CHAN_INFO_OFFSET),                      \
+       .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+       .info_mask_shared_by_all = _mask_all,                   \
+       .scan_index = 1,                                        \
+       .scan_type = {                                          \
+               .sign = 'u',                                    \
+               .realbits = (_bits),                            \
+               .storagebits = 32,                              \
+               .shift = (_wordsize) - (_bits),                 \
+               .endianness = IIO_BE,                           \
+       },                                                      \
+}
+
+#define AD7780_CHANNEL(_bits, _wordsize)       \
+       _AD7780_CHANNEL(_bits, _wordsize, BIT(IIO_CHAN_INFO_SAMP_FREQ))
+#define AD7170_CHANNEL(_bits, _wordsize)       \
+       _AD7780_CHANNEL(_bits, _wordsize, 0)
 
 static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
        [ID_AD7170] = {