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)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 20 Aug 2017 14:41:13 +0000 (15:41 +0100)
commit73e3e3fc50de50cfd68e945d85679c983ed31bd9
treee6277bcfcd388098fb38483ba4df45cfff750226
parente8245c68350104b6022b6783719e843d69ea7c43
iio: adc: ti-ads1015: avoid getting stale result after runtime resume

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>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-ads1015.c