iio: adc: max1027: Prevent single channel accesses during buffer reads
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 21 Sep 2021 11:54:02 +0000 (13:54 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 19 Oct 2021 07:27:33 +0000 (08:27 +0100)
commit59fcc6af89ff2069436830be02ebfde76d79d2d8
tree8e0affae937ba546f359e5bb073a70dc838d859d
parentaf8b93e27fb6cc74c0cf1e9b70ba01e85586d793
iio: adc: max1027: Prevent single channel accesses during buffer reads

When hardware buffers are enabled (the cnvst pin being the trigger), one
should not mess with the device state by requesting a single channel
read.

There is already a iio_buffer_enabled() check in *_read_single_value()
to merely prevent this situation but the check is inconsistent since
buffers can be enabled after the if clause anyway. Instead, use the core
mutex by calling iio_device_claim/release_direct_mode().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-11-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/max1027.c