From: Jonathan Cameron <jic23@kernel.org>
To: Harald Geyer <harald@ccbib.org>,
linux-iio@vger.kernel.org,
Jonathan Bell <jonathan@raspberrypi.org>
Cc: Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH 1/3] iio: dht11: Improve reliability - be more tolerant about missing start bits
Date: Mon, 4 Jan 2016 11:45:41 +0000 [thread overview]
Message-ID: <568A5B65.7070509@kernel.org> (raw)
In-Reply-To: <1451485605-3441-1-git-send-email-harald@ccbib.org>
On 30/12/15 14:26, Harald Geyer wrote:
> 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>
Seems sensible, but ideally I'd like a tested by! Sounds like
Jonathan Bell might be able to provide one.
Changes to this driver always worry me given how fiddly the hardware
interface is.
Jonathan
> ---
> Jonathan Bell:
> Can you test if this fixes the problems you reported on RPi?
>
> (It does fix problems I noticed when I slowed down my test HW with
> enabling the debug logging introduced later in this series, so including
> this patch is a good thing even if it doesn't fix Jonathan's problems.)
>
> drivers/iio/humidity/dht11.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c
> index 1165b1c..1ca284a 100644
> --- a/drivers/iio/humidity/dht11.c
> +++ b/drivers/iio/humidity/dht11.c
> @@ -161,7 +161,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
> int *val, int *val2, long m)
> {
> struct dht11 *dht11 = iio_priv(iio_dev);
> - int ret, timeres;
> + int ret, timeres, offset;
>
> mutex_lock(&dht11->lock);
> if (dht11->timestamp + DHT11_DATA_VALID_TIME < ktime_get_real_ns()) {
> @@ -208,11 +208,14 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
> if (ret < 0)
> goto err;
>
> - ret = dht11_decode(dht11,
> - dht11->num_edges == DHT11_EDGES_PER_READ ?
> - DHT11_EDGES_PREAMBLE :
> - DHT11_EDGES_PREAMBLE - 2,
> - timeres);
> + offset = DHT11_EDGES_PREAMBLE +
> + dht11->num_edges - DHT11_EDGES_PER_READ;
> + for (; offset >= 0; --offset) {
> + ret = dht11_decode(dht11, offset, timeres);
> + if (!ret)
> + break;
> + }
> +
> if (ret)
> goto err;
> }
>
next prev parent reply other threads:[~2016-01-04 11:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-30 14:26 [PATCH 1/3] iio: dht11: Improve reliability - be more tolerant about missing start bits Harald Geyer
2015-12-30 14:26 ` [PATCH 2/3] iio: dht11: Simplify decoding algorithm Harald Geyer
2016-01-04 11:44 ` Jonathan Cameron
2016-01-04 14:37 ` Harald Geyer
2015-12-30 14:26 ` [PATCH 3/3] iio: dht11: Improve logging Harald Geyer
2016-01-04 11:53 ` Jonathan Cameron
2016-01-04 14:49 ` Harald Geyer
2016-01-04 18:20 ` Jonathan Cameron
2016-01-04 11:45 ` Jonathan Cameron [this message]
2016-01-04 14:28 ` [PATCH 1/3] iio: dht11: Improve reliability - be more tolerant about missing start bits Harald Geyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=568A5B65.7070509@kernel.org \
--to=jic23@kernel.org \
--cc=harald@ccbib.org \
--cc=jonathan@raspberrypi.org \
--cc=linux-iio@vger.kernel.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.