aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/iio/cdc/ad7150.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index dd7fcab8e19e..e075244c602b 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -5,6 +5,7 @@
5 * Copyright 2010-2011 Analog Devices Inc. 5 * Copyright 2010-2011 Analog Devices Inc.
6 */ 6 */
7 7
8#include <linux/bitfield.h>
8#include <linux/interrupt.h> 9#include <linux/interrupt.h>
9#include <linux/device.h> 10#include <linux/device.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -130,7 +131,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev,
130{ 131{
131 int ret; 132 int ret;
132 u8 threshtype; 133 u8 threshtype;
133 bool adaptive; 134 bool thrfixed;
134 struct ad7150_chip_info *chip = iio_priv(indio_dev); 135 struct ad7150_chip_info *chip = iio_priv(indio_dev);
135 136
136 ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); 137 ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG);
@@ -138,21 +139,23 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev,
138 return ret; 139 return ret;
139 140
140 threshtype = (ret >> 5) & 0x03; 141 threshtype = (ret >> 5) & 0x03;
141 adaptive = !!(ret & 0x80); 142
143 /*check if threshold mode is fixed or adaptive*/
144 thrfixed = FIELD_GET(AD7150_CFG_FIX, ret);
142 145
143 switch (type) { 146 switch (type) {
144 case IIO_EV_TYPE_MAG_ADAPTIVE: 147 case IIO_EV_TYPE_MAG_ADAPTIVE:
145 if (dir == IIO_EV_DIR_RISING) 148 if (dir == IIO_EV_DIR_RISING)
146 return adaptive && (threshtype == 0x1); 149 return !thrfixed && (threshtype == 0x1);
147 return adaptive && (threshtype == 0x0); 150 return !thrfixed && (threshtype == 0x0);
148 case IIO_EV_TYPE_THRESH_ADAPTIVE: 151 case IIO_EV_TYPE_THRESH_ADAPTIVE:
149 if (dir == IIO_EV_DIR_RISING) 152 if (dir == IIO_EV_DIR_RISING)
150 return adaptive && (threshtype == 0x3); 153 return !thrfixed && (threshtype == 0x3);
151 return adaptive && (threshtype == 0x2); 154 return !thrfixed && (threshtype == 0x2);
152 case IIO_EV_TYPE_THRESH: 155 case IIO_EV_TYPE_THRESH:
153 if (dir == IIO_EV_DIR_RISING) 156 if (dir == IIO_EV_DIR_RISING)
154 return !adaptive && (threshtype == 0x1); 157 return thrfixed && (threshtype == 0x1);
155 return !adaptive && (threshtype == 0x0); 158 return thrfixed && (threshtype == 0x0);
156 default: 159 default:
157 break; 160 break;
158 } 161 }