[PATCH RFC 1/3] iio: core: add new helper to iterate active channels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a new iio_for_each_active_channel() helper to iterate over the
active channels. Also add an helper to access masklength using
ACCESS_PRIVATE(). End goal is to annotate that variable as __private so that
we can get checker warnings if drivers directly access that variable.

Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx>
---
 include/linux/iio/iio.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 894309294182..a63888746707 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -860,6 +860,12 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
 int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer,
 	int *fract);
 
+#define iio_dev_masklength(indio_dev)	ACCESS_PRIVATE(indio_dev, masklength)
+
+#define iio_for_each_active_channel(indio_dev, bit) \
+	for_each_set_bit((bit), (indio_dev)->active_scan_mask, \
+			 iio_dev_masklength(indio_dev))
+
 /**
  * IIO_DEGREE_TO_RAD() - Convert degree to rad
  * @deg: A value in degree

-- 
2.45.2





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux