From: Nuno Sa <nuno.sa@analog.com>
To: <linux-iio@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>
Subject: [PATCH RFC 1/3] iio: core: add new helper to iterate active channels
Date: Wed, 12 Jun 2024 16:20:48 +0200 [thread overview]
Message-ID: <20240612-dev-iio-scan-private-v1-1-7c75c8e3d30b@analog.com> (raw)
In-Reply-To: <20240612-dev-iio-scan-private-v1-0-7c75c8e3d30b@analog.com>
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@analog.com>
---
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
next prev parent reply other threads:[~2024-06-12 14:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 14:20 [PATCH RFC 0/3] iio: add helpers and accessors for active channels and masklength Nuno Sa
2024-06-12 14:20 ` Nuno Sa [this message]
2024-06-12 14:20 ` [PATCH RFC 2/3] iio: imu: adis16475: make use of iio_for_each_active_channel() Nuno Sa
2024-06-12 14:20 ` [PATCH RFC 3/3] iio: core annotate masklength as private Nuno Sa
2024-06-15 13:18 ` [PATCH RFC 0/3] iio: add helpers and accessors for active channels and masklength Jonathan Cameron
2024-06-17 6:34 ` Nuno Sá
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612-dev-iio-scan-private-v1-1-7c75c8e3d30b@analog.com \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox