From: Junjie Cao <junjie.cao@intel.com>
To: jic23@kernel.org, linux-iio@vger.kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-kernel@vger.kernel.org, Junjie Cao <junjie.cao@intel.com>
Subject: [PATCH] iio: core: Cast info mask to 'unsigned long *' in bit-ops
Date: Fri, 15 Aug 2025 10:25:28 +0800 [thread overview]
Message-ID: <20250815022528.24705-1-junjie.cao@intel.com> (raw)
for_each_set_bit()/find_*_bit() expect 'const unsigned long *' (see
include/linux/find.h), but industrialio-core.c passes 'const long *'
in iio_device_add_info_mask_type{,_avail}(). Sparse flags a signedness
mismatch.
The masks are used purely as bit arrays. Cast them to 'const unsigned
long *' at the call sites to match the helpers' prototypes, without
changing memory layout or behavior. Changing the field types would cause
unnecessary churn across IIO.
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
---
drivers/iio/industrialio-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 159d6c5ca3ce..e9491a999ac0 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1248,7 +1248,7 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev,
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
int i, ret, attrcount = 0;
- for_each_set_bit(i, infomask, sizeof(*infomask)*8) {
+ for_each_set_bit(i, (const unsigned long *)infomask, sizeof(*infomask) * 8) {
if (i >= ARRAY_SIZE(iio_chan_info_postfix))
return -EINVAL;
ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
@@ -1279,7 +1279,7 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev,
int i, ret, attrcount = 0;
char *avail_postfix;
- for_each_set_bit(i, infomask, sizeof(*infomask) * 8) {
+ for_each_set_bit(i, (const unsigned long *)infomask, sizeof(*infomask) * 8) {
if (i >= ARRAY_SIZE(iio_chan_info_postfix))
return -EINVAL;
avail_postfix = kasprintf(GFP_KERNEL,
--
2.43.0
next reply other threads:[~2025-08-15 2:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 2:25 Junjie Cao [this message]
2025-08-16 11:10 ` Jonathan Cameron
2025-08-19 9:52 ` Andy Shevchenko
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=20250815022528.24705-1-junjie.cao@intel.com \
--to=junjie.cao@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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
all inboxes | Powered by JetHome®