iio: dht11: Use boottime
PATCH 1/1 iio: dht11: Use boottime
Wall time obtained from ktime_get_real_ns is susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps.
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/humidity/dht11.c +4 -4
@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11, int offset, int timeres)if (((hum_int + hum_dec + temp_int + temp_dec) &0xff ) != checksum)return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec) * ((temp_int &0x80 ) ?-100 :100 );
@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges <DHT11_EDGES_PER_READ && dht11->num_edges >=0 ) { - dht11->edges[dht11->num_edges].ts =ktime_get_real_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); dht11->edges[dht11->num_edges++].value =gpio_get_value (dht11->gpio);
@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres;mutex_lock (&dht11->lock); -if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_real_ns ()) { +if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boot_ns ()) { timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns too low\n",
@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device *pdev)return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);
Signature · 1 line
1.7.9.5
Jonathan Cameron
maintainerQuoted 5 lines · Abhilash Jindal
Wall time obtained from
ktime_get_real_nsis susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps.Signed-off-by Abhilash Jindal <[email protected]>
Seems sensible to me, but would like Richard / Harald to take a quick look before I apply it.
Thanks,
Jonathan
Quoted 45 lines
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/iio/humidity/dht11.c +4
-4@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11, int offset, int timeres)if (((hum_int + hum_dec + temp_int + temp_dec) &0xff ) != checksum)return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec) * ((temp_int &0x80 ) ?-100 :100 );@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges <DHT11_EDGES_PER_READ && dht11->num_edges >=0 ) { - dht11->edges[dht11->num_edges].ts =ktime_get_real_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); dht11->edges[dht11->num_edges++].value =gpio_get_value (dht11->gpio);@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres;mutex_lock (&dht11->lock); -if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_real_ns ()) { +if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boot_ns ()) { timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns too low\n",@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device *pdev)return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);
Harald Geyer
Reviewed-byQuoted 8 lines · Jonathan Cameron
Quoted 5 lines · Abhilash Jindal
Wall time obtained from
ktime_get_real_nsis susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps.Signed-off-by Abhilash Jindal <[email protected]>Seems sensible to me, but would like Richard / Harald to take a quick look before I apply it.
I can't test this right now, but I think it will fix an odd issue I have seen in a log file (apparently was completely off track debugging it). As this very likely is a real world issue, I'd recommend applying the patch to the fixes branch, so that it hopefully gets picked up for LTS kernels.
I used ktime_get_real_ns() because that is what iio_get_time_ns() uses. I should have thought about this twice - sorry about being sloppy!
I just grepped the other iio drivers and none is using iio_get_time_ns() in a comparision like dht11 did, so maybe the other uses are safe. However I couldn't check variables containing timestamps that way, so maybe reviewing the users of iio_get_time_ns(), whether wall time is actually what is wanted, would be a worthwhile task if somebody has the time ...
Thanks for the patch!
Harald
Quoted 49 lines
Thanks,
Jonathan
Quoted 45 lines
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/iio/humidity/dht11.c +4
-4@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11, int offset, int timeres)if (((hum_int + hum_dec + temp_int + temp_dec) &0xff ) != checksum)return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec) * ((temp_int &0x80 ) ?-100 :100 );@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data)/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges <DHT11_EDGES_PER_READ && dht11->num_edges >=0 ) { - dht11->edges[dht11->num_edges].ts =ktime_get_real_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); dht11->edges[dht11->num_edges++].value =gpio_get_value (dht11->gpio);@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres;mutex_lock (&dht11->lock); -if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_real_ns ()) { +if (dht11->timestamp +DHT11_DATA_VALID_TIME <ktime_get_boot_ns ()) { timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns too low\n",@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device *pdev)return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);
Signature · 4 lines
If you want to support my work: see http://friends.ccbib.org/harald/supporting/ or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS
Thanks Harald and Jonathan.
I would absolutely love to know the symptoms of the odd issue you mentioned.
Cheers,
Abhilash
Quoted 97 lines · Harald Geyer
Quoted 2 lines · Jonathan Cameron
Quoted 1 line · Abhilash Jindal
Wall time obtained from
ktime_get_real_nsis susceptible to suddenjumps due to
Quoted 1 line
Quoted 1 line
user setting the time or due to NTP. Boot time is constantly
increasing time
Quoted 5 lines
Quoted 3 lines
better suited for comparing two timestamps.
Signed-off-by Abhilash Jindal <[email protected]>Seems sensible to me, but would like Richard / Harald to take a quick look before I apply it.
Reviewed-by Harald Geyer <[email protected]>I can't test this right now, but I think it will fix an odd issue I have seen in a log file (apparently was completely off track debugging it). As this very likely is a real world issue, I'd recommend applying the patch to the fixes branch, so that it hopefully gets picked up for LTS kernels.
I used
ktime_get_real_ns()because that is whatiio_get_time_ns()uses. I should have thought about this twice - sorry about being sloppy!I just grepped the other iio drivers and none is using
iio_get_time_ns()in a comparision like dht11 did, so maybe the other uses are safe. However I couldn't check variables containing timestamps that way, so maybe reviewing the users ofiio_get_time_ns(), whether wall time is actually what is wanted, would be a worthwhile task if somebody has the time ...Thanks for the patch!
HaraldQuoted 8 lines
Thanks,
Jonathan
Review
Quoted 5 lines
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/iio/humidity/dht11.cQuoted 4 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11, int
Quoted 4 lines
index 1165b1c..cfc5a05 100644
drivers/iio/humidity/dht11.c +0
-0@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11, intoffset, int timeres)
Quoted 7 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11, int offset, int timeres)
Quoted 7 lines
drivers/iio/humidity/dht11.c +1
-1if (((hum_int + hum_dec + temp_int + temp_dec) &0xff ) != checksum)return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec)*
Quoted 2 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void
Quoted 2 lines
drivers/iio/humidity/dht11.c +0
-0((temp_int &0x80 ) ?-100 :100 );@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq, void*data)
Quoted 3 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void · line 146
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >=0) {
Quoted 4 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void *data) · line 151
Quoted 4 lines
drivers/iio/humidity/dht11.c +1
-1- dht11->edges[dht11->num_edges].ts =ktime_get_real_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); dht11->edges[dht11->num_edges++].value =
gpio_get_value(dht11->gpio);Quoted 6 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev, · line 167
Quoted 6 lines
drivers/iio/humidity/dht11.c +0
-1@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres;mutex_lock (&dht11->lock); - if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_real_ns()) {Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev, · line 167
Quoted 1 line
drivers/iio/humidity/dht11.c +1
-0+ if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_boot_ns()) {Quoted 3 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev,
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns toolow\n",
Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device*pdev)
Quoted 10 lines
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device *pdev) · line 285
Quoted 9 lines
drivers/iio/humidity/dht11.c +1
-1return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);--
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS
Quoted 3 lines · Abhilash Jindal
Thanks Harald and Jonathan.
I would absolutely love to know the symptoms of the odd issue you mentioned.
Sure. What I was seeing was a number of zero humidity, zero temperature values reported for some time after boot. Then the sensors started to work normally.
Given that "all transmission bits zero" passes the checksum test, I thought that maybe there is some ressource conflict of the irq line causing edges to come in at way too fast pace. However the bug you found explains it neatly if we assume that the system clock is set after probe() but before the sensor is read for the first time and the zeros I saw in the log were actually uninitialized memory.
Maybe settingdht11->timestamp = ktime_get_real_ns() - DHT11_DATA_VALID_TIME - 1; in probe() wasn't such a good idea.dht11->timestamp = -1;
probably would have been more robust. But of course your patch is fixing the true problem.
best regards,
Harald
Quoted 103 lines
Cheers,
AbhilashQuoted 97 lines · Harald Geyer
Quoted 2 lines · Jonathan Cameron
Quoted 1 line · Abhilash Jindal
Wall time obtained from
ktime_get_real_nsis susceptible to suddenjumps due to
Quoted 1 line
Quoted 1 line
user setting the time or due to NTP. Boot time is constantly
increasing time
Quoted 5 lines
Quoted 3 lines
better suited for comparing two timestamps.
Signed-off-by Abhilash Jindal <[email protected]>Seems sensible to me, but would like Richard / Harald to take a quick look before I apply it.
Reviewed-by Harald Geyer <[email protected]>I can't test this right now, but I think it will fix an odd issue I have seen in a log file (apparently was completely off track debugging it). As this very likely is a real world issue, I'd recommend applying the patch to the fixes branch, so that it hopefully gets picked up for LTS kernels.
I used
ktime_get_real_ns()because that is whatiio_get_time_ns()uses. I should have thought about this twice - sorry about being sloppy!I just grepped the other iio drivers and none is using
iio_get_time_ns()in a comparision like dht11 did, so maybe the other uses are safe. However I couldn't check variables containing timestamps that way, so maybe reviewing the users ofiio_get_time_ns(), whether wall time is actually what is wanted, would be a worthwhile task if somebody has the time ...Thanks for the patch!
HaraldQuoted 8 lines
Thanks,
Jonathan
Review
Quoted 5 lines
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/iio/humidity/dht11.cQuoted 4 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11, int
Quoted 4 lines
index 1165b1c..cfc5a05 100644
drivers/iio/humidity/dht11.c +0
-0@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11, intoffset, int timeres)
Quoted 7 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11, int offset, int timeres)
Quoted 7 lines
drivers/iio/humidity/dht11.c +1
-1if (((hum_int + hum_dec + temp_int + temp_dec) &0xff ) != checksum)return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int &0x7f ) <<8 ) + temp_dec)*
Quoted 2 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void
Quoted 2 lines
drivers/iio/humidity/dht11.c +0
-0((temp_int &0x80 ) ?-100 :100 );@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq, void*data)
Quoted 3 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void · line 146
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >=0) {
Quoted 4 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void *data) · line 151
Quoted 4 lines
drivers/iio/humidity/dht11.c +1
-1- dht11->edges[dht11->num_edges].ts =ktime_get_real_ns (); + dht11->edges[dht11->num_edges].ts =ktime_get_boot_ns (); dht11->edges[dht11->num_edges++].value =
gpio_get_value(dht11->gpio);Quoted 6 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev, · line 167
Quoted 6 lines
drivers/iio/humidity/dht11.c +0
-1@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,int ret, timeres;mutex_lock (&dht11->lock); - if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_real_ns()) {Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev, · line 167
Quoted 1 line
drivers/iio/humidity/dht11.c +1
-0+ if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_boot_ns()) {Quoted 3 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev,
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns toolow\n",
Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device*pdev)
Quoted 10 lines
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device *pdev) · line 285
Quoted 9 lines
drivers/iio/humidity/dht11.c +1
-1return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME -1 ; + dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME -1 ; dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);--
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS
Signature · 4 lines
If you want to support my work: see http://friends.ccbib.org/harald/supporting/ or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS
Great, thanks.
Best,
Abhilash
Quoted 153 lines · Harald Geyer
Quoted 3 lines · Abhilash Jindal
Thanks Harald and Jonathan.
I would absolutely love to know the symptoms of the odd issue you
mentioned.
Sure. What I was seeing was a number of zero humidity, zero temperature values reported for some time after boot. Then the sensors started to work normally.
Given that "all transmission bits zero" passes the checksum test, I thought that maybe there is some ressource conflict of the irq line causing edges to come in at way too fast pace. However the bug you found explains it neatly if we assume that the system clock is set after
probe()but before
the sensor is read for the first time and the zeros I saw in the log were actually uninitialized memory.Maybe setting
dht11->timestamp=ktime_get_real_ns()-DHT11_DATA_VALID_TIME- 1; inprobe()wasn't such a good idea.dht11->timestamp= -1;
probably would have been more robust. But of course your patch is fixing the true problem.best regards,
HaraldQuoted 21 lines
Cheers,
AbhilashQuoted 16 lines · Harald Geyer
Quoted 2 lines · Jonathan Cameron
Quoted 1 line · Abhilash Jindal
Wall time obtained from
ktime_get_real_nsis susceptible to suddenjumps due to
Quoted 1 line
Quoted 1 line
user setting the time or due to NTP. Boot time is constantly
increasing time
Quoted 5 lines
Quoted 3 lines
better suited for comparing two timestamps.
Signed-off-by Abhilash Jindal <[email protected]>Seems sensible to me, but would like Richard / Harald to take a quick look before I apply it.
Reviewed-by Harald Geyer <[email protected]>I can't test this right now, but I think it will fix an odd issue I have seen in a log file (apparently was completely off track debugging
it).
Quoted 1 line
Quoted 1 line
As this very likely is a real world issue, I'd recommend applying the
patch
Quoted 1 line
Quoted 1 line
to the fixes branch, so that it hopefully gets picked up for LTS
kernels.
Quoted 5 lines
Quoted 5 lines
I used
ktime_get_real_ns()because that is whatiio_get_time_ns()uses. I should have thought about this twice - sorry about being sloppy!I just grepped the other iio drivers and none is using
iio_get_time_ns()inQuoted 15 lines
Quoted 15 lines
a comparision like dht11 did, so maybe the other uses are safe. However I couldn't check variables containing timestamps that way, so maybe reviewing the users of
iio_get_time_ns(), whether wall time is actually what is wanted, would be a worthwhile task if somebody has the time ...Thanks for the patch!
HaraldQuoted 7 lines
Thanks,
Jonathan
Quoted 4 lines
--- drivers/iio/humidity/dht11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/iio/humidity/dht11.cQuoted 4 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11,
Quoted 4 lines
index 1165b1c..cfc5a05 100644
drivers/iio/humidity/dht11.c +0
-0@@ -117,7 +117,7 @@ static int dht11_decode(struct dht11 *dht11,int
Quoted 2 lines
Quoted 2 lines
offset, int timeres)
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0if (((hum_int + hum_dec + temp_int + temp_dec) & 0xff) !=checksum)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/iio/humidity/dht11.c static int dht11_decode(struct dht11 *dht11, int offset, int timeres)
Quoted 6 lines
drivers/iio/humidity/dht11.c +1
-1return -EIO ; - dht11->timestamp =ktime_get_real_ns (); + dht11->timestamp =ktime_get_boot_ns ();if (hum_int <20 ) {/* DHT22 */ dht11->temperature = (((temp_int & 0x7f) << 8) +
temp_dec)Quoted 2 lines
Quoted 2 lines
*
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0((temp_int & 0x80) ? -100 :100);
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq,
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0@@ -145,7 +145,7 @@ static irqreturn_t dht11_handle_irq(int irq,void
Quoted 4 lines
Quoted 4 lines
*data)
Quoted 3 lines
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0/* TODO: Consider making the handler safe for IRQ sharing */ if (dht11->num_edges < DHT11_EDGES_PER_READ &&
dht11->num_edges>=Quoted 2 lines
Quoted 2 lines
0) {
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-1- dht11->edges[dht11->num_edges].ts =
ktime_get_real_ns();Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, · line 147
Quoted 1 line
drivers/iio/humidity/dht11.c +1
-0+ dht11->edges[dht11->num_edges].ts =
ktime_get_boot_ns();Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
drivers/iio/humidity/dht11.c static irqreturn_t dht11_handle_irq(int irq, void *data) · line 151
Quoted 2 lines
drivers/iio/humidity/dht11.c +0
-0dht11->edges[dht11->num_edges++].value =
gpio_get_value(dht11->gpio);Quoted 2 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev
Quoted 2 lines
drivers/iio/humidity/dht11.c +0
-0@@ -164,7 +164,7 @@ static int dht11_read_raw(struct iio_dev
*iio_dev,Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev *iio_dev,
Quoted 4 lines
drivers/iio/humidity/dht11.c +0
-1int ret, timeres;mutex_lock (&dht11->lock); - if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_real_ns()) {Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_read_raw(struct iio_dev · line 167
Quoted 1 line
drivers/iio/humidity/dht11.c +1
-0+ if (dht11->timestamp + DHT11_DATA_VALID_TIME <
ktime_get_boot_ns()) {Quoted 3 lines
Quoted 3 lines
drivers/iio/humidity/dht11.c +0
-0timeres =ktime_get_resolution_ns ();if (DHT11_DATA_BIT_HIGH <2 * timeres) { dev_err(dht11->dev, "timeresolution %dns tooQuoted 7 lines
Quoted 7 lines
low\n",
Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device
Quoted 1 line
drivers/iio/humidity/dht11.c +0
-0@@ -279,7 +279,7 @@ static int dht11_probe(struct platform_device*pdev)
Quoted 4 lines
Quoted 4 lines
drivers/iio/humidity/dht11.c +0
-1return -EINVAL ; } - dht11->timestamp =ktime_get_real_ns () -DHT11_DATA_VALID_TIME - 1;
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/iio/humidity/dht11.c static int dht11_probe(struct platform_device · line 282
Quoted 1 line
drivers/iio/humidity/dht11.c +1
-0+ dht11->timestamp =ktime_get_boot_ns () -DHT11_DATA_VALID_TIME - 1;
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
drivers/iio/humidity/dht11.c +0
-0dht11->num_edges =-1 ;platform_set_drvdata (pdev, iio);Quoted 7 lines
Quoted 6 lines
--
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS--
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w or bitcoin 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS