Create macro for capacitance channels in order to remove the repeated
code and improve its readability.

Signed-off-by: Bárbara Fernandes <barbara.fernan...@usp.br>
Signed-off-by: Wilson Sales <spo...@spoonm.org>
Co-developed-by: Wilson Sales <spo...@spoonm.org>
---
 drivers/staging/iio/cdc/ad7150.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index 072094227e1b..d8c43cabce25 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -468,24 +468,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)
 };
 
 /*
-- 
2.22.0.rc0.1.g337bb99195.dirty

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to