staging: iio: cdc: ad7150: create macro for capacitance channels
authorBárbara Fernandes <barbara.fernandes@usp.br>
Sat, 18 May 2019 22:41:36 +0000 (19:41 -0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 26 May 2019 14:52:17 +0000 (15:52 +0100)
Create macro for capacitance channels in order to remove the repeated
code and improve its readability.

Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Signed-off-by: Wilson Sales <spoonm@spoonm.org>
Co-developed-by: Wilson Sales <spoonm@spoonm.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/cdc/ad7150.c

index dd7fcab8e19e1c82f79fde07d8e08e5a8cf74387..8234da4b8c652335d262150f87d04e759c074183 100644 (file)
@@ -465,24 +465,19 @@ static const struct iio_event_spec ad7150_events[] = {
        },
 };
 
+#define AD7150_CAPACITANCE_CHAN(_chan) {                       \
+               .type = IIO_CAPACITANCE,                        \
+               .indexed = 1,                                   \
+               .channel = _chan,                               \
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |  \
+               BIT(IIO_CHAN_INFO_AVERAGE_RAW),                 \
+               .event_spec = ad7150_events,                    \
+               .num_event_specs = ARRAY_SIZE(ad7150_events),   \
+       }
+
 static const struct iio_chan_spec ad7150_channels[] = {
-       {
-               .type = IIO_CAPACITANCE,
-               .indexed = 1,
-               .channel = 0,
-               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-               BIT(IIO_CHAN_INFO_AVERAGE_RAW),
-               .event_spec = ad7150_events,
-               .num_event_specs = ARRAY_SIZE(ad7150_events),
-       }, {
-               .type = IIO_CAPACITANCE,
-               .indexed = 1,
-               .channel = 1,
-               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-               BIT(IIO_CHAN_INFO_AVERAGE_RAW),
-               .event_spec = ad7150_events,
-               .num_event_specs = ARRAY_SIZE(ad7150_events),
-       },
+       AD7150_CAPACITANCE_CHAN(0),
+       AD7150_CAPACITANCE_CHAN(1)
 };
 
 /*