summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorHarald Geyer <harald@ccbib.org>2018-02-11 12:09:40 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-02-17 13:03:16 +0100
commita6bffb6920d16fb2ef4ba072fac5b64b36b1c254 (patch)
treec78fa9fce5d4f2c43082c5e40b6d3fb4946896e5 /drivers/iio
parentstaging: ade7759: Fix open parenthesis alignment (diff)
downloadlinux-a6bffb6920d16fb2ef4ba072fac5b64b36b1c254.tar.xz
linux-a6bffb6920d16fb2ef4ba072fac5b64b36b1c254.zip
iio: dht11: Improve detection of sensor type
The old code was based on a DHT11 datasheet which specifies a measurement range of 20%-90% RH. Turns out the sensor actually reports values outside this range, so we should support it as far as possible. Reported-by: Edward Attfield <edward@attfield.ca> Signed-off-by: Harald Geyer <harald@ccbib.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/humidity/dht11.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c
index df6bab40d6fa..1a9f8f4ffb88 100644
--- a/drivers/iio/humidity/dht11.c
+++ b/drivers/iio/humidity/dht11.c
@@ -159,7 +159,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)
}
dht11->timestamp = ktime_get_boot_ns();
- if (hum_int < 20) { /* DHT22 */
+ if (hum_int < 4) { /* DHT22: 100000 = (3*256+232)*100 */
dht11->temperature = (((temp_int & 0x7f) << 8) + temp_dec) *
((temp_int & 0x80) ? -100 : 100);
dht11->humidity = ((hum_int << 8) + hum_dec) * 100;