aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ad7887.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/adc/ad7887.c')
-rw-r--r--drivers/iio/adc/ad7887.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 749a6cadab8b..2fd012ee99f5 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -15,6 +15,7 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/bitops.h>
18 19
19#include <linux/iio/iio.h> 20#include <linux/iio/iio.h>
20#include <linux/iio/sysfs.h> 21#include <linux/iio/sysfs.h>
@@ -25,14 +26,14 @@
25 26
26#include <linux/platform_data/ad7887.h> 27#include <linux/platform_data/ad7887.h>
27 28
28#define AD7887_REF_DIS (1 << 5) /* on-chip reference disable */ 29#define AD7887_REF_DIS BIT(5) /* on-chip reference disable */
29#define AD7887_DUAL (1 << 4) /* dual-channel mode */ 30#define AD7887_DUAL BIT(4) /* dual-channel mode */
30#define AD7887_CH_AIN1 (1 << 3) /* convert on channel 1, DUAL=1 */ 31#define AD7887_CH_AIN1 BIT(3) /* convert on channel 1, DUAL=1 */
31#define AD7887_CH_AIN0 (0 << 3) /* convert on channel 0, DUAL=0,1 */ 32#define AD7887_CH_AIN0 0 /* convert on channel 0, DUAL=0,1 */
32#define AD7887_PM_MODE1 (0) /* CS based shutdown */ 33#define AD7887_PM_MODE1 0 /* CS based shutdown */
33#define AD7887_PM_MODE2 (1) /* full on */ 34#define AD7887_PM_MODE2 1 /* full on */
34#define AD7887_PM_MODE3 (2) /* auto shutdown after conversion */ 35#define AD7887_PM_MODE3 2 /* auto shutdown after conversion */
35#define AD7887_PM_MODE4 (3) /* standby mode */ 36#define AD7887_PM_MODE4 3 /* standby mode */
36 37
37enum ad7887_channels { 38enum ad7887_channels {
38 AD7887_CH0, 39 AD7887_CH0,
@@ -40,8 +41,6 @@ enum ad7887_channels {
40 AD7887_CH1, 41 AD7887_CH1,
41}; 42};
42 43
43#define RES_MASK(bits) ((1 << (bits)) - 1)
44
45/** 44/**
46 * struct ad7887_chip_info - chip specifc information 45 * struct ad7887_chip_info - chip specifc information
47 * @int_vref_mv: the internal reference voltage 46 * @int_vref_mv: the internal reference voltage
@@ -167,7 +166,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
167 if (ret < 0) 166 if (ret < 0)
168 return ret; 167 return ret;
169 *val = ret >> chan->scan_type.shift; 168 *val = ret >> chan->scan_type.shift;
170 *val &= RES_MASK(chan->scan_type.realbits); 169 *val &= GENMASK(chan->scan_type.realbits - 1, 0);
171 return IIO_VAL_INT; 170 return IIO_VAL_INT;
172 case IIO_CHAN_INFO_SCALE: 171 case IIO_CHAN_INFO_SCALE:
173 if (st->reg) { 172 if (st->reg) {