1
0
Fork 0
Commit Graph

11 Commits (fec2f3335c637ca95166a9eb753fe2b49aee4e71)

Author SHA1 Message Date
Harald Geyer 155a57593d iio: dht11: Simplify decoding algorithm
The new algorithm uses a 'one size fits em all' threshold, which should
be easier to understand and debug. I believe there are no regressions
compared to the old adaptive threshold algorithm. I don't remember why
I chose the old algorithm when I initially wrote the driver.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-30 16:27:13 +00:00
Harald Geyer 22acc120a1 iio: dht11: Improve reliability - be more tolerant about missing start bits
Instead of guessing where the data starts, we now just try to decode from
every possible start position. This causes no additional overhead if we
properly received the full preamble and only costs a few extra CPU cycles
in the case where the preamble is corrupted. This is much more efficient
than to return an error to userspace and start over again.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-30 16:27:13 +00:00
Harald Geyer 081d974031 iio: dht11: Use new function ktime_get_resolution_ns()
This cleans up the most ugly workaround in this driver. There are no
functional changes yet in the decoding algorithm, but we improve the
following things:
 * Get rid of spurious warning messages on systems with fast HRTIMER.
 * If the clock is not fast enough for decoding to work, we give
   up immediately.
 * In that case we return EAGAIN instead of EIO, so it's easier to
   discriminate causes of failure.

Returning EAGAIN is somewhat controversial: It's technically correct
as a faster clock might become available. OTOH once all clocks are
enabled this is a permanent error. There is no ECLOCKTOOSLOW error
code.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20 18:41:20 +01:00
Harald Geyer 5fbb0bc466 iio: dht11: avoid multiple assignments to make checkpatch.pl --strict happy
We just do the assignments in two steps.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20 18:41:19 +01:00
Harald Geyer a7126003b6 iio: dht11: add comment to make checkpatch.pl --strict happy
Explain why the driver needs a mutex.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20 18:41:18 +01:00
Harald Geyer 889c5e9b66 iio: dht11: whitespace changes to make checkpatch.pl --strict happy
* add spaces around binary operators in cases where it reduces readability
* align multiline statements around opening parenthesis

Reported-by: Hartmut Knaack <knaack.h@gmx.de>
	in Message-ID: <55919E72.3010807@gmx.de>

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20 18:41:17 +01:00
Richard Weinberger 94e65519ab iio: dht11: IRQ fixes
Since setting irq-enabled GPIOs into output state is not supported
by all GPIO controllers, we need to disable the irq while requesting
sensor data. As side effect we lose a tiny bit of functionality:
Some wiring problems can't be concluded from log messages anymore.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-10 11:16:32 +00:00
Richard Weinberger 004bc53034 iio: dht11: Add locking
Make sure that the read function is not interrupted...

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Harald Geyer <harald@ccbib.org>
Reviewed-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-10 11:14:53 +00:00
Richard Weinberger ddc25bdd2b iio: dht11: Fix out-of-bounds read
As we access i-1 we must not start with i=0.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Acked-by: Harald Geyer <harald@ccbib.org>
Reviewed-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-10 11:13:35 +00:00
Sanjeev Sharma 81816affea iio: remove .owner field for driver using module_platform_driver
This patch removes the .owner field for drivers which use the
platform_driver_register api because this is overriden in
_platform_driver_register.

Signed-off-by: Sanjeev Sharma <Sanjeev_Sharma@mentor.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-26 21:08:38 +01:00
Harald Geyer 091a121b04 iio: Add new driver dht11
This driver handles DHT11 and DHT22 sensors.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-12-03 20:22:30 +00:00