Skip to content

Commit 725cb47

Browse files
committed
iio: core: add accessors 'masklength'
'masklength' is supposed to be an IIO private member. However, drivers (often in trigger handlers) need to access it to iterate over the enabled channels for example (there are other reasons). Hence, a couple of new accessors are being added: * iio_for_each_active_channel() - Iterates over the active channels; * iio_get_masklength() - Get length of the channels mask. The goal of these new accessors is to annotate 'masklength' as private as soon as all drivers accessing it are converted to use the new helpers. Signed-off-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com> Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-1-98193bf536a6@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent f1aa31e commit 725cb47

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/linux/iio/iio.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,24 @@ static inline const struct iio_scan_type
838838
return &chan->scan_type;
839839
}
840840

841+
/**
842+
* iio_get_masklength - Get length of the channels mask
843+
* @indio_dev: the IIO device to get the masklength for
844+
*/
845+
static inline unsigned int iio_get_masklength(const struct iio_dev *indio_dev)
846+
{
847+
return indio_dev->masklength;
848+
}
849+
850+
/**
851+
* iio_for_each_active_channel - Iterated over active channels
852+
* @indio_dev: the IIO device
853+
* @chan: Holds the index of the enabled channel
854+
*/
855+
#define iio_for_each_active_channel(indio_dev, chan) \
856+
for_each_set_bit((chan), (indio_dev)->active_scan_mask, \
857+
iio_get_masklength(indio_dev))
858+
841859
ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
842860

843861
int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer,

0 commit comments

Comments
 (0)