aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ad7298.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-18 23:02:33 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-18 23:02:33 -0400
commitf641f66784351d0266817301158d7171df6eec20 (patch)
treec2ef5a87a5243fe732cd69266c3e16a155c2431b /drivers/iio/adc/ad7298.c
parent98e11370052aa88a38c2d5d1693a5ec2966c4f81 (diff)
parent88f6da779a37a3579e580296776ba86d6c6bd980 (diff)
Merge tag 'iio-for-3.17a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes: First round of new drivers, cleanups and functionality for the 3.17 cycle. New drivers * t5403 barometric pressure sensor * kxcjk1013 accelerometer (with a locking followup fix). * ak09911 digital compass Documentation * ABI docs for proximity added (interface has been there a long time but somehow snuck through without being documented) * Move iio-trig-sysfs documentation out of staging (got left behind when the driver moved some time ago). Cleanups * drop the timestamp argument from iio_trigger_poll(_chained) as nothing has been done with it for some time. * ad799x kerneldoc for ad799x_chip brought up to date. * replace a number of reimplementations of the GENMASK macro and use the BIT macro to cleanup a few locations. * bring the iio_event_monitor example program up to date with new device types. * fix some incorrect function prototypes in iio_utils.h example code. * INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED fix in docs. This got left behind after we renamed it a long time back. * fix error handling in the generic_buffer example program. * small tidy ups in the iio-trig-periodic-rtc driver. * Allow reseting iio-trig-periodic-rtc frequency to 0 (default) after it has changed. * Trivial tidy ups in coding style in iio_simply_dummy
Diffstat (limited to 'drivers/iio/adc/ad7298.c')
-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: