Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697577 > unrolled thread

[PATCH] iio: adc: ina219: Avoid underflow for sleeping time

Started byStefan Brüns <stefan.bruens@rwth-aachen.de>
First post2017-07-26 23:40 +0200
Last post2017-07-30 16:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: adc: ina219: Avoid underflow for sleeping time Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-07-26 23:40 +0200
    Re: [PATCH] iio: adc: ina219: Avoid underflow for sleeping time Jonathan Cameron <jic23@kernel.org> - 2017-07-30 16:00 +0200

#1697577 — [PATCH] iio: adc: ina219: Avoid underflow for sleeping time

FromStefan Brüns <stefan.bruens@rwth-aachen.de>
Date2017-07-26 23:40 +0200
Subject[PATCH] iio: adc: ina219: Avoid underflow for sleeping time
Message-ID<u7Cca-5FZ-5@gated-at.bofh.it>
Proper support for the INA219 lowered the minimum sampling period from
2*140us to 2*84us. Subtracting 200us later leads to an underflow and
an almost infinite udelay later.

Using a signed int for the sampling period provides sufficient range
(at most 2*8640*1024us), but catches the underflow when comparing with
buffer_us.

Fixes: 18edac2e22f4 ("iio: adc: Fix integration time/averaging for INA219/220")
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
 drivers/iio/adc/ina2xx-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index b0d9e3b80e6d..85b419ea9ba9 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -657,7 +657,7 @@ static int ina2xx_capture_thread(void *data)
 {
 	struct iio_dev *indio_dev = data;
 	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
-	unsigned int sampling_us = SAMPLING_PERIOD(chip);
+	int sampling_us = SAMPLING_PERIOD(chip);
 	int buffer_us;
 
 	/*
-- 
2.13.3

[toc] | [next] | [standalone]


#1699536

FromJonathan Cameron <jic23@kernel.org>
Date2017-07-30 16:00 +0200
Message-ID<u8WVc-11e-9@gated-at.bofh.it>
In reply to#1697577
On Wed, 26 Jul 2017 23:32:06 +0200
Stefan Brüns <stefan.bruens@rwth-aachen.de> wrote:

> Proper support for the INA219 lowered the minimum sampling period from
> 2*140us to 2*84us. Subtracting 200us later leads to an underflow and
> an almost infinite udelay later.
> 
> Using a signed int for the sampling period provides sufficient range
> (at most 2*8640*1024us), but catches the underflow when comparing with
> buffer_us.
> 
> Fixes: 18edac2e22f4 ("iio: adc: Fix integration time/averaging for INA219/220")
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/adc/ina2xx-adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index b0d9e3b80e6d..85b419ea9ba9 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -657,7 +657,7 @@ static int ina2xx_capture_thread(void *data)
>  {
>  	struct iio_dev *indio_dev = data;
>  	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
> -	unsigned int sampling_us = SAMPLING_PERIOD(chip);
> +	int sampling_us = SAMPLING_PERIOD(chip);
>  	int buffer_us;
>  
>  	/*

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web