diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2014-12-06 06:00:00 +0000 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-06-14 16:04:24 +0100 |
commit | 488980532de968d4002262394817bf08709cab97 (patch) | |
tree | ddec29305b50fa3ef48e6a14de6f079535478ce7 /drivers/iio/adc | |
parent | bc74fb8191c0405e17925473e940db65be1b80e7 (diff) | |
download | op-kernel-dev-488980532de968d4002262394817bf08709cab97.zip op-kernel-dev-488980532de968d4002262394817bf08709cab97.tar.gz |
iio:adc:ad7298: Use BIT() and GENMASK() macros
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r-- | drivers/iio/adc/ad7298.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 2a3b65c..4a8c0a2 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -16,6 +16,7 @@ #include <linux/delay.h> #include <linux/module.h> #include <linux/interrupt.h> +#include <linux/bitops.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> @@ -25,23 +26,19 @@ #include <linux/platform_data/ad7298.h> -#define AD7298_WRITE (1 << 15) /* write to the control register */ -#define AD7298_REPEAT (1 << 14) /* repeated conversion enable */ -#define AD7298_CH(x) (1 << (13 - (x))) /* channel select */ -#define AD7298_TSENSE (1 << 5) /* temperature conversion enable */ -#define AD7298_EXTREF (1 << 2) /* external reference enable */ -#define AD7298_TAVG (1 << 1) /* temperature sensor averaging enable */ -#define AD7298_PDD (1 << 0) /* partial power down enable */ +#define AD7298_WRITE BIT(15) /* write to the control register */ +#define AD7298_REPEAT BIT(14) /* repeated conversion enable */ +#define AD7298_CH(x) BIT(13 - (x)) /* channel select */ +#define AD7298_TSENSE BIT(5) /* temperature conversion enable */ +#define AD7298_EXTREF BIT(2) /* external reference enable */ +#define AD7298_TAVG BIT(1) /* temperature sensor averaging enable */ +#define AD7298_PDD BIT(0) /* partial power down enable */ #define AD7298_MAX_CHAN 8 -#define AD7298_BITS 12 -#define AD7298_STORAGE_BITS 16 #define AD7298_INTREF_mV 2500 #define AD7298_CH_TEMP 9 -#define RES_MASK(bits) ((1 << (bits)) - 1) - struct ad7298_state { struct spi_device *spi; struct regulator *reg; @@ -257,7 +254,7 @@ static int ad7298_read_raw(struct iio_dev *indio_dev, return ret; if (chan->address != AD7298_CH_TEMP) - *val = ret & RES_MASK(AD7298_BITS); + *val = ret & GENMASK(chan->scan_type.realbits - 1, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: |