aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2014-12-06 01:00:00 -0500
committerJonathan Cameron <jic23@kernel.org>2014-06-14 11:04:24 -0400
commit488980532de968d4002262394817bf08709cab97 (patch)
treeddec29305b50fa3ef48e6a14de6f079535478ce7 /drivers/iio
parentbc74fb8191c0405e17925473e940db65be1b80e7 (diff)
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')
-rw-r--r--drivers/iio/adc/ad7298.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 2a3b65c74af9..4a8c0a2f49b6 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/bitops.h>
19 20
20#include <linux/iio/iio.h> 21#include <linux/iio/iio.h>
21#include <linux/iio/sysfs.h> 22#include <linux/iio/sysfs.h>
@@ -25,23 +26,19 @@
25 26
26#include <linux/platform_data/ad7298.h> 27#include <linux/platform_data/ad7298.h>
27 28
28#define AD7298_WRITE (1 << 15) /* write to the control register */ 29#define AD7298_WRITE BIT(15) /* write to the control register */
29#define AD7298_REPEAT (1 << 14) /* repeated conversion enable */ 30#define AD7298_REPEAT BIT(14) /* repeated conversion enable */
30#define AD7298_CH(x) (1 << (13 - (x))) /* channel select */ 31#define AD7298_CH(x) BIT(13 - (x)) /* channel select */
31#define AD7298_TSENSE (1 << 5) /* temperature conversion enable */ 32#define AD7298_TSENSE BIT(5) /* temperature conversion enable */
32#define AD7298_EXTREF (1 << 2) /* external reference enable */ 33#define AD7298_EXTREF BIT(2) /* external reference enable */
33#define AD7298_TAVG (1 << 1) /* temperature sensor averaging enable */ 34#define AD7298_TAVG BIT(1) /* temperature sensor averaging enable */
34#define AD7298_PDD (1 << 0) /* partial power down enable */ 35#define AD7298_PDD BIT(0) /* partial power down enable */
35 36
36#define AD7298_MAX_CHAN 8 37#define AD7298_MAX_CHAN 8
37#define AD7298_BITS 12
38#define AD7298_STORAGE_BITS 16
39#define AD7298_INTREF_mV 2500 38#define AD7298_INTREF_mV 2500
40 39
41#define AD7298_CH_TEMP 9 40#define AD7298_CH_TEMP 9
42 41
43#define RES_MASK(bits) ((1 << (bits)) - 1)
44
45struct ad7298_state { 42struct ad7298_state {
46 struct spi_device *spi; 43 struct spi_device *spi;
47 struct regulator *reg; 44 struct regulator *reg;
@@ -257,7 +254,7 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
257 return ret; 254 return ret;
258 255
259 if (chan->address != AD7298_CH_TEMP) 256 if (chan->address != AD7298_CH_TEMP)
260 *val = ret & RES_MASK(AD7298_BITS); 257 *val = ret & GENMASK(chan->scan_type.realbits - 1, 0);
261 258
262 return IIO_VAL_INT; 259 return IIO_VAL_INT;
263 case IIO_CHAN_INFO_SCALE: 260 case IIO_CHAN_INFO_SCALE: