iio: Add callback to check whether a scan mask is valid
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 9 Jul 2012 09:00:00 +0000 (10:00 +0100)
committerJonathan Cameron <jic23@kernel.org>
Mon, 9 Jul 2012 17:18:15 +0000 (18:18 +0100)
commit939546d1a9f47ed169554c711e1e05965b84ffe1
tree80ee898547145c1b202a77d3ca5f642809ba9778
parentc732a24c5a9392cf3738f5957e0d97d37c09e6e1
iio: Add callback to check whether a scan mask is valid

This is useful for cases where the number of valid scan masks grows
exponentially, but it is rather easy to check whether a mask is valid or not
programmatically.

An example of such a case is a device with multiple ADCs where each ADC has a
upstream MUX, which allows to select from a number of physical channels.

  +-------+   +-------+
  |       |   |       | --- Channel 1
  | ADC 1 |---| MUX 1 | ---   ...
  |       |   |       | --- Channel M
  +-------+   +-------+

     .            .            .
     .            .            .
     .            .            .

  +-------+   +-------+
  |       |   |       | --- Channel M * N + 1
  | ADC N |---| MUX N | ---       ...
  |       |   |       | --- Channel M * N + M
  +-------+   +-------+

The number of necessary scan masks for this case is (M+1)**N - 1, on the other
hand it is easy to check whether subsets for each ADC of the scanmask have only
one bit set.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-buffer.c
include/linux/iio/iio.h