summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2017-12-08 20:41:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-08 18:03:42 +0300
commit8bcf024f06f11c0c9597ecbbfbe291a9a5092204 (patch)
treec96d137ba7742d62454e5d1a179fff589583904d /drivers/iio
parentc68013f3a9a7c901a9a7935a973a0ab1cc884c4a (diff)
downloadlinux-8bcf024f06f11c0c9597ecbbfbe291a9a5092204.tar.xz
iio: adc: ina2xx: Do not udelay for several seconds
The conversion time can be up to 16 seconds (8 ms per channel, 2 channels, 1024 times averaging). Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/ina2xx-adc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index b027d485398b..2621a34ee5c6 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -764,7 +764,7 @@ static int ina2xx_capture_thread(void *data)
struct iio_dev *indio_dev = data;
struct ina2xx_chip_info *chip = iio_priv(indio_dev);
int sampling_us = SAMPLING_PERIOD(chip);
- int buffer_us;
+ int buffer_us, delay_us;
/*
* Poll a bit faster than the chip internal Fs, in case
@@ -778,8 +778,10 @@ static int ina2xx_capture_thread(void *data)
if (buffer_us < 0)
return buffer_us;
- if (sampling_us > buffer_us)
- udelay(sampling_us - buffer_us);
+ if (sampling_us > buffer_us) {
+ delay_us = sampling_us - buffer_us;
+ usleep_range(delay_us, (delay_us * 3) >> 1);
+ }
} while (!kthread_should_stop());