Skip to content

Commit ff3aa88

Browse files
StefanBruensjic23
authored andcommitted
iio: adc: ina219: Avoid underflow for sleeping time
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: 18edac2 ("iio: adc: Fix integration time/averaging for INA219/220") Signed-off-by: Stefan Brüns <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 90938ca commit ff3aa88

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/adc/ina2xx-adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ static int ina2xx_capture_thread(void *data)
644644
{
645645
struct iio_dev *indio_dev = data;
646646
struct ina2xx_chip_info *chip = iio_priv(indio_dev);
647-
unsigned int sampling_us = SAMPLING_PERIOD(chip);
647+
int sampling_us = SAMPLING_PERIOD(chip);
648648
int buffer_us;
649649

650650
/*

0 commit comments

Comments
 (0)