Skip to content

Commit 5afc154

Browse files
Colin Ian Kingjic23
authored andcommitted
iio: adc: Fix incorrect exit of for-loop
Currently the for-loop that scans for the optimial adc_period iterates through all the possible adc_period levels because the exit logic in the loop is inverted. I believe the comparison should be swapped and the continue replaced with a break to exit the loop at the correct point. Addresses-Coverity: ("Continue has no effect") Fixes: e08e19c ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc") Signed-off-by: Colin Ian King <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 84edec8 commit 5afc154

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/adc/palmas_gpadc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
664664

665665
adc_period = adc->auto_conversion_period;
666666
for (i = 0; i < 16; ++i) {
667-
if (((1000 * (1 << i)) / 32) < adc_period)
668-
continue;
667+
if (((1000 * (1 << i)) / 32) >= adc_period)
668+
break;
669669
}
670670
if (i > 0)
671671
i--;

0 commit comments

Comments
 (0)