46
46
* Note that when reading the sensor actually 84 edges are detected, but
47
47
* since the last edge is not significant, we only store 83:
48
48
*/
49
- #define DHT11_EDGES_PER_READ (2*DHT11_BITS_PER_READ + DHT11_EDGES_PREAMBLE + 1)
49
+ #define DHT11_EDGES_PER_READ (2 * DHT11_BITS_PER_READ + \
50
+ DHT11_EDGES_PREAMBLE + 1)
50
51
51
52
/* Data transmission timing (nano seconds) */
52
53
#define DHT11_START_TRANSMISSION 18 /* ms */
@@ -95,24 +96,24 @@ static int dht11_decode(struct dht11 *dht11, int offset)
95
96
96
97
/* Calculate timestamp resolution */
97
98
for (i = 1 ; i < dht11 -> num_edges ; ++ i ) {
98
- t = dht11 -> edges [i ].ts - dht11 -> edges [i - 1 ].ts ;
99
+ t = dht11 -> edges [i ].ts - dht11 -> edges [i - 1 ].ts ;
99
100
if (t > 0 && t < timeres )
100
101
timeres = t ;
101
102
}
102
- if (2 * timeres > DHT11_DATA_BIT_HIGH ) {
103
+ if (2 * timeres > DHT11_DATA_BIT_HIGH ) {
103
104
pr_err ("dht11: timeresolution %d too bad for decoding\n" ,
104
- timeres );
105
+ timeres );
105
106
return - EIO ;
106
107
}
107
108
threshold = DHT11_DATA_BIT_HIGH / timeres ;
108
- if (DHT11_DATA_BIT_LOW / timeres + 1 >= threshold )
109
+ if (DHT11_DATA_BIT_LOW / timeres + 1 >= threshold )
109
110
pr_err ("dht11: WARNING: decoding ambiguous\n" );
110
111
111
112
/* scale down with timeres and check validity */
112
113
for (i = 0 ; i < DHT11_BITS_PER_READ ; ++ i ) {
113
- t = dht11 -> edges [offset + 2 * i + 2 ].ts -
114
- dht11 -> edges [offset + 2 * i + 1 ].ts ;
115
- if (!dht11 -> edges [offset + 2 * i + 1 ].value )
114
+ t = dht11 -> edges [offset + 2 * i + 2 ].ts -
115
+ dht11 -> edges [offset + 2 * i + 1 ].ts ;
116
+ if (!dht11 -> edges [offset + 2 * i + 1 ].value )
116
117
return - EIO ; /* lost synchronisation */
117
118
timing [i ] = t / timeres ;
118
119
}
@@ -166,7 +167,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)
166
167
}
167
168
168
169
static int dht11_read_raw (struct iio_dev * iio_dev ,
169
- const struct iio_chan_spec * chan ,
170
+ const struct iio_chan_spec * chan ,
170
171
int * val , int * val2 , long m )
171
172
{
172
173
struct dht11 * dht11 = iio_priv (iio_dev );
@@ -192,21 +193,21 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
192
193
goto err ;
193
194
194
195
ret = wait_for_completion_killable_timeout (& dht11 -> completion ,
195
- HZ );
196
+ HZ );
196
197
197
198
free_irq (dht11 -> irq , iio_dev );
198
199
199
200
if (ret == 0 && dht11 -> num_edges < DHT11_EDGES_PER_READ - 1 ) {
200
201
dev_err (& iio_dev -> dev ,
201
- "Only %d signal edges detected\n" ,
202
+ "Only %d signal edges detected\n" ,
202
203
dht11 -> num_edges );
203
204
ret = - ETIMEDOUT ;
204
205
}
205
206
if (ret < 0 )
206
207
goto err ;
207
208
208
209
ret = dht11_decode (dht11 ,
209
- dht11 -> num_edges == DHT11_EDGES_PER_READ ?
210
+ dht11 -> num_edges == DHT11_EDGES_PER_READ ?
210
211
DHT11_EDGES_PREAMBLE :
211
212
DHT11_EDGES_PREAMBLE - 2 );
212
213
if (ret )
0 commit comments