iio: __iio_update_buffers: Update mode before preenable/after postdisable
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 30 Apr 2020 08:24:55 +0000 (11:24 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 16 May 2020 16:03:28 +0000 (17:03 +0100)
commit5cb1a5481cc3a1101457abd6abffc9b168bc7bb4
tree57cab675abbc4472cbd53c31733d10ddd9ad73d7
parent3adb82ebd9bb1c6c7985eb6fdaeede35c619b269
iio: __iio_update_buffers: Update mode before preenable/after postdisable

It is clear that we transition to INDIO_DIRECT_MODE when disabling the
buffer(s) and it is also clear that we transition from INDIO_DIRECT_MODE
when enabling the buffer(s). So leaving the currentmode field
INDIO_DIRECT_MODE until after the preenable() callback and updating it to
INDIO_DIRECT_MODE before the postdisable() callback doesn't add additional
value. On the other hand some drivers will need to perform different
actions depending on which mode the device is going to operate in/was
operating in.

Moving the update of currentmode before preenable() and after postdisable()
enables us to have drivers which perform mode dependent actions in those
callbacks.

Note, was originally not intended as such, but fixes an issue introduced
in the at91-sama5d2 adc driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Fixes: 065056cb0d0a ("iio: at91-sama5d2_adc: split at91_adc_current_chan_is_touch() helper")
Tested-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-buffer.c