iio: adc: max1027: Minimize the number of converted channels
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 21 Sep 2021 11:53:56 +0000 (13:53 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 19 Oct 2021 07:27:33 +0000 (08:27 +0100)
commite1c0ea8f6e9d65754cade52fdb6fd206d169c3c4
tree3a9c4e57b9f9e295ef1a6ecf2876668ebd149b26
parent6f1bc6d8fb569eff3c4a5a54a31fc501adab4234
iio: adc: max1027: Minimize the number of converted channels

Provide a list of ->available_scan_masks which match the device's
capabilities. Basically, these devices are able to scan from 0 to N, N
being the highest voltage channel requested by the user. The temperature
can be included or not, but cannot be retrieved alone.

The consequence is, instead of reading and pushing to the IIO buffers
all channels each time, the "minimum" number of channels will be scanned
and pushed based on the ->active_scan_mask.

For example, if the user wants channels 1, 4 and 5, all channels from
0 to 5 will be scanned and pushed to the IIO buffers. The core will then
filter out the unneeded samples based on the ->active_scan_mask that has
been selected and only channels 1, 4 and 5 will be available to the user
in the shared buffer.

Provide a comment in the code explaining this logic.

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