diff options
author | Martin Kepplinger <martink@posteo.de> | 2015-12-15 11:45:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-12-19 11:45:42 -0500 |
commit | e60378c17c7eebf8636fb6831bff1efc9a434521 (patch) | |
tree | 4ea501819dc55b2c359f4ad2504b707f38a7a2e1 | |
parent | 8e34f2c8d2688a84f516d698aa8a8438a668265f (diff) |
iio: mma8452: use enum for channel index
This gets rid of some magic numbers by adding an enum.
Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/accel/mma8452.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 162bbef8139f..ccc632a7cf01 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c | |||
@@ -143,6 +143,13 @@ struct mma_chip_info { | |||
143 | u8 ev_count; | 143 | u8 ev_count; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | enum { | ||
147 | idx_x, | ||
148 | idx_y, | ||
149 | idx_z, | ||
150 | idx_ts, | ||
151 | }; | ||
152 | |||
146 | static int mma8452_drdy(struct mma8452_data *data) | 153 | static int mma8452_drdy(struct mma8452_data *data) |
147 | { | 154 | { |
148 | int tries = 150; | 155 | int tries = 150; |
@@ -816,31 +823,31 @@ static struct attribute_group mma8452_event_attribute_group = { | |||
816 | } | 823 | } |
817 | 824 | ||
818 | static const struct iio_chan_spec mma8452_channels[] = { | 825 | static const struct iio_chan_spec mma8452_channels[] = { |
819 | MMA8452_CHANNEL(X, 0, 12), | 826 | MMA8452_CHANNEL(X, idx_x, 12), |
820 | MMA8452_CHANNEL(Y, 1, 12), | 827 | MMA8452_CHANNEL(Y, idx_y, 12), |
821 | MMA8452_CHANNEL(Z, 2, 12), | 828 | MMA8452_CHANNEL(Z, idx_z, 12), |
822 | IIO_CHAN_SOFT_TIMESTAMP(3), | 829 | IIO_CHAN_SOFT_TIMESTAMP(idx_ts), |
823 | }; | 830 | }; |
824 | 831 | ||
825 | static const struct iio_chan_spec mma8453_channels[] = { | 832 | static const struct iio_chan_spec mma8453_channels[] = { |
826 | MMA8452_CHANNEL(X, 0, 10), | 833 | MMA8452_CHANNEL(X, idx_x, 10), |
827 | MMA8452_CHANNEL(Y, 1, 10), | 834 | MMA8452_CHANNEL(Y, idx_y, 10), |
828 | MMA8452_CHANNEL(Z, 2, 10), | 835 | MMA8452_CHANNEL(Z, idx_z, 10), |
829 | IIO_CHAN_SOFT_TIMESTAMP(3), | 836 | IIO_CHAN_SOFT_TIMESTAMP(idx_ts), |
830 | }; | 837 | }; |
831 | 838 | ||
832 | static const struct iio_chan_spec mma8652_channels[] = { | 839 | static const struct iio_chan_spec mma8652_channels[] = { |
833 | MMA8652_CHANNEL(X, 0, 12), | 840 | MMA8652_CHANNEL(X, idx_x, 12), |
834 | MMA8652_CHANNEL(Y, 1, 12), | 841 | MMA8652_CHANNEL(Y, idx_y, 12), |
835 | MMA8652_CHANNEL(Z, 2, 12), | 842 | MMA8652_CHANNEL(Z, idx_z, 12), |
836 | IIO_CHAN_SOFT_TIMESTAMP(3), | 843 | IIO_CHAN_SOFT_TIMESTAMP(idx_ts), |
837 | }; | 844 | }; |
838 | 845 | ||
839 | static const struct iio_chan_spec mma8653_channels[] = { | 846 | static const struct iio_chan_spec mma8653_channels[] = { |
840 | MMA8652_CHANNEL(X, 0, 10), | 847 | MMA8652_CHANNEL(X, idx_x, 10), |
841 | MMA8652_CHANNEL(Y, 1, 10), | 848 | MMA8652_CHANNEL(Y, idx_y, 10), |
842 | MMA8652_CHANNEL(Z, 2, 10), | 849 | MMA8652_CHANNEL(Z, idx_z, 10), |
843 | IIO_CHAN_SOFT_TIMESTAMP(3), | 850 | IIO_CHAN_SOFT_TIMESTAMP(idx_ts), |
844 | }; | 851 | }; |
845 | 852 | ||
846 | enum { | 853 | enum { |