iio: adc: ti-ads1015: avoid getting stale result after runtime resume
authorAkinobu Mita <akinobu.mita@gmail.com>
Thu, 20 Jul 2017 15:24:20 +0000 (00:24 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Sep 2017 15:39:38 +0000 (17:39 +0200)
commit1ed4565b7c7bb73d802800c333244498f0993274
tree491d3532cb709437141ec027798d2355721fb461
parentc72ad1a4fdf044c5253a72bc413e1869d6b16f39
iio: adc: ti-ads1015: avoid getting stale result after runtime resume

commit 73e3e3fc50de50cfd68e945d85679c983ed31bd9 upstream.

This driver assumes that the device is operating in the continuous
conversion mode which performs the conversion continuously.  So this driver
doesn't insert a wait time before reading the conversion register if the
configuration is not changed from a previous request.

This assumption is broken if the device is runtime suspended and entered
a power-down state.  The forthcoming request causes reading a stale result
from the conversion register as the device is runtime resumed just before.

Fix it by adding a flag to detect that condition and insert a necessary
wait time.

Cc: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ti-ads1015.c