diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2014-08-07 07:06:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-07-08 16:16:32 -0400 |
commit | cfa71bf35c87c79ad9a03a29a7426b495446b2bf (patch) | |
tree | 197531f962c1ace411c34ca9bb41559f428a4ff1 | |
parent | 8a32f65f389396267ae50a78d3416bcac5d4d959 (diff) |
staging:iio:ad7291 define alert register bits
Define some names for alert register bits and apply them to
ad7291_event_handler().
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/adc/ad7291.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 40f1cea25e1f..9139958da787 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c | |||
@@ -68,6 +68,17 @@ | |||
68 | */ | 68 | */ |
69 | #define AD7291_VALUE_MASK GENMASK(11, 0) | 69 | #define AD7291_VALUE_MASK GENMASK(11, 0) |
70 | 70 | ||
71 | /* | ||
72 | * AD7291 alert register bits | ||
73 | */ | ||
74 | #define AD7291_T_LOW BIT(0) | ||
75 | #define AD7291_T_HIGH BIT(1) | ||
76 | #define AD7291_T_AVG_LOW BIT(2) | ||
77 | #define AD7291_T_AVG_HIGH BIT(3) | ||
78 | #define AD7291_V_LOW(x) BIT((x) * 2) | ||
79 | #define AD7291_V_HIGH(x) BIT((x) * 2 + 1) | ||
80 | |||
81 | |||
71 | struct ad7291_chip_info { | 82 | struct ad7291_chip_info { |
72 | struct i2c_client *client; | 83 | struct i2c_client *client; |
73 | struct regulator *reg; | 84 | struct regulator *reg; |
@@ -122,14 +133,14 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) | |||
122 | ad7291_i2c_write(chip, AD7291_COMMAND, command); | 133 | ad7291_i2c_write(chip, AD7291_COMMAND, command); |
123 | 134 | ||
124 | /* For now treat t_sense and t_sense_average the same */ | 135 | /* For now treat t_sense and t_sense_average the same */ |
125 | if ((t_status & (1 << 0)) || (t_status & (1 << 2))) | 136 | if ((t_status & AD7291_T_LOW) || (t_status & AD7291_T_AVG_LOW)) |
126 | iio_push_event(indio_dev, | 137 | iio_push_event(indio_dev, |
127 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, | 138 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, |
128 | 0, | 139 | 0, |
129 | IIO_EV_TYPE_THRESH, | 140 | IIO_EV_TYPE_THRESH, |
130 | IIO_EV_DIR_FALLING), | 141 | IIO_EV_DIR_FALLING), |
131 | timestamp); | 142 | timestamp); |
132 | if ((t_status & (1 << 1)) || (t_status & (1 << 3))) | 143 | if ((t_status & AD7291_T_HIGH) || (t_status & AD7291_T_AVG_HIGH)) |
133 | iio_push_event(indio_dev, | 144 | iio_push_event(indio_dev, |
134 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, | 145 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, |
135 | 0, | 146 | 0, |
@@ -137,18 +148,18 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) | |||
137 | IIO_EV_DIR_RISING), | 148 | IIO_EV_DIR_RISING), |
138 | timestamp); | 149 | timestamp); |
139 | 150 | ||
140 | for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) { | 151 | for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) { |
141 | if (v_status & (1 << i)) | 152 | if (v_status & AD7291_V_LOW(i)) |
142 | iio_push_event(indio_dev, | 153 | iio_push_event(indio_dev, |
143 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, | 154 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, |
144 | i/2, | 155 | i, |
145 | IIO_EV_TYPE_THRESH, | 156 | IIO_EV_TYPE_THRESH, |
146 | IIO_EV_DIR_FALLING), | 157 | IIO_EV_DIR_FALLING), |
147 | timestamp); | 158 | timestamp); |
148 | if (v_status & (1 << (i + 1))) | 159 | if (v_status & AD7291_V_HIGH(i)) |
149 | iio_push_event(indio_dev, | 160 | iio_push_event(indio_dev, |
150 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, | 161 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, |
151 | i/2, | 162 | i, |
152 | IIO_EV_TYPE_THRESH, | 163 | IIO_EV_TYPE_THRESH, |
153 | IIO_EV_DIR_RISING), | 164 | IIO_EV_DIR_RISING), |
154 | timestamp); | 165 | timestamp); |