Skip to content

Commit cfa71bf

Browse files
Hartmut Knaackjic23
authored andcommitted
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>
1 parent 8a32f65 commit cfa71bf

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

‎drivers/staging/iio/adc/ad7291.c‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@
6868
*/
6969
#define AD7291_VALUE_MASK GENMASK(11, 0)
7070

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+
7182
struct ad7291_chip_info {
7283
struct i2c_client *client;
7384
struct regulator *reg;
@@ -122,33 +133,33 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
122133
ad7291_i2c_write(chip, AD7291_COMMAND, command);
123134

124135
/* 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))
126137
iio_push_event(indio_dev,
127138
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
128139
0,
129140
IIO_EV_TYPE_THRESH,
130141
IIO_EV_DIR_FALLING),
131142
timestamp);
132-
if ((t_status & (1 << 1)) || (t_status & (1 << 3)))
143+
if ((t_status & AD7291_T_HIGH) || (t_status & AD7291_T_AVG_HIGH))
133144
iio_push_event(indio_dev,
134145
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
135146
0,
136147
IIO_EV_TYPE_THRESH,
137148
IIO_EV_DIR_RISING),
138149
timestamp);
139150

140-
for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) {
141-
if (v_status & (1 << i))
151+
for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) {
152+
if (v_status & AD7291_V_LOW(i))
142153
iio_push_event(indio_dev,
143154
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
144-
i/2,
155+
i,
145156
IIO_EV_TYPE_THRESH,
146157
IIO_EV_DIR_FALLING),
147158
timestamp);
148-
if (v_status & (1 << (i + 1)))
159+
if (v_status & AD7291_V_HIGH(i))
149160
iio_push_event(indio_dev,
150161
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
151-
i/2,
162+
i,
152163
IIO_EV_TYPE_THRESH,
153164
IIO_EV_DIR_RISING),
154165
timestamp);

0 commit comments

Comments
 (0)