mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: core: Cast info mask to 'unsigned long *' in bit-ops
@ 2025-08-15  2:25 Junjie Cao
  2025-08-16 11:10 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Junjie Cao @ 2025-08-15  2:25 UTC (permalink / raw)
  To: jic23, linux-iio; +Cc: dlechner, nuno.sa, andy, linux-kernel, Junjie Cao

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-19  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-15  2:25 [PATCH] iio: core: Cast info mask to 'unsigned long *' in bit-ops Junjie Cao
2025-08-16 11:10 ` Jonathan Cameron
2025-08-19  9:52   ` Andy Shevchenko

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®