linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andreas Klinger <ak@it-klinger.de>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] iio: adc: hx711: optimize sampling of data
Date: Sun, 8 Sep 2019 14:49:22 +0100	[thread overview]
Message-ID: <20190908144922.51ba448e@archlinux> (raw)
In-Reply-To: <20190907101759.kft6xwsqc5lf4acq@arbad>

On Sat, 7 Sep 2019 12:18:00 +0200
Andreas Klinger <ak@it-klinger.de> wrote:

> Fix bug in sampling function hx711_cycle() when interrupt occures while
> PD_SCK is high. If PD_SCK is high for at least 60 us power down mode of
> the sensor is entered which in turn leads to a wrong measurement.
> 
> Move query of DOUT at the latest point of time which is at the end of
> PD_SCK low period.
> 
> Signed-off-by: Andreas Klinger <ak@it-klinger.de>

Hi Andreas,

One thing I'm not clear on from these is how much a 'fix' they
are.  That just effects whether we mark them for stable / push them
out as quickly as possible or not.  So has this been seen in 
normal operation?

+ please add fixes tags to the two fixes.

For patch 3, it's in the very low importance category so it may
well get forgotten if these two go through the fixes tree
(up to you to remind me!)

Thanks,

Jonathan

> ---
>  drivers/iio/adc/hx711.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
> index 88c7fe15003b..0678964dbd21 100644
> --- a/drivers/iio/adc/hx711.c
> +++ b/drivers/iio/adc/hx711.c
> @@ -101,13 +101,14 @@ struct hx711_data {
>  static int hx711_cycle(struct hx711_data *hx711_data)
>  {
>  	int val;
> +	unsigned long flags;
>  
>  	/*
>  	 * if preempted for more then 60us while PD_SCK is high:
>  	 * hx711 is going in reset
>  	 * ==> measuring is false
>  	 */
> -	preempt_disable();
> +	local_irq_save(flags);
>  	gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
>  
>  	/*
> @@ -117,7 +118,6 @@ static int hx711_cycle(struct hx711_data *hx711_data)
>  	 */
>  	ndelay(hx711_data->data_ready_delay_ns);
>  
> -	val = gpiod_get_value(hx711_data->gpiod_dout);
>  	/*
>  	 * here we are not waiting for 0.2 us as suggested by the datasheet,
>  	 * because the oscilloscope showed in a test scenario
> @@ -125,7 +125,7 @@ static int hx711_cycle(struct hx711_data *hx711_data)
>  	 * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz
>  	 */
>  	gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
> -	preempt_enable();
> +	local_irq_restore(flags);
>  
>  	/*
>  	 * make it a square wave for addressing cases with capacitance on
> @@ -133,7 +133,8 @@ static int hx711_cycle(struct hx711_data *hx711_data)
>  	 */
>  	ndelay(hx711_data->data_ready_delay_ns);
>  
> -	return val;
> +	/* sample as late as possible */
> +	return gpiod_get_value(hx711_data->gpiod_dout);
>  }
>  
>  static int hx711_read(struct hx711_data *hx711_data)


  reply	other threads:[~2019-09-08 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-07 10:18 [PATCH 1/3] iio: adc: hx711: optimize sampling of data Andreas Klinger
2019-09-08 13:49 ` Jonathan Cameron [this message]
2019-09-09 12:35   ` Andreas Klinger

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=20190908144922.51ba448e@archlinux \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).