]> git.baikalelectronics.ru Git - kernel.git/commit
iio: adc: ina2xx: Actually align the loop with the conversion ready flag
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Thu, 21 Dec 2017 18:31:38 +0000 (19:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jan 2018 15:03:43 +0000 (16:03 +0100)
commitc42c7d06d8744ed0b67d11438378c67782ea197c
tree67d6922d8f736b1efd95295bfbf59e0061ad4994
parent59a52d1ef492dfa716dfc440f66dbfc604a0ef38
iio: adc: ina2xx: Actually align the loop with the conversion ready flag

Currently, the registers are read out once per conversion interval. If
the reading is delayed as the conversion has not yet finished, this extra
time is treated as being part of the readout, although it should delay
the start of the poll interval. This results in the interval starting
slightly earlier in each iteration, until all time between reads is
spent polling the status registers instead of sleeping.

To fix this, the delay has to account for the state of the conversion
ready flag. Whenever the conversion is already finished, schedule the next
read on the regular interval, otherwise schedule it one interval after the
flag bit has been set.

Split the work function in two functions, one for the status poll and one
for reading the values, to be able to note down the time when the flag
bit is raised.

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>
drivers/iio/adc/ina2xx-adc.c