Skip to contentSkip to conversation

iio: Fix scan mask subset check logic

PATCH Superseded Fabio Estevam 3 participants 18 messages Apr 29, 2025 – May 8, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 iio: Fix scan mask subset check logic

From: Fabio Estevam <[email protected]>

Since commit 2718f15403fb ("iio: sanity check available_scan_masks array"), verbose and misleading warnings are printed for devices like the MAX11601:

max1363 1-0064: available_scan_mask 8 subset of 0. Never used max1363 1-0064: available_scan_mask 9 subset of 0. Never used max1363 1-0064: available_scan_mask 10 subset of 0. Never used max1363 1-0064: available_scan_mask 11 subset of 0. Never used max1363 1-0064: available_scan_mask 12 subset of 0. Never used max1363 1-0064: available_scan_mask 13 subset of 0. Never used
...
[warnings continue]

Fix the available_scan_masks sanity check logic so that it only prints the warning when an element of available_scan_mask is in fact a subset of a previous one.

These warnings incorrectly report that later scan masks are subsets of the first one, even when they are not. The issue lies in the logic that checks for subset relationships between scan masks.

Fix the subset detection to correctly compare each mask only against previous masks, and only warn when a true subset is found.

With this fix, the warning output becomes both correct and more informative:

max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored

Fixes 2718f15403fb ("iio: sanity check available_scan_masks array")
---
 drivers/iio/industrialio-core.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/iio/industrialio-core.c +10 -13
index 6a6568d4a2cb..855d5fd3e6b2 100644
@@ -1904,6 +1904,11 @@ static int iio_check_extended_name(const struct iio_dev *indio_dev)
 
 static const struct iio_buffer_setup_ops noop_ring_setup_ops;
 
+static int is_subset(unsigned long a, unsigned long b)
+{
+	return (a & ~b) == 0;
+}
+
 static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
 {
 	unsigned int num_masks, masklength, longs_per_mask;
@@ -1947,21 +1952,13 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
 	 * available masks in the order of preference (presumably the least
 	 * costy to access masks first).
 	 */
-	for (i = 0; i < num_masks - 1; i++) {
-		const unsigned long *mask1;
-		int j;
 
-		mask1 = av_masks + i * longs_per_mask;
-		for (j = i + 1; j < num_masks; j++) {
-			const unsigned long *mask2;
-
-			mask2 = av_masks + j * longs_per_mask;
-			if (bitmap_subset(mask2, mask1, masklength))
+	for (i = 1; i < num_masks; ++i)
+		for (int j = 0; j < i; ++j)
+			if (is_subset(av_masks[i], av_masks[j]))
 				dev_warn(indio_dev->dev.parent,
-					 "available_scan_mask %d subset of %d. Never used\n",
-					 j, i);
-		}
-	}
+					 "Mask %d (0x%lx) is a subset of mask %d (0x%lx) and will be ignored\n",
+					 i, av_masks[i], j, av_masks[j]);
 }
 
 /**
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 iio: adc: max1363: Reorder max11607_mode_list[]

From: Fabio Estevam <[email protected]>

The IIO core emits warnings when a scan mask is a subset of a previous one in the available_scan_masks array.

In the current max11607_mode_list[], the s0to3 mode (channels 0–3, mask 0xF) precedes the s2to3 mode (channels 2–3, mask 0xC). Since 0xC is a subset of 0xF, the following warning is triggered:

max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored

Reordering the max11607_mode_list[] to place s0to3 after s2to3 ensures that more specific scan modes are listed before broader ones, preventing such warnings.​

This change improves clarity and avoids unnecessary warnings during device initialization.

Fixes 2718f15403fb ("iio: sanity check available_scan_masks array")
---
 drivers/iio/adc/max1363.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/max1363.c +2 -2
index d0c6e94f7204..e8eeb00bef7b 100644
@@ -577,8 +577,8 @@ static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
 
 static const enum max1363_modes max11607_mode_list[] = {
 	_s0, _s1, _s2, _s3,
-	s0to1, s0to2, s0to3,
-	s2to3,
+	s0to1, s0to2, s2to3,
+	s0to3,
 	d0m1, d2m3, d1m0, d3m2,
 	d0m1to2m3, d1m0to3m2,
 };
Signature · 1 line
2.34.1
maintainer
#4 lore raw
In reply to Fabio Estevam
Quoted 14 lines · On Tue, 29 Apr 2025 12:02:12 -0300 Fabio Estevam <[email protected]> wrote:

From: Fabio Estevam <[email protected]>

Since commit 2718f15403fb ("iio: sanity check available_scan_masks array"), verbose and misleading warnings are printed for devices like the MAX11601:

max1363 1-0064: available_scan_mask 8 subset of 0. Never used max1363 1-0064: available_scan_mask 9 subset of 0. Never used max1363 1-0064: available_scan_mask 10 subset of 0. Never used max1363 1-0064: available_scan_mask 11 subset of 0. Never used max1363 1-0064: available_scan_mask 12 subset of 0. Never used max1363 1-0064: available_scan_mask 13 subset of 0. Never used
...
[warnings continue]

Quoted 7 lines

Fix the available_scan_masks sanity check logic so that it only prints the warning when an element of available_scan_mask is in fact a subset of a previous one.

These warnings incorrectly report that later scan masks are subsets of the first one, even when they are not. The issue lies in the logic that checks for subset relationships between scan masks.

Add a little on why the logic is wrong would be good.

I stared at this for a while when you first reported it and couldn't spot it..

Quoted 39 lines

Fix the subset detection to correctly compare each mask only against previous masks, and only warn when a true subset is found.

With this fix, the warning output becomes both correct and more informative:

max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored

Fixes 2718f15403fb ("iio: sanity check available_scan_masks array")
---
 drivers/iio/industrialio-core.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/iio/industrialio-core.c +5 -3
index 6a6568d4a2cb..855d5fd3e6b2 100644
@@ -1904,6 +1904,11 @@ static int iio_check_extended_name(const struct iio_dev *indio_dev)
 
 static const struct iio_buffer_setup_ops noop_ring_setup_ops;
 
+static int is_subset(unsigned long a, unsigned long b)
+{
+	return (a & ~b) == 0;
+}
+
 static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
 {
 	unsigned int num_masks, masklength, longs_per_mask;
@@ -1947,21 +1952,13 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
 	 * available masks in the order of preference (presumably the least
 	 * costy to access masks first).
 	 */
-	for (i = 0; i < num_masks - 1; i++) {
-		const unsigned long *mask1;
-		int j;

drivers/iio/industrialio-core.c static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) · line 1958

Quoted 10 lines
drivers/iio/industrialio-core.c +3 -6
 
-		mask1 = av_masks + i * longs_per_mask;
-		for (j = i + 1; j < num_masks; j++) {
-			const unsigned long *mask2;
-
-			mask2 = av_masks + j * longs_per_mask;
-			if (bitmap_subset(mask2, mask1, masklength))
+	for (i = 1; i < num_masks; ++i)
+		for (int j = 0; j < i; ++j)
+			if (is_subset(av_masks[i], av_masks[j]))

Why move away from the bitmap_subset() call?

There are some broken corners for large bitmaps but I'd rather not make it worse if we can avoid it as the intent is that we can make these larger bitmaps if needed.

Quoted 10 lines
drivers/iio/industrialio-core.c +2 -4
 				dev_warn(indio_dev->dev.parent,
-					 "available_scan_mask %d subset of %d. Never used\n",
-					 j, i);
-		}
-	}
+					 "Mask %d (0x%lx) is a subset of mask %d (0x%lx) and will be ignored\n",
+					 i, av_masks[i], j, av_masks[j]);
 }
 
 /**
maintainer
#2 lore raw

Re: [PATCH 2/2] iio: adc: max1363: Reorder max11607_mode_list[]

In reply to Fabio Estevam
Quoted 15 lines · On Tue, 29 Apr 2025 12:02:13 -0300 Fabio Estevam <[email protected]> wrote:

From: Fabio Estevam <[email protected]>

The IIO core emits warnings when a scan mask is a subset of a previous one in the available_scan_masks array.

In the current max11607_mode_list[], the s0to3 mode (channels 0–3, mask 0xF) precedes the s2to3 mode (channels 2–3, mask 0xC). Since 0xC is a subset of 0xF, the following warning is triggered:

max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored

Reordering the max11607_mode_list[] to place s0to3 after s2to3 ensures that more specific scan modes are listed before broader ones, preventing such warnings.​

Quoted 6 lines

This change improves clarity and avoids unnecessary warnings during device initialization.

Fixes 2718f15403fb ("iio: sanity check available_scan_masks array")

There are others in there that are out of order... max1238_mode_list[] for example looks to be as s6to7 should be before s0to7 (there are more issues with that one).

Would you mind taking a quick look at all those others as I'd like one fix for all of them if possible?

Thanks,

Jonathan

Quoted 19 lines
---
 drivers/iio/adc/max1363.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/max1363.c +2 -2
index d0c6e94f7204..e8eeb00bef7b 100644
@@ -577,8 +577,8 @@ static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
 
 static const enum max1363_modes max11607_mode_list[] = {
 	_s0, _s1, _s2, _s3,
-	s0to1, s0to2, s0to3,
-	s2to3,
+	s0to1, s0to2, s2to3,
+	s0to3,
 	d0m1, d2m3, d1m0, d3m2,
 	d0m1to2m3, d1m0to3m2,
 };
#5 lore raw
In reply to Jonathan Cameron

Hi Jonathan,

Quoted 1 line · Jonathan Cameron

Why move away from the bitmap_subset() call?

I added the following debug patch on top of the original code:

drivers/iio/industrialio-core.c +0 -0
@@ -1947,15 +1947,23 @@ static void

iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
* available masks in the order of preference (presumably the least
* costy to access masks first).
*/
+
+ pr_err("******** masklength is %d", masklength);
+ pr_err("******** longs_per_mask is %d", longs_per_mask);
+

        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;

                mask1 = av_masks + i * longs_per_mask;
+
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]);
+
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;

                        mask2 = av_masks + j * longs_per_mask;

+ pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]);
if (bitmap_subset(mask2, mask1, masklength))
dev_warn(indio_dev->dev.parent,
"available_scan_mask %d
subset of %d. Never used\n",

and saw that the current logic for determining when an element is a subset of a previous one is not working correctly:

[    1.562321] iio-core: ******** masklength is 9
[    1.562334] iio-core: ******** longs_per_mask is 1
[    1.566855] iio-core: ******** mask1[0] is 0x1
[    1.576121] iio-core: ******** mask2[1] is 0x2
[    1.580577] iio-core: ******** mask2[2] is 0x4
[    1.585029] iio-core: ******** mask2[3] is 0x8
[    1.589482] iio-core: ******** mask2[4] is 0x3
[    1.593936] iio-core: ******** mask2[5] is 0x7
[    1.598389] iio-core: ******** mask2[6] is 0xf
[    1.602840] iio-core: ******** mask2[7] is 0xc
[    1.607294] iio-core: ******** mask2[8] is 0x1000
[    1.612013] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
[    1.618814] iio-core: ******** mask2[9] is 0x2000
[    1.623530] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
[    1.630328] iio-core: ******** mask2[10] is 0x40000
[    1.635224] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.642112] iio-core: ******** mask2[11] is 0x80000
[    1.647001] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.653886] iio-core: ******** mask2[12] is 0x3000
[    1.658687] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
[    1.665571] iio-core: ******** mask2[13] is 0xc0000
[    1.670461] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.677350] iio-core: ******** mask1[1] is 0x4
[    1.681811] iio-core: ******** mask2[2] is 0x8
[    1.686272] iio-core: ******** mask2[3] is 0x3
[    1.690724] iio-core: ******** mask2[4] is 0x7
[    1.695175] iio-core: ******** mask2[5] is 0xf
[    1.699626] iio-core: ******** mask2[6] is 0xc
[    1.704078] iio-core: ******** mask2[7] is 0x1000
[    1.708791] iio-core: ******** mask2[8] is 0x2000
[    1.713506] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
[    1.720305] iio-core: ******** mask2[9] is 0x40000
[    1.725106] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
[    1.731903] iio-core: ******** mask2[10] is 0x80000
[    1.736793] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.743676] iio-core: ******** mask2[11] is 0x3000
[    1.748478] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.755363] iio-core: ******** mask2[12] is 0xc0000
[    1.760251] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
[    1.767136] iio-core: ******** mask2[13] is 0x0
[    1.771677] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.778562] iio-core: ******** mask1[2] is 0x3
[    1.783015] iio-core: ******** mask2[3] is 0x7
[    1.787470] iio-core: ******** mask2[4] is 0xf
[    1.791922] iio-core: ******** mask2[5] is 0xc
[    1.796403] iio-core: ******** mask2[6] is 0x1000
[    1.801116] iio-core: ******** mask2[7] is 0x2000
[    1.805830] iio-core: ******** mask2[8] is 0x40000
[    1.810636] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
[    1.817433] iio-core: ******** mask2[9] is 0x80000
[    1.822235] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
[    1.829033] iio-core: ******** mask2[10] is 0x3000
[    1.833832] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.840719] iio-core: ******** mask2[11] is 0xc0000
[    1.845607] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.852491] iio-core: ******** mask2[12] is 0x0
[    1.857029] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
[    1.863915] iio-core: ******** mask2[13] is 0x0
[    1.868456] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.875341] iio-core: ******** mask1[3] is 0xf
[    1.879794] iio-core: ******** mask2[4] is 0xc
[    1.884246] iio-core: ******** mask2[5] is 0x1000
[    1.888960] iio-core: ******** mask2[6] is 0x2000
[    1.893674] iio-core: ******** mask2[7] is 0x40000
[    1.898475] iio-core: ******** mask2[8] is 0x80000
[    1.903276] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
[    1.910074] iio-core: ******** mask2[9] is 0x3000
[    1.914788] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
[    1.921586] iio-core: ******** mask2[10] is 0xc0000
[    1.926474] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.933360] iio-core: ******** mask2[11] is 0x0
[    1.937906] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.944794] iio-core: ******** mask2[12] is 0x0
[    1.949334] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
[    1.956219] iio-core: ******** mask2[13] is 0xffff0000012b5480
[    1.962063] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.968948] iio-core: ******** mask1[4] is 0x1000
[    1.973659] iio-core: ******** mask2[5] is 0x2000
[    1.978372] iio-core: ******** mask2[6] is 0x40000
[    1.983172] iio-core: ******** mask2[7] is 0x80000
[    1.987972] iio-core: ******** mask2[8] is 0x3000
[    1.992686] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
[    1.999484] iio-core: ******** mask2[9] is 0xc0000
[    2.004289] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
[    2.011087] iio-core: ******** mask2[10] is 0x0
[    2.015629] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    2.022514] iio-core: ******** mask2[11] is 0x0
[    2.027054] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    2.033939] iio-core: ******** mask2[12] is 0xffff0000012b5480
[    2.039783] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
[    2.046668] iio-core: ******** mask2[13] is 0xffff0000012b5420
[    2.052513] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    2.059404] iio-core: ******** mask1[5] is 0x40000
[    2.064203] iio-core: ******** mask2[6] is 0x80000
[    2.069003] iio-core: ******** mask2[7] is 0x3000
[    2.073716] iio-core: ******** mask2[8] is 0xc0000
[    2.078518] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
[    2.085316] iio-core: ******** mask2[9] is 0x0
[    2.089769] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
[    2.096567] iio-core: ******** mask2[10] is 0x0
[    2.101107] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    2.107993] iio-core: ******** mask2[11] is 0xffff0000012b5480
[    2.113836] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.120721] iio-core: ******** mask2[12] is 0xffff0000012b5420
[    2.126564] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
[    2.133449] iio-core: ******** mask2[13] is 0xffff0000012b53c0
[    2.139292] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.146182] iio-core: ******** mask1[6] is 0x3000
[    2.150898] iio-core: ******** mask2[7] is 0xc0000
[    2.155699] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    2.162499] iio-core: ******** mask2[8] is 0x0
[    2.166952] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
[    2.173750] iio-core: ******** mask2[9] is 0x0
[    2.178204] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
[    2.185006] iio-core: ******** mask2[10] is 0xffff0000012b5480
[    2.190850] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.197735] iio-core: ******** mask2[11] is 0xffff0000012b5420
[    2.203578] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.210463] iio-core: ******** mask2[12] is 0xffff0000012b53c0
[    2.216307] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
[    2.223194] iio-core: ******** mask2[13] is 0xffff0000012b5360
[    2.229041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.235926] iio-core: ******** mask1[7] is 0x0
[    2.240378] iio-core: ******** mask2[8] is 0x0
[    2.244831] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
[    2.251629] iio-core: ******** mask2[9] is 0xffff0000012b5480
[    2.257385] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
[    2.264183] iio-core: ******** mask2[10] is 0xffff0000012b5420
[    2.270032] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.276914] iio-core: ******** mask2[11] is 0xffff0000012b53c0
[    2.282757] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.289640] iio-core: ******** mask2[12] is 0xffff0000012b5360
[    2.295483] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
[    2.302367] iio-core: ******** mask2[13] is 0xffff0000012b5300
[    2.308215] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.315101] iio-core: ******** mask1[8] is 0xffff0000012b5480
[    2.320857] iio-core: ******** mask2[9] is 0xffff0000012b5420
[    2.326613] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
[    2.333411] iio-core: ******** mask2[10] is 0xffff0000012b53c0
[    2.339254] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.346138] iio-core: ******** mask2[11] is 0xffff0000012b5360
[    2.351981] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.358867] iio-core: ******** mask2[12] is 0xffff0000012b5300
[    2.364710] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
[    2.371594] iio-core: ******** mask2[13] is 0xffff0000012b52a0
[    2.377437] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.384322] iio-core: ******** mask1[9] is 0xffff0000012b53c0
[    2.390077] iio-core: ******** mask2[10] is 0xffff0000012b5360
[    2.395921] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.402805] iio-core: ******** mask2[11] is 0xffff0000012b5300
[    2.408648] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.415533] iio-core: ******** mask2[12] is 0xffff0000012b52a0
[    2.421376] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
[    2.428262] iio-core: ******** mask2[13] is 0xffff0000012b5240
[    2.434108] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.440993] iio-core: ******** mask1[10] is 0xffff0000012b5300
[    2.446836] iio-core: ******** mask2[11] is 0xffff0000012b52a0
[    2.452679] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.459651] iio-core: ******** mask2[12] is 0xffff0000012b5240
[    2.465494] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
[    2.472466] iio-core: ******** mask2[13] is 0xffff0000012b51e0
[    2.478309] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.485281] iio-core: ******** mask1[11] is 0xffff0000012b5240
[    2.491123] iio-core: ******** mask2[12] is 0xffff0000012b51e0
[    2.496966] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
[    2.503939] iio-core: ******** mask2[13] is 0xffff0000012b5180
[    2.509780] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.516752] iio-core: ******** mask1[12] is 0xffff0000012b5180
[    2.522594] iio-core: ******** mask2[13] is 0xffff0000012b5120
[    2.528436] max1363 1-0064: available_scan_mask 13 subset of 12. Never used

That's why I decided to implement a new one that I have validated on a PC.

I am open to suggestions.

Thanks

#3 lore raw

Re: [PATCH 2/2] iio: adc: max1363: Reorder max11607_mode_list[]

In reply to Jonathan Cameron
Quoted 6 lines · Jonathan Cameron

There are others in there that are out of order... max1238_mode_list[] for example looks to be as s6to7 should be before s0to7 (there are more issues with that one).

Would you mind taking a quick look at all those others as I'd like one fix for all of them if possible?

Yes, I can fix all of them.

#6 lore raw
In reply to Fabio Estevam
Quoted 1 line · Fabio Estevam

+ pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]);

Sorry, this line is wrong.

The correct debug patch is this one:

drivers/iio/industrialio-core.c +0 -0
@@ -1947,15 +1947,23 @@ static void

iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
* available masks in the order of preference (presumably the least
* costy to access masks first).
*/
+
+ pr_err("******** masklength is %d", masklength);
+ pr_err("******** longs_per_mask is %d", longs_per_mask);
+

        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;

                mask1 = av_masks + i * longs_per_mask;
+
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]);
+
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;

                        mask2 = av_masks + j * longs_per_mask;

+ pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[j]);
if (bitmap_subset(mask2, mask1, masklength))
dev_warn(indio_dev->dev.parent,
"available_scan_mask %d
subset of %d. Never used\n",
The original mask array is:

0x1,
0x2,
0x4,
0x8,
0x3,
0x7,
0xf,
0xc,
0x1000,
0x2000,
0x40000,
0x80000,
0x3000,
0xc0000,

So mask2 is jumping by two indexes, instead of one.

mask1 and mask2 arrays are accessing uninitialized data:

[    1.561626] iio-core: ******** masklength is 9
[    1.561639] iio-core: ******** longs_per_mask is 1
[    1.566130] iio-core: ******** mask1[0] is 0x1
[    1.570945] iio-core: ******** mask2[1] is 0x4
[    1.584554] iio-core: ******** mask2[2] is 0x3
[    1.589012] iio-core: ******** mask2[3] is 0xf
[    1.593465] iio-core: ******** mask2[4] is 0x1000
[    1.598183] iio-core: ******** mask2[5] is 0x40000
[    1.602981] iio-core: ******** mask2[6] is 0x3000
[    1.607702] iio-core: ******** mask2[7] is 0x0
[    1.612157] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.617925] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
[    1.624723] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.630493] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
[    1.637297] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.643141] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.650032] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.655876] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.662772] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.668614] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
[    1.675506] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.681361] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.688257] iio-core: ******** mask1[1] is 0x4
[    1.692725] iio-core: ******** mask2[2] is 0x3
[    1.697185] iio-core: ******** mask2[3] is 0xf
[    1.701642] iio-core: ******** mask2[4] is 0x1000
[    1.706361] iio-core: ******** mask2[5] is 0x40000
[    1.711163] iio-core: ******** mask2[6] is 0x3000
[    1.715880] iio-core: ******** mask2[7] is 0x0
[    1.720335] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.726097] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
[    1.732899] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.738659] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
[    1.745463] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.751307] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.758197] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.764044] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.770933] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.776776] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
[    1.783671] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.789521] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.796407] iio-core: ******** mask1[2] is 0x3
[    1.800864] iio-core: ******** mask2[3] is 0xf
[    1.805319] iio-core: ******** mask2[4] is 0x1000
[    1.810046] iio-core: ******** mask2[5] is 0x40000
[    1.814848] iio-core: ******** mask2[6] is 0x3000
[    1.819563] iio-core: ******** mask2[7] is 0x0
[    1.824014] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.829769] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
[    1.836566] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.842322] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
[    1.849149] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.854994] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.861880] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.867723] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.874608] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.880452] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
[    1.887339] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.893182] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.900068] iio-core: ******** mask1[3] is 0xf
[    1.904520] iio-core: ******** mask2[4] is 0x1000
[    1.909232] iio-core: ******** mask2[5] is 0x40000
[    1.914033] iio-core: ******** mask2[6] is 0x3000
[    1.918746] iio-core: ******** mask2[7] is 0x0
[    1.923200] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.928956] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
[    1.935759] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.941517] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
[    1.948315] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.954156] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.961042] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.966885] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.973771] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.979614] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
[    1.986499] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.992343] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.999226] iio-core: ******** mask1[4] is 0x1000
[    2.003943] iio-core: ******** mask2[5] is 0x40000
[    2.008743] iio-core: ******** mask2[6] is 0x3000
[    2.013457] iio-core: ******** mask2[7] is 0x0
[    2.017910] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.023666] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
[    2.030464] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.036220] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
[    2.043019] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.048863] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    2.055748] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.061596] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    2.068482] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.074326] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
[    2.081212] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.087055] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    2.093938] iio-core: ******** mask1[5] is 0x40000
[    2.098739] iio-core: ******** mask2[6] is 0x3000
[    2.103452] iio-core: ******** mask2[7] is 0x0
[    2.107905] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.113661] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
[    2.120459] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.126215] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
[    2.133013] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.138857] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    2.145750] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.151595] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.158480] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.164323] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
[    2.171208] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.177051] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.183936] iio-core: ******** mask1[6] is 0x3000
[    2.188654] iio-core: ******** mask2[7] is 0x0
[    2.193106] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    2.199904] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.205660] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
[    2.212458] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.218215] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
[    2.225012] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.230855] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.237740] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.243583] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.250470] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.256313] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
[    2.263198] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.269041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.275926] iio-core: ******** mask1[7] is 0x0
[    2.280379] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.286135] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
[    2.292934] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.298689] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
[    2.305488] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.311336] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.318221] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.324065] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.330949] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.336792] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
[    2.343677] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.349520] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.356406] iio-core: ******** mask1[8] is 0xffff0000000e2720
[    2.362162] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.367918] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
[    2.374716] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.380559] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.387444] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.393287] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.400172] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.406015] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
[    2.412901] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.418744] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.425629] iio-core: ******** mask1[9] is 0xffff0000000e2660
[    2.431384] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.437231] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.444117] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.449961] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.456846] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.462689] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
[    2.469575] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.475417] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.482303] iio-core: ******** mask1[10] is 0xffff0000000e25a0
[    2.488145] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.493988] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.500957] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.506800] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
[    2.513772] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.519615] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.526587] iio-core: ******** mask1[11] is 0xffff0000000e24e0
[    2.532429] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.538272] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
[    2.545244] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.551087] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.558060] iio-core: ******** mask1[12] is 0xffff0000000e2420
[    2.563906] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.569747] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
#7 lore raw
Quoted 16 lines · On Tue, 29 Apr 2025 16:05:55 -0300 Fabio Estevam <[email protected]> wrote:
Quoted 1 line · Fabio Estevam

+ pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]);

Sorry, this line is wrong.

The correct debug patch is this one:

drivers/iio/industrialio-core.c +1 -0
@@ -1947,15 +1947,23 @@ static void
 iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
         * available masks in the order of preference (presumably the least
         * costy to access masks first).
         */
+

drivers/iio/industrialio-core.c static void · line 1961

Quoted 10 lines
drivers/iio/industrialio-core.c +5 -0
+       pr_err("******** masklength is %d", masklength);
+       pr_err("******** longs_per_mask is %d", longs_per_mask);
+
        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;
 
                mask1 = av_masks + i * longs_per_mask;
+
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]);

As below. Should be mask1[0] as we've already indexed the array with the above calculation.

drivers/iio/industrialio-core.c static void · line 1967

Quoted 6 lines
drivers/iio/industrialio-core.c +2 -0
+
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;
 
                        mask2 = av_masks + j * longs_per_mask;
+                       pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[j]);

Should print mask2[0] as the calculation already found the offset into the array.

Jonathan

Quoted 21 lines
drivers/iio/industrialio-core.c +0 -0
                        if (bitmap_subset(mask2, mask1, masklength))
                                dev_warn(indio_dev->dev.parent,

"available_scan_mask %d
subset of %d. Never used\n",
The original mask array is:

0x1,
0x2,
0x4,
0x8,
0x3,
0x7,
0xf,
0xc,
0x1000,
0x2000,
0x40000,
0x80000,
0x3000,
0xc0000,

Quoted 1 line

So mask2 is jumping by two indexes, instead of one.

I think this is a false positive due to the bug in the debug prints above.

Quoted 174 lines

mask1 and mask2 arrays are accessing uninitialized data:

[    1.561626] iio-core: ******** masklength is 9
[    1.561639] iio-core: ******** longs_per_mask is 1
[    1.566130] iio-core: ******** mask1[0] is 0x1
[    1.570945] iio-core: ******** mask2[1] is 0x4
[    1.584554] iio-core: ******** mask2[2] is 0x3
[    1.589012] iio-core: ******** mask2[3] is 0xf
[    1.593465] iio-core: ******** mask2[4] is 0x1000
[    1.598183] iio-core: ******** mask2[5] is 0x40000
[    1.602981] iio-core: ******** mask2[6] is 0x3000
[    1.607702] iio-core: ******** mask2[7] is 0x0
[    1.612157] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.617925] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
[    1.624723] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.630493] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
[    1.637297] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.643141] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.650032] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.655876] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.662772] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.668614] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
[    1.675506] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.681361] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.688257] iio-core: ******** mask1[1] is 0x4
[    1.692725] iio-core: ******** mask2[2] is 0x3
[    1.697185] iio-core: ******** mask2[3] is 0xf
[    1.701642] iio-core: ******** mask2[4] is 0x1000
[    1.706361] iio-core: ******** mask2[5] is 0x40000
[    1.711163] iio-core: ******** mask2[6] is 0x3000
[    1.715880] iio-core: ******** mask2[7] is 0x0
[    1.720335] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.726097] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
[    1.732899] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.738659] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
[    1.745463] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.751307] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.758197] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.764044] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.770933] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.776776] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
[    1.783671] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.789521] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.796407] iio-core: ******** mask1[2] is 0x3
[    1.800864] iio-core: ******** mask2[3] is 0xf
[    1.805319] iio-core: ******** mask2[4] is 0x1000
[    1.810046] iio-core: ******** mask2[5] is 0x40000
[    1.814848] iio-core: ******** mask2[6] is 0x3000
[    1.819563] iio-core: ******** mask2[7] is 0x0
[    1.824014] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.829769] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
[    1.836566] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.842322] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
[    1.849149] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.854994] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.861880] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.867723] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.874608] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.880452] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
[    1.887339] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.893182] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.900068] iio-core: ******** mask1[3] is 0xf
[    1.904520] iio-core: ******** mask2[4] is 0x1000
[    1.909232] iio-core: ******** mask2[5] is 0x40000
[    1.914033] iio-core: ******** mask2[6] is 0x3000
[    1.918746] iio-core: ******** mask2[7] is 0x0
[    1.923200] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    1.928956] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
[    1.935759] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    1.941517] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
[    1.948315] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    1.954156] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.961042] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    1.966885] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.973771] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    1.979614] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
[    1.986499] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    1.992343] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.999226] iio-core: ******** mask1[4] is 0x1000
[    2.003943] iio-core: ******** mask2[5] is 0x40000
[    2.008743] iio-core: ******** mask2[6] is 0x3000
[    2.013457] iio-core: ******** mask2[7] is 0x0
[    2.017910] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.023666] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
[    2.030464] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.036220] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
[    2.043019] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.048863] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    2.055748] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.061596] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    2.068482] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.074326] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
[    2.081212] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.087055] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    2.093938] iio-core: ******** mask1[5] is 0x40000
[    2.098739] iio-core: ******** mask2[6] is 0x3000
[    2.103452] iio-core: ******** mask2[7] is 0x0
[    2.107905] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.113661] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
[    2.120459] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.126215] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
[    2.133013] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.138857] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    2.145750] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.151595] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.158480] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.164323] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
[    2.171208] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.177051] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.183936] iio-core: ******** mask1[6] is 0x3000
[    2.188654] iio-core: ******** mask2[7] is 0x0
[    2.193106] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    2.199904] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.205660] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
[    2.212458] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.218215] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
[    2.225012] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.230855] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.237740] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.243583] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.250470] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.256313] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
[    2.263198] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.269041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.275926] iio-core: ******** mask1[7] is 0x0
[    2.280379] iio-core: ******** mask2[8] is 0xffff0000000e2720
[    2.286135] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
[    2.292934] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.298689] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
[    2.305488] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.311336] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.318221] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.324065] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.330949] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.336792] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
[    2.343677] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.349520] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.356406] iio-core: ******** mask1[8] is 0xffff0000000e2720
[    2.362162] iio-core: ******** mask2[9] is 0xffff0000000e2660
[    2.367918] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
[    2.374716] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.380559] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.387444] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.393287] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.400172] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.406015] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
[    2.412901] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.418744] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.425629] iio-core: ******** mask1[9] is 0xffff0000000e2660
[    2.431384] iio-core: ******** mask2[10] is 0xffff0000000e25a0
[    2.437231] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.444117] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.449961] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.456846] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.462689] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
[    2.469575] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.475417] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.482303] iio-core: ******** mask1[10] is 0xffff0000000e25a0
[    2.488145] iio-core: ******** mask2[11] is 0xffff0000000e24e0
[    2.493988] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.500957] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.506800] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
[    2.513772] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.519615] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.526587] iio-core: ******** mask1[11] is 0xffff0000000e24e0
[    2.532429] iio-core: ******** mask2[12] is 0xffff0000000e2420
[    2.538272] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
[    2.545244] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.551087] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.558060] iio-core: ******** mask1[12] is 0xffff0000000e2420
[    2.563906] iio-core: ******** mask2[13] is 0xffff0000000e2360
[    2.569747] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
#8 lore raw
Quoted 2 lines · Jonathan Cameron

As below. Should be mask1[0] as we've already indexed the array with the above calculation.

Thanks for catching that bug.

Now I get:

[    1.556734] iio-core: ******** masklength is 9
[    1.559663] iio-core: ******** longs_per_mask is 1
[    1.564119] iio-core: ******** mask1[0] is 0x1
[    1.573367] iio-core: ******** mask2[0] is 0x2
[    1.577822] iio-core: ******** mask2[0] is 0x4
[    1.582279] iio-core: ******** mask2[0] is 0x8
[    1.586738] iio-core: ******** mask2[0] is 0x3
[    1.591198] iio-core: ******** mask2[0] is 0x7
[    1.595654] iio-core: ******** mask2[0] is 0xf
[    1.600110] iio-core: ******** mask2[0] is 0xc
[    1.604560] iio-core: ******** mask2[0] is 0x1000
[    1.609278] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
[    1.616084] iio-core: ******** mask2[0] is 0x2000
[    1.620799] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
[    1.627602] iio-core: ******** mask2[0] is 0x40000
[    1.632408] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.639303] iio-core: ******** mask2[0] is 0x80000
[    1.644105] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.650995] iio-core: ******** mask2[0] is 0x3000
[    1.655713] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
[    1.662606] iio-core: ******** mask2[0] is 0xc0000
[    1.667412] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.674309] iio-core: ******** mask1[1] is 0x2
[    1.678761] iio-core: ******** mask2[1] is 0x4
[    1.683212] iio-core: ******** mask2[1] is 0x8
[    1.687666] iio-core: ******** mask2[1] is 0x3
[    1.692118] iio-core: ******** mask2[1] is 0x7
[    1.696576] iio-core: ******** mask2[1] is 0xf
[    1.701029] iio-core: ******** mask2[1] is 0xc
[    1.705483] iio-core: ******** mask2[1] is 0x1000
[    1.710199] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
[    1.716996] iio-core: ******** mask2[1] is 0x2000
[    1.721711] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
[    1.728510] iio-core: ******** mask2[1] is 0x40000
[    1.733317] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.740212] iio-core: ******** mask2[1] is 0x80000
[    1.745013] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.751899] iio-core: ******** mask2[1] is 0x3000
[    1.756612] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
[    1.763503] iio-core: ******** mask2[1] is 0xc0000
[    1.768306] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.775193] iio-core: ******** mask1[2] is 0x4
[    1.779650] iio-core: ******** mask2[2] is 0x8
[    1.784117] iio-core: ******** mask2[2] is 0x3
[    1.788570] iio-core: ******** mask2[2] is 0x7
[    1.793023] iio-core: ******** mask2[2] is 0xf
[    1.797476] iio-core: ******** mask2[2] is 0xc
[    1.801934] iio-core: ******** mask2[2] is 0x1000
[    1.806650] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
[    1.813447] iio-core: ******** mask2[2] is 0x2000
[    1.818162] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
[    1.824961] iio-core: ******** mask2[2] is 0x40000
[    1.829764] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.836649] iio-core: ******** mask2[2] is 0x80000
[    1.841450] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.848336] iio-core: ******** mask2[2] is 0x3000
[    1.853049] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
[    1.859934] iio-core: ******** mask2[2] is 0xc0000
[    1.864740] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.871626] iio-core: ******** mask1[3] is 0x8
[    1.876079] iio-core: ******** mask2[3] is 0x3
[    1.880533] iio-core: ******** mask2[3] is 0x7
[    1.884985] iio-core: ******** mask2[3] is 0xf
[    1.889439] iio-core: ******** mask2[3] is 0xc
[    1.893891] iio-core: ******** mask2[3] is 0x1000
[    1.898605] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
[    1.905403] iio-core: ******** mask2[3] is 0x2000
[    1.910122] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
[    1.916921] iio-core: ******** mask2[3] is 0x40000
[    1.921724] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.928610] iio-core: ******** mask2[3] is 0x80000
[    1.933413] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.940297] iio-core: ******** mask2[3] is 0x3000
[    1.945012] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
[    1.951897] iio-core: ******** mask2[3] is 0xc0000
[    1.956698] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.963584] iio-core: ******** mask1[4] is 0x3
[    1.968037] iio-core: ******** mask2[4] is 0x7
[    1.972489] iio-core: ******** mask2[4] is 0xf
[    1.976942] iio-core: ******** mask2[4] is 0xc
[    1.981394] iio-core: ******** mask2[4] is 0x1000
[    1.986113] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
[    1.992915] iio-core: ******** mask2[4] is 0x2000
[    1.997626] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
[    2.004429] iio-core: ******** mask2[4] is 0x40000
[    2.009230] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    2.016120] iio-core: ******** mask2[4] is 0x80000
[    2.020922] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    2.027807] iio-core: ******** mask2[4] is 0x3000
[    2.032522] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
[    2.039408] iio-core: ******** mask2[4] is 0xc0000
[    2.044210] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    2.051095] iio-core: ******** mask1[5] is 0x7
[    2.055548] iio-core: ******** mask2[5] is 0xf
[    2.060000] iio-core: ******** mask2[5] is 0xc
[    2.064453] iio-core: ******** mask2[5] is 0x1000
[    2.069167] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
[    2.075966] iio-core: ******** mask2[5] is 0x2000
[    2.080680] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
[    2.087478] iio-core: ******** mask2[5] is 0x40000
[    2.092280] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    2.099166] iio-core: ******** mask2[5] is 0x80000
[    2.103967] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.110858] iio-core: ******** mask2[5] is 0x3000
[    2.115573] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
[    2.122463] iio-core: ******** mask2[5] is 0xc0000
[    2.127265] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.134150] iio-core: ******** mask1[6] is 0xf
[    2.138602] iio-core: ******** mask2[6] is 0xc
[    2.143056] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    2.149862] iio-core: ******** mask2[6] is 0x1000
[    2.154578] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
[    2.161374] iio-core: ******** mask2[6] is 0x2000
[    2.166089] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
[    2.172886] iio-core: ******** mask2[6] is 0x40000
[    2.177687] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.184573] iio-core: ******** mask2[6] is 0x80000
[    2.189372] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.196257] iio-core: ******** mask2[6] is 0x3000
[    2.200973] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
[    2.207858] iio-core: ******** mask2[6] is 0xc0000
[    2.212659] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.219544] iio-core: ******** mask1[7] is 0xc
[    2.223996] iio-core: ******** mask2[7] is 0x1000
[    2.228715] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
[    2.235518] iio-core: ******** mask2[7] is 0x2000
[    2.240234] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
[    2.247030] iio-core: ******** mask2[7] is 0x40000
[    2.251832] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.258717] iio-core: ******** mask2[7] is 0x80000
[    2.263518] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.270403] iio-core: ******** mask2[7] is 0x3000
[    2.275117] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
[    2.282002] iio-core: ******** mask2[7] is 0xc0000
[    2.286803] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.293688] iio-core: ******** mask1[8] is 0x1000
[    2.298401] iio-core: ******** mask2[8] is 0x2000
[    2.303116] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
[    2.309914] iio-core: ******** mask2[8] is 0x40000
[    2.314715] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.321600] iio-core: ******** mask2[8] is 0x80000
[    2.326401] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.333289] iio-core: ******** mask2[8] is 0x3000
[    2.338004] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
[    2.344889] iio-core: ******** mask2[8] is 0xc0000
[    2.349691] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.356577] iio-core: ******** mask1[9] is 0x2000
[    2.361294] iio-core: ******** mask2[9] is 0x40000
[    2.366094] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.372977] iio-core: ******** mask2[9] is 0x80000
[    2.377778] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.384663] iio-core: ******** mask2[9] is 0x3000
[    2.389377] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
[    2.396262] iio-core: ******** mask2[9] is 0xc0000
[    2.401063] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.407948] iio-core: ******** mask1[10] is 0x40000
[    2.412835] iio-core: ******** mask2[10] is 0x80000
[    2.417723] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.424696] iio-core: ******** mask2[10] is 0x3000
[    2.429497] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
[    2.436471] iio-core: ******** mask2[10] is 0xc0000
[    2.441359] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.448331] iio-core: ******** mask1[11] is 0x80000
[    2.453218] iio-core: ******** mask2[11] is 0x3000
[    2.458020] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
[    2.464991] iio-core: ******** mask2[11] is 0xc0000
[    2.469879] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.476860] iio-core: ******** mask1[12] is 0x3000
[    2.481659] iio-core: ******** mask2[12] is 0xc0000
[    2.486551] max1363 1-0064: available_scan_mask 13 subset of 12. Never used

Who sets masklength = 9? Is this correct?

If I use BITS_PER_LONG instead of masklength inside bitmap_subset():

drivers/iio/industrialio-core.c +0 -0
@@ -1947,16 +1947,22 @@ static void

iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
* available masks in the order of preference (presumably the least
* costy to access masks first).
*/
+ pr_err("******** masklength is %d", masklength);
+ pr_err("******** longs_per_mask is %d", longs_per_mask);
+
+

        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;

                mask1 = av_masks + i * longs_per_mask;
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[0]);
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;

                        mask2 = av_masks + j * longs_per_mask;
-                       if (bitmap_subset(mask2, mask1, masklength))
+                       pr_err("******** mask2[%d] is 0x%lx\n", i, mask2[0]);
+                       if (bitmap_subset(mask2, mask1, BITS_PER_LONG))
                                dev_warn(indio_dev->dev.parent,
                                         "available_scan_mask %d
subset of %d. Never used\n",
                                         j, i);

Then the correct subset information is printed:

[    1.560392] iio-core: ******** masklength is 9
[    1.560406] iio-core: ******** longs_per_mask is 1
[    1.564890] iio-core: ******** mask1[0] is 0x1
[    1.574185] iio-core: ******** mask2[0] is 0x2
[    1.578644] iio-core: ******** mask2[0] is 0x4
[    1.583108] iio-core: ******** mask2[0] is 0x8
[    1.587564] iio-core: ******** mask2[0] is 0x3
[    1.592024] iio-core: ******** mask2[0] is 0x7
[    1.596486] iio-core: ******** mask2[0] is 0xf
[    1.600948] iio-core: ******** mask2[0] is 0xc
[    1.605407] iio-core: ******** mask2[0] is 0x1000
[    1.610130] iio-core: ******** mask2[0] is 0x2000
[    1.614856] iio-core: ******** mask2[0] is 0x40000
[    1.619670] iio-core: ******** mask2[0] is 0x80000
[    1.624475] iio-core: ******** mask2[0] is 0x3000
[    1.629199] iio-core: ******** mask2[0] is 0xc0000
[    1.634017] iio-core: ******** mask1[1] is 0x2
[    1.638475] iio-core: ******** mask2[1] is 0x4
[    1.642941] iio-core: ******** mask2[1] is 0x8
[    1.647401] iio-core: ******** mask2[1] is 0x3
[    1.651865] iio-core: ******** mask2[1] is 0x7
[    1.656321] iio-core: ******** mask2[1] is 0xf
[    1.660786] iio-core: ******** mask2[1] is 0xc
[    1.665245] iio-core: ******** mask2[1] is 0x1000
[    1.669968] iio-core: ******** mask2[1] is 0x2000
[    1.674691] iio-core: ******** mask2[1] is 0x40000
[    1.679505] iio-core: ******** mask2[1] is 0x80000
[    1.684345] iio-core: ******** mask2[1] is 0x3000
[    1.689069] iio-core: ******** mask2[1] is 0xc0000
[    1.693872] iio-core: ******** mask1[2] is 0x4
[    1.698331] iio-core: ******** mask2[2] is 0x8
[    1.702788] iio-core: ******** mask2[2] is 0x3
[    1.707246] iio-core: ******** mask2[2] is 0x7
[    1.711702] iio-core: ******** mask2[2] is 0xf
[    1.716156] iio-core: ******** mask2[2] is 0xc
[    1.720614] iio-core: ******** mask2[2] is 0x1000
[    1.725333] iio-core: ******** mask2[2] is 0x2000
[    1.730046] iio-core: ******** mask2[2] is 0x40000
[    1.734850] iio-core: ******** mask2[2] is 0x80000
[    1.739665] iio-core: ******** mask2[2] is 0x3000
[    1.744385] iio-core: ******** mask2[2] is 0xc0000
[    1.749192] iio-core: ******** mask1[3] is 0x8
[    1.753654] iio-core: ******** mask2[3] is 0x3
[    1.758112] iio-core: ******** mask2[3] is 0x7
[    1.762570] iio-core: ******** mask2[3] is 0xf
[    1.767027] iio-core: ******** mask2[3] is 0xc
[    1.771484] iio-core: ******** mask2[3] is 0x1000
[    1.776203] iio-core: ******** mask2[3] is 0x2000
[    1.780921] iio-core: ******** mask2[3] is 0x40000
[    1.785727] iio-core: ******** mask2[3] is 0x80000
[    1.790531] iio-core: ******** mask2[3] is 0x3000
[    1.795253] iio-core: ******** mask2[3] is 0xc0000
[    1.800059] iio-core: ******** mask1[4] is 0x3
[    1.804515] iio-core: ******** mask2[4] is 0x7
[    1.808970] iio-core: ******** mask2[4] is 0xf
[    1.813427] iio-core: ******** mask2[4] is 0xc
[    1.817891] iio-core: ******** mask2[4] is 0x1000
[    1.822608] iio-core: ******** mask2[4] is 0x2000
[    1.827336] iio-core: ******** mask2[4] is 0x40000
[    1.832164] iio-core: ******** mask2[4] is 0x80000
[    1.836970] iio-core: ******** mask2[4] is 0x3000
[    1.841690] iio-core: ******** mask2[4] is 0xc0000
[    1.846495] iio-core: ******** mask1[5] is 0x7
[    1.850953] iio-core: ******** mask2[5] is 0xf
[    1.855409] iio-core: ******** mask2[5] is 0xc
[    1.859867] iio-core: ******** mask2[5] is 0x1000
[    1.864590] iio-core: ******** mask2[5] is 0x2000
[    1.869310] iio-core: ******** mask2[5] is 0x40000
[    1.874116] iio-core: ******** mask2[5] is 0x80000
[    1.878918] iio-core: ******** mask2[5] is 0x3000
[    1.883636] iio-core: ******** mask2[5] is 0xc0000
[    1.888442] iio-core: ******** mask1[6] is 0xf
[    1.892900] iio-core: ******** mask2[6] is 0xc
[    1.897364] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    1.904169] iio-core: ******** mask2[6] is 0x1000
[    1.908887] iio-core: ******** mask2[6] is 0x2000
[    1.913603] iio-core: ******** mask2[6] is 0x40000
[    1.918409] iio-core: ******** mask2[6] is 0x80000
[    1.923212] iio-core: ******** mask2[6] is 0x3000
[    1.927930] iio-core: ******** mask2[6] is 0xc0000
[    1.932733] iio-core: ******** mask1[7] is 0xc
[    1.937190] iio-core: ******** mask2[7] is 0x1000
[    1.941902] iio-core: ******** mask2[7] is 0x2000
[    1.941907] iio-core: ******** mask2[7] is 0x40000
[    1.941911] iio-core: ******** mask2[7] is 0x80000
[    1.941917] iio-core: ******** mask2[7] is 0x3000
[    1.965640] iio-core: ******** mask2[7] is 0xc0000
[    1.970447] iio-core: ******** mask1[8] is 0x1000
[    1.975163] iio-core: ******** mask2[8] is 0x2000
[    1.979881] iio-core: ******** mask2[8] is 0x40000
[    1.984683] iio-core: ******** mask2[8] is 0x80000
[    1.989491] iio-core: ******** mask2[8] is 0x3000
[    1.994209] iio-core: ******** mask2[8] is 0xc0000
[    1.999010] iio-core: ******** mask1[9] is 0x2000
[    2.003732] iio-core: ******** mask2[9] is 0x40000
[    2.008533] iio-core: ******** mask2[9] is 0x80000
[    2.013339] iio-core: ******** mask2[9] is 0x3000
[    2.018065] iio-core: ******** mask2[9] is 0xc0000
[    2.022866] iio-core: ******** mask1[10] is 0x40000
[    2.027760] iio-core: ******** mask2[10] is 0x80000
[    2.032647] iio-core: ******** mask2[10] is 0x3000
[    2.037453] iio-core: ******** mask2[10] is 0xc0000
[    2.042346] iio-core: ******** mask1[11] is 0x80000
[    2.047234] iio-core: ******** mask2[11] is 0x3000
[    2.052041] iio-core: ******** mask2[11] is 0xc0000
[    2.056928] iio-core: ******** mask1[12] is 0x3000
[    2.061736] iio-core: ******** mask2[12] is 0xc0000
#9 lore raw
Quoted 181 lines · On Wed, 30 Apr 2025 10:26:12 -0300 Fabio Estevam <[email protected]> wrote:
Quoted 2 lines · Jonathan Cameron

As below. Should be mask1[0] as we've already indexed the array with the above calculation.

Thanks for catching that bug.

Now I get:

[    1.556734] iio-core: ******** masklength is 9
[    1.559663] iio-core: ******** longs_per_mask is 1
[    1.564119] iio-core: ******** mask1[0] is 0x1
[    1.573367] iio-core: ******** mask2[0] is 0x2
[    1.577822] iio-core: ******** mask2[0] is 0x4
[    1.582279] iio-core: ******** mask2[0] is 0x8
[    1.586738] iio-core: ******** mask2[0] is 0x3
[    1.591198] iio-core: ******** mask2[0] is 0x7
[    1.595654] iio-core: ******** mask2[0] is 0xf
[    1.600110] iio-core: ******** mask2[0] is 0xc
[    1.604560] iio-core: ******** mask2[0] is 0x1000
[    1.609278] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
[    1.616084] iio-core: ******** mask2[0] is 0x2000
[    1.620799] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
[    1.627602] iio-core: ******** mask2[0] is 0x40000
[    1.632408] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.639303] iio-core: ******** mask2[0] is 0x80000
[    1.644105] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.650995] iio-core: ******** mask2[0] is 0x3000
[    1.655713] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
[    1.662606] iio-core: ******** mask2[0] is 0xc0000
[    1.667412] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.674309] iio-core: ******** mask1[1] is 0x2
[    1.678761] iio-core: ******** mask2[1] is 0x4
[    1.683212] iio-core: ******** mask2[1] is 0x8
[    1.687666] iio-core: ******** mask2[1] is 0x3
[    1.692118] iio-core: ******** mask2[1] is 0x7
[    1.696576] iio-core: ******** mask2[1] is 0xf
[    1.701029] iio-core: ******** mask2[1] is 0xc
[    1.705483] iio-core: ******** mask2[1] is 0x1000
[    1.710199] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
[    1.716996] iio-core: ******** mask2[1] is 0x2000
[    1.721711] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
[    1.728510] iio-core: ******** mask2[1] is 0x40000
[    1.733317] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.740212] iio-core: ******** mask2[1] is 0x80000
[    1.745013] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.751899] iio-core: ******** mask2[1] is 0x3000
[    1.756612] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
[    1.763503] iio-core: ******** mask2[1] is 0xc0000
[    1.768306] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.775193] iio-core: ******** mask1[2] is 0x4
[    1.779650] iio-core: ******** mask2[2] is 0x8
[    1.784117] iio-core: ******** mask2[2] is 0x3
[    1.788570] iio-core: ******** mask2[2] is 0x7
[    1.793023] iio-core: ******** mask2[2] is 0xf
[    1.797476] iio-core: ******** mask2[2] is 0xc
[    1.801934] iio-core: ******** mask2[2] is 0x1000
[    1.806650] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
[    1.813447] iio-core: ******** mask2[2] is 0x2000
[    1.818162] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
[    1.824961] iio-core: ******** mask2[2] is 0x40000
[    1.829764] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.836649] iio-core: ******** mask2[2] is 0x80000
[    1.841450] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.848336] iio-core: ******** mask2[2] is 0x3000
[    1.853049] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
[    1.859934] iio-core: ******** mask2[2] is 0xc0000
[    1.864740] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.871626] iio-core: ******** mask1[3] is 0x8
[    1.876079] iio-core: ******** mask2[3] is 0x3
[    1.880533] iio-core: ******** mask2[3] is 0x7
[    1.884985] iio-core: ******** mask2[3] is 0xf
[    1.889439] iio-core: ******** mask2[3] is 0xc
[    1.893891] iio-core: ******** mask2[3] is 0x1000
[    1.898605] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
[    1.905403] iio-core: ******** mask2[3] is 0x2000
[    1.910122] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
[    1.916921] iio-core: ******** mask2[3] is 0x40000
[    1.921724] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.928610] iio-core: ******** mask2[3] is 0x80000
[    1.933413] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.940297] iio-core: ******** mask2[3] is 0x3000
[    1.945012] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
[    1.951897] iio-core: ******** mask2[3] is 0xc0000
[    1.956698] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.963584] iio-core: ******** mask1[4] is 0x3
[    1.968037] iio-core: ******** mask2[4] is 0x7
[    1.972489] iio-core: ******** mask2[4] is 0xf
[    1.976942] iio-core: ******** mask2[4] is 0xc
[    1.981394] iio-core: ******** mask2[4] is 0x1000
[    1.986113] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
[    1.992915] iio-core: ******** mask2[4] is 0x2000
[    1.997626] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
[    2.004429] iio-core: ******** mask2[4] is 0x40000
[    2.009230] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    2.016120] iio-core: ******** mask2[4] is 0x80000
[    2.020922] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    2.027807] iio-core: ******** mask2[4] is 0x3000
[    2.032522] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
[    2.039408] iio-core: ******** mask2[4] is 0xc0000
[    2.044210] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    2.051095] iio-core: ******** mask1[5] is 0x7
[    2.055548] iio-core: ******** mask2[5] is 0xf
[    2.060000] iio-core: ******** mask2[5] is 0xc
[    2.064453] iio-core: ******** mask2[5] is 0x1000
[    2.069167] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
[    2.075966] iio-core: ******** mask2[5] is 0x2000
[    2.080680] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
[    2.087478] iio-core: ******** mask2[5] is 0x40000
[    2.092280] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    2.099166] iio-core: ******** mask2[5] is 0x80000
[    2.103967] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.110858] iio-core: ******** mask2[5] is 0x3000
[    2.115573] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
[    2.122463] iio-core: ******** mask2[5] is 0xc0000
[    2.127265] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.134150] iio-core: ******** mask1[6] is 0xf
[    2.138602] iio-core: ******** mask2[6] is 0xc
[    2.143056] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    2.149862] iio-core: ******** mask2[6] is 0x1000
[    2.154578] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
[    2.161374] iio-core: ******** mask2[6] is 0x2000
[    2.166089] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
[    2.172886] iio-core: ******** mask2[6] is 0x40000
[    2.177687] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.184573] iio-core: ******** mask2[6] is 0x80000
[    2.189372] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.196257] iio-core: ******** mask2[6] is 0x3000
[    2.200973] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
[    2.207858] iio-core: ******** mask2[6] is 0xc0000
[    2.212659] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.219544] iio-core: ******** mask1[7] is 0xc
[    2.223996] iio-core: ******** mask2[7] is 0x1000
[    2.228715] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
[    2.235518] iio-core: ******** mask2[7] is 0x2000
[    2.240234] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
[    2.247030] iio-core: ******** mask2[7] is 0x40000
[    2.251832] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.258717] iio-core: ******** mask2[7] is 0x80000
[    2.263518] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.270403] iio-core: ******** mask2[7] is 0x3000
[    2.275117] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
[    2.282002] iio-core: ******** mask2[7] is 0xc0000
[    2.286803] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.293688] iio-core: ******** mask1[8] is 0x1000
[    2.298401] iio-core: ******** mask2[8] is 0x2000
[    2.303116] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
[    2.309914] iio-core: ******** mask2[8] is 0x40000
[    2.314715] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.321600] iio-core: ******** mask2[8] is 0x80000
[    2.326401] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.333289] iio-core: ******** mask2[8] is 0x3000
[    2.338004] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
[    2.344889] iio-core: ******** mask2[8] is 0xc0000
[    2.349691] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.356577] iio-core: ******** mask1[9] is 0x2000
[    2.361294] iio-core: ******** mask2[9] is 0x40000
[    2.366094] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.372977] iio-core: ******** mask2[9] is 0x80000
[    2.377778] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.384663] iio-core: ******** mask2[9] is 0x3000
[    2.389377] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
[    2.396262] iio-core: ******** mask2[9] is 0xc0000
[    2.401063] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.407948] iio-core: ******** mask1[10] is 0x40000
[    2.412835] iio-core: ******** mask2[10] is 0x80000
[    2.417723] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.424696] iio-core: ******** mask2[10] is 0x3000
[    2.429497] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
[    2.436471] iio-core: ******** mask2[10] is 0xc0000
[    2.441359] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.448331] iio-core: ******** mask1[11] is 0x80000
[    2.453218] iio-core: ******** mask2[11] is 0x3000
[    2.458020] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
[    2.464991] iio-core: ******** mask2[11] is 0xc0000
[    2.469879] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.476860] iio-core: ******** mask1[12] is 0x3000
[    2.481659] iio-core: ******** mask2[12] is 0xc0000
[    2.486551] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
Quoted 1 line

Who sets masklength = 9? Is this correct?

It should be set to the maximum scan index seen for any channels (+1 for some reason I can't remember) and hence the maximum bitmap bit that should ever be set. That's something like 19 in this case not 9...

Hmm. These masks seem to be garbage because the driver is packing the scan indexes not using the same ones for all channel combinations as those masks assume.

So wherever MAX1363_CHAN_U is called should assume the single channels start at index 0 and the differential channels at 12. For instance:

#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec) {			\
	MAX1363_CHAN_U(0, _s0, 0, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),	\
	IIO_CHAN_SOFT_TIMESTAMP(8)					\
	}

Should be:

#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec) {			\
	MAX1363_CHAN_U(0, _s0, 0, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),		\
	MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),	\
	MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),	\
	IIO_CHAN_SOFT_TIMESTAMP(8)					\
	}

https://elixir.bootlin.com/linux/v6.14.4/source/drivers/iio/industrialio-buffer.c#L2272

The reason userspace never notices this is that the channel indices are treated as monotonic so the mismatch between 4 and 12 is irrelevant because there are no channels on scan index 5,6,7,8,9,10,11 in this example.

Took me a while to figure out why basic tests wouldn't fail!

So the full fix is reorder the scan indices to fix the basic problem + fix the scan index values in all those channel arrays to use the right mask bits.

Thanks for chasing this down!

Jonathan

Quoted 141 lines

If I use BITS_PER_LONG instead of masklength inside bitmap_subset():

drivers/iio/industrialio-core.c +7 -1
@@ -1947,16 +1947,22 @@ static void
 iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
         * available masks in the order of preference (presumably the least
         * costy to access masks first).
         */
+       pr_err("******** masklength is %d", masklength);
+       pr_err("******** longs_per_mask is %d", longs_per_mask);
+
+
        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;
 
                mask1 = av_masks + i * longs_per_mask;
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[0]);
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;
 
                        mask2 = av_masks + j * longs_per_mask;
-                       if (bitmap_subset(mask2, mask1, masklength))
+                       pr_err("******** mask2[%d] is 0x%lx\n", i, mask2[0]);
+                       if (bitmap_subset(mask2, mask1, BITS_PER_LONG))
                                dev_warn(indio_dev->dev.parent,
                                         "available_scan_mask %d

subset of %d. Never used\n",

                                         j, i);

Then the correct subset information is printed:

[    1.560392] iio-core: ******** masklength is 9
[    1.560406] iio-core: ******** longs_per_mask is 1
[    1.564890] iio-core: ******** mask1[0] is 0x1
[    1.574185] iio-core: ******** mask2[0] is 0x2
[    1.578644] iio-core: ******** mask2[0] is 0x4
[    1.583108] iio-core: ******** mask2[0] is 0x8
[    1.587564] iio-core: ******** mask2[0] is 0x3
[    1.592024] iio-core: ******** mask2[0] is 0x7
[    1.596486] iio-core: ******** mask2[0] is 0xf
[    1.600948] iio-core: ******** mask2[0] is 0xc
[    1.605407] iio-core: ******** mask2[0] is 0x1000
[    1.610130] iio-core: ******** mask2[0] is 0x2000
[    1.614856] iio-core: ******** mask2[0] is 0x40000
[    1.619670] iio-core: ******** mask2[0] is 0x80000
[    1.624475] iio-core: ******** mask2[0] is 0x3000
[    1.629199] iio-core: ******** mask2[0] is 0xc0000
[    1.634017] iio-core: ******** mask1[1] is 0x2
[    1.638475] iio-core: ******** mask2[1] is 0x4
[    1.642941] iio-core: ******** mask2[1] is 0x8
[    1.647401] iio-core: ******** mask2[1] is 0x3
[    1.651865] iio-core: ******** mask2[1] is 0x7
[    1.656321] iio-core: ******** mask2[1] is 0xf
[    1.660786] iio-core: ******** mask2[1] is 0xc
[    1.665245] iio-core: ******** mask2[1] is 0x1000
[    1.669968] iio-core: ******** mask2[1] is 0x2000
[    1.674691] iio-core: ******** mask2[1] is 0x40000
[    1.679505] iio-core: ******** mask2[1] is 0x80000
[    1.684345] iio-core: ******** mask2[1] is 0x3000
[    1.689069] iio-core: ******** mask2[1] is 0xc0000
[    1.693872] iio-core: ******** mask1[2] is 0x4
[    1.698331] iio-core: ******** mask2[2] is 0x8
[    1.702788] iio-core: ******** mask2[2] is 0x3
[    1.707246] iio-core: ******** mask2[2] is 0x7
[    1.711702] iio-core: ******** mask2[2] is 0xf
[    1.716156] iio-core: ******** mask2[2] is 0xc
[    1.720614] iio-core: ******** mask2[2] is 0x1000
[    1.725333] iio-core: ******** mask2[2] is 0x2000
[    1.730046] iio-core: ******** mask2[2] is 0x40000
[    1.734850] iio-core: ******** mask2[2] is 0x80000
[    1.739665] iio-core: ******** mask2[2] is 0x3000
[    1.744385] iio-core: ******** mask2[2] is 0xc0000
[    1.749192] iio-core: ******** mask1[3] is 0x8
[    1.753654] iio-core: ******** mask2[3] is 0x3
[    1.758112] iio-core: ******** mask2[3] is 0x7
[    1.762570] iio-core: ******** mask2[3] is 0xf
[    1.767027] iio-core: ******** mask2[3] is 0xc
[    1.771484] iio-core: ******** mask2[3] is 0x1000
[    1.776203] iio-core: ******** mask2[3] is 0x2000
[    1.780921] iio-core: ******** mask2[3] is 0x40000
[    1.785727] iio-core: ******** mask2[3] is 0x80000
[    1.790531] iio-core: ******** mask2[3] is 0x3000
[    1.795253] iio-core: ******** mask2[3] is 0xc0000
[    1.800059] iio-core: ******** mask1[4] is 0x3
[    1.804515] iio-core: ******** mask2[4] is 0x7
[    1.808970] iio-core: ******** mask2[4] is 0xf
[    1.813427] iio-core: ******** mask2[4] is 0xc
[    1.817891] iio-core: ******** mask2[4] is 0x1000
[    1.822608] iio-core: ******** mask2[4] is 0x2000
[    1.827336] iio-core: ******** mask2[4] is 0x40000
[    1.832164] iio-core: ******** mask2[4] is 0x80000
[    1.836970] iio-core: ******** mask2[4] is 0x3000
[    1.841690] iio-core: ******** mask2[4] is 0xc0000
[    1.846495] iio-core: ******** mask1[5] is 0x7
[    1.850953] iio-core: ******** mask2[5] is 0xf
[    1.855409] iio-core: ******** mask2[5] is 0xc
[    1.859867] iio-core: ******** mask2[5] is 0x1000
[    1.864590] iio-core: ******** mask2[5] is 0x2000
[    1.869310] iio-core: ******** mask2[5] is 0x40000
[    1.874116] iio-core: ******** mask2[5] is 0x80000
[    1.878918] iio-core: ******** mask2[5] is 0x3000
[    1.883636] iio-core: ******** mask2[5] is 0xc0000
[    1.888442] iio-core: ******** mask1[6] is 0xf
[    1.892900] iio-core: ******** mask2[6] is 0xc
[    1.897364] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
[    1.904169] iio-core: ******** mask2[6] is 0x1000
[    1.908887] iio-core: ******** mask2[6] is 0x2000
[    1.913603] iio-core: ******** mask2[6] is 0x40000
[    1.918409] iio-core: ******** mask2[6] is 0x80000
[    1.923212] iio-core: ******** mask2[6] is 0x3000
[    1.927930] iio-core: ******** mask2[6] is 0xc0000
[    1.932733] iio-core: ******** mask1[7] is 0xc
[    1.937190] iio-core: ******** mask2[7] is 0x1000
[    1.941902] iio-core: ******** mask2[7] is 0x2000
[    1.941907] iio-core: ******** mask2[7] is 0x40000
[    1.941911] iio-core: ******** mask2[7] is 0x80000
[    1.941917] iio-core: ******** mask2[7] is 0x3000
[    1.965640] iio-core: ******** mask2[7] is 0xc0000
[    1.970447] iio-core: ******** mask1[8] is 0x1000
[    1.975163] iio-core: ******** mask2[8] is 0x2000
[    1.979881] iio-core: ******** mask2[8] is 0x40000
[    1.984683] iio-core: ******** mask2[8] is 0x80000
[    1.989491] iio-core: ******** mask2[8] is 0x3000
[    1.994209] iio-core: ******** mask2[8] is 0xc0000
[    1.999010] iio-core: ******** mask1[9] is 0x2000
[    2.003732] iio-core: ******** mask2[9] is 0x40000
[    2.008533] iio-core: ******** mask2[9] is 0x80000
[    2.013339] iio-core: ******** mask2[9] is 0x3000
[    2.018065] iio-core: ******** mask2[9] is 0xc0000
[    2.022866] iio-core: ******** mask1[10] is 0x40000
[    2.027760] iio-core: ******** mask2[10] is 0x80000
[    2.032647] iio-core: ******** mask2[10] is 0x3000
[    2.037453] iio-core: ******** mask2[10] is 0xc0000
[    2.042346] iio-core: ******** mask1[11] is 0x80000
[    2.047234] iio-core: ******** mask2[11] is 0x3000
[    2.052041] iio-core: ******** mask2[11] is 0xc0000
[    2.056928] iio-core: ******** mask1[12] is 0x3000
[    2.061736] iio-core: ******** mask2[12] is 0xc0000
#10 lore raw

Hi Jonathan,

Quoted 12 lines · Jonathan Cameron

Should be:

#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec) {                  \
        MAX1363_CHAN_U(0, _s0, 0, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }

I have applied your suggestion.

Please take a look and let me know your thoughts.

drivers/iio/adc/max1363.c +4 -4
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
 
@@ -577,8 +577,8 @@ static const struct iio_chan_spec

max1238_channels[] = MAX1363_12X_CHANS(12);

 static const enum max1363_modes max11607_mode_list[] = {
        _s0, _s1, _s2, _s3,
-       s0to1, s0to2, s0to3,
-       s2to3,
+       s0to1, s0to2, s2to3,
+       s0to3,
        d0m1, d2m3, d1m0, d3m2,
        d0m1to2m3, d1m0to3m2,

};

drivers/iio/industrialio-core.c +0 -0
index 6a6568d4a2cb..8c9330a9f615 100644
@@ -1947,15 +1947,21 @@ static void

iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
* available masks in the order of preference (presumably the least
* costy to access masks first).
*/
+ pr_err("******** masklength is %d", masklength);
+ pr_err("******** longs_per_mask is %d", longs_per_mask);
+
+

        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;

                mask1 = av_masks + i * longs_per_mask;
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[0]);
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;

                        mask2 = av_masks + j * longs_per_mask;

+ pr_err("******** mask2[%d] is 0x%lx\n", i, mask2[0]);
if (bitmap_subset(mask2, mask1, masklength))
dev_warn(indio_dev->dev.parent,
"available_scan_mask %d
subset of %d. Never used\n",

[    1.569250] iio-core: ******** masklength is 16
[    1.569261] iio-core: ******** longs_per_mask is 1
[    1.573834] iio-core: ******** mask1[0] is 0x1
[    1.583173] iio-core: ******** mask2[0] is 0x2
[    1.587629] iio-core: ******** mask2[0] is 0x4
[    1.592091] iio-core: ******** mask2[0] is 0x8
[    1.596569] iio-core: ******** mask2[0] is 0x3
[    1.601027] iio-core: ******** mask2[0] is 0x7
[    1.605482] iio-core: ******** mask2[0] is 0xc
[    1.609942] iio-core: ******** mask2[0] is 0xf
[    1.614400] iio-core: ******** mask2[0] is 0x1000
[    1.619118] iio-core: ******** mask2[0] is 0x2000
[    1.623832] iio-core: ******** mask2[0] is 0x40000
[    1.628642] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.635543] iio-core: ******** mask2[0] is 0x80000
[    1.640343] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.647229] iio-core: ******** mask2[0] is 0x3000
[    1.651943] iio-core: ******** mask2[0] is 0xc0000
[    1.656745] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.663631] iio-core: ******** mask1[1] is 0x2
[    1.668088] iio-core: ******** mask2[1] is 0x4
[    1.672544] iio-core: ******** mask2[1] is 0x8
[    1.676997] iio-core: ******** mask2[1] is 0x3
[    1.681452] iio-core: ******** mask2[1] is 0x7
[    1.685905] iio-core: ******** mask2[1] is 0xc
[    1.690365] iio-core: ******** mask2[1] is 0xf
[    1.694820] iio-core: ******** mask2[1] is 0x1000
[    1.699535] iio-core: ******** mask2[1] is 0x2000
[    1.704251] iio-core: ******** mask2[1] is 0x40000
[    1.709059] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.715945] iio-core: ******** mask2[1] is 0x80000
[    1.720747] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.727632] iio-core: ******** mask2[1] is 0x3000
[    1.732349] iio-core: ******** mask2[1] is 0xc0000
[    1.737150] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.744038] iio-core: ******** mask1[2] is 0x4
[    1.748488] iio-core: ******** mask2[2] is 0x8
[    1.752941] iio-core: ******** mask2[2] is 0x3
[    1.757393] iio-core: ******** mask2[2] is 0x7
[    1.761846] iio-core: ******** mask2[2] is 0xc
[    1.766300] iio-core: ******** mask2[2] is 0xf
[    1.770756] iio-core: ******** mask2[2] is 0x1000
[    1.775469] iio-core: ******** mask2[2] is 0x2000
[    1.780184] iio-core: ******** mask2[2] is 0x40000
[    1.784986] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.791871] iio-core: ******** mask2[2] is 0x80000
[    1.796673] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.803558] iio-core: ******** mask2[2] is 0x3000
[    1.808271] iio-core: ******** mask2[2] is 0xc0000
[    1.813072] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.819961] iio-core: ******** mask1[3] is 0x8
[    1.824415] iio-core: ******** mask2[3] is 0x3
[    1.828865] iio-core: ******** mask2[3] is 0x7
[    1.833317] iio-core: ******** mask2[3] is 0xc
[    1.837771] iio-core: ******** mask2[3] is 0xf
[    1.842224] iio-core: ******** mask2[3] is 0x1000
[    1.846937] iio-core: ******** mask2[3] is 0x2000
[    1.851649] iio-core: ******** mask2[3] is 0x40000
[    1.856448] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.863334] iio-core: ******** mask2[3] is 0x80000
[    1.868135] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.875026] iio-core: ******** mask2[3] is 0x3000
[    1.879739] iio-core: ******** mask2[3] is 0xc0000
[    1.884540] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.891427] iio-core: ******** mask1[4] is 0x3
[    1.895882] iio-core: ******** mask2[4] is 0x7
[    1.900334] iio-core: ******** mask2[4] is 0xc
[    1.904787] iio-core: ******** mask2[4] is 0xf
[    1.909239] iio-core: ******** mask2[4] is 0x1000
[    1.913952] iio-core: ******** mask2[4] is 0x2000
[    1.918666] iio-core: ******** mask2[4] is 0x40000
[    1.923467] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    1.930353] iio-core: ******** mask2[4] is 0x80000
[    1.935154] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    1.942045] iio-core: ******** mask2[4] is 0x3000
[    1.946759] iio-core: ******** mask2[4] is 0xc0000
[    1.951560] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    1.958445] iio-core: ******** mask1[5] is 0x7
[    1.962898] iio-core: ******** mask2[5] is 0xc
[    1.967351] iio-core: ******** mask2[5] is 0xf
[    1.971804] iio-core: ******** mask2[5] is 0x1000
[    1.976515] iio-core: ******** mask2[5] is 0x2000
[    1.981233] iio-core: ******** mask2[5] is 0x40000
[    1.986034] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    1.992920] iio-core: ******** mask2[5] is 0x80000
[    1.997722] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.004612] iio-core: ******** mask2[5] is 0x3000
[    2.009327] iio-core: ******** mask2[5] is 0xc0000
[    2.014125] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.021011] iio-core: ******** mask1[6] is 0xc
[    2.025463] iio-core: ******** mask2[6] is 0xf
[    2.029916] iio-core: ******** mask2[6] is 0x1000
[    2.034629] iio-core: ******** mask2[6] is 0x2000
[    2.039343] iio-core: ******** mask2[6] is 0x40000
[    2.044146] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.051031] iio-core: ******** mask2[6] is 0x80000
[    2.055832] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.062717] iio-core: ******** mask2[6] is 0x3000
[    2.067435] iio-core: ******** mask2[6] is 0xc0000
[    2.072237] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.079123] iio-core: ******** mask1[7] is 0xf
[    2.083579] iio-core: ******** mask2[7] is 0x1000
[    2.088293] iio-core: ******** mask2[7] is 0x2000
[    2.093006] iio-core: ******** mask2[7] is 0x40000
[    2.097808] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.104694] iio-core: ******** mask2[7] is 0x80000
[    2.109493] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.116378] iio-core: ******** mask2[7] is 0x3000
[    2.121091] iio-core: ******** mask2[7] is 0xc0000
[    2.125892] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.132777] iio-core: ******** mask1[8] is 0x1000
[    2.137490] iio-core: ******** mask2[8] is 0x2000
[    2.142203] iio-core: ******** mask2[8] is 0x40000
[    2.147009] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.153896] iio-core: ******** mask2[8] is 0x80000
[    2.158698] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.165583] iio-core: ******** mask2[8] is 0x3000
[    2.170297] iio-core: ******** mask2[8] is 0xc0000
[    2.175098] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.181983] iio-core: ******** mask1[9] is 0x2000
[    2.186698] iio-core: ******** mask2[9] is 0x40000
[    2.191504] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.198390] iio-core: ******** mask2[9] is 0x80000
[    2.203191] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.210077] iio-core: ******** mask2[9] is 0x3000
[    2.214788] iio-core: ******** mask2[9] is 0xc0000
[    2.219591] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.226476] iio-core: ******** mask1[10] is 0x40000
[    2.231363] iio-core: ******** mask2[10] is 0x80000
[    2.236250] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.243222] iio-core: ******** mask2[10] is 0x3000
[    2.248022] iio-core: ******** mask2[10] is 0xc0000
[    2.252910] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.259882] iio-core: ******** mask1[11] is 0x80000
[    2.264770] iio-core: ******** mask2[11] is 0x3000
[    2.269570] iio-core: ******** mask2[11] is 0xc0000
[    2.274458] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.281430] iio-core: ******** mask1[12] is 0x3000
[    2.286229] iio-core: ******** mask2[12] is 0xc0000
[    2.291120] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
#11 lore raw
Quoted 9 lines · Fabio Estevam

I have applied your suggestion.

Please take a look and let me know your thoughts.

drivers/iio/adc/max1363.c +0 -0
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 511

Quoted 10 lines
drivers/iio/adc/max1363.c +4 -4
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \

I have also tried changing it like this:

drivers/iio/adc/max1363.c +4 -4
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 28, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 29, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 30, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 31, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
 

In this case, the warnings are gone.

Should the masks be 32-bit?

Thanks

maintainer
#13 lore raw
In reply to Fabio Estevam
Quoted 26 lines · On Wed, 30 Apr 2025 16:37:30 -0300 Fabio Estevam <[email protected]> wrote:

Hi Jonathan,

Quoted 12 lines · Jonathan Cameron

Should be:

#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec) {                  \
        MAX1363_CHAN_U(0, _s0, 0, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
        MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }  

I have applied your suggestion.

Please take a look and let me know your thoughts.

drivers/iio/adc/max1363.c +0 -0
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 510

Quoted 10 lines
drivers/iio/adc/max1363.c +4 -4
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \

Ah. I was wrong for last two channels above. The scan masks for single channel for differential channels also index a bunch we aren't using in this device.

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 508

Quoted 2 lines
drivers/iio/adc/max1363.c +2 -0
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \

//gap here as we aren't using 4,5 6,7 8,9, 10,11

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 509

Quoted 1 line
drivers/iio/adc/max1363.c +1 -0
+       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \

Should be 18
https://elixir.bootlin.com/linux/v6.14.5/source/drivers/iio/adc/max1363.c#L262

Quoted 1 line

+ MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec), \

and 19 I believe.

Maybe we can simplify this and make it less error prone. These scan indices are always the same as the enum max1363_mode entries in the 2nd or 3rd parameter. We can just reuse those I think. Only the single channel ones apply here but those are the first set of entries in that enum.

Bonus points for just dropping the parameter and using the existing addr parameter for the macro as si as well.

That is:

#define MAX1363_CHAN_U(num, addr, bits, ev_spec, num_ev_spec)	\
	{								\
		.type = IIO_VOLTAGE,					\
		.indexed = 1,						\
		.channel = num,						\
		.address = addr,					\
		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),		\
		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),	\
		.datasheet_name = "AIN"#num,				\
		.scan_type = {						\
			.sign = 'u',					\
			.realbits = bits,				\
			.storagebits = (bits > 8) ? 16 : 8,		\
			.endianness = IIO_BE,				\
		},							\
		.scan_index = (addr),					\
The above changed from si to addr
		.event_spec = ev_spec,					\
		.num_event_specs = num_ev_spec,				\
	}
Quoted 185 lines
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
drivers/iio/adc/max1363.c +2 -2
@@ -577,8 +577,8 @@ static const struct iio_chan_spec
 max1238_channels[] = MAX1363_12X_CHANS(12);
 
 static const enum max1363_modes max11607_mode_list[] = {
        _s0, _s1, _s2, _s3,
-       s0to1, s0to2, s0to3,
-       s2to3,
+       s0to1, s0to2, s2to3,
+       s0to3,
        d0m1, d2m3, d1m0, d3m2,
        d0m1to2m3, d1m0to3m2,

};

drivers/iio/industrialio-core.c +6 -0
index 6a6568d4a2cb..8c9330a9f615 100644
@@ -1947,15 +1947,21 @@ static void
 iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
         * available masks in the order of preference (presumably the least
         * costy to access masks first).
         */
+       pr_err("******** masklength is %d", masklength);
+       pr_err("******** longs_per_mask is %d", longs_per_mask);
+
+
        for (i = 0; i < num_masks - 1; i++) {
                const unsigned long *mask1;
                int j;
 
                mask1 = av_masks + i * longs_per_mask;
+               pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[0]);
                for (j = i + 1; j < num_masks; j++) {
                        const unsigned long *mask2;
 
                        mask2 = av_masks + j * longs_per_mask;
+                       pr_err("******** mask2[%d] is 0x%lx\n", i, mask2[0]);
                        if (bitmap_subset(mask2, mask1, masklength))
                                dev_warn(indio_dev->dev.parent,

"available_scan_mask %d
subset of %d. Never used\n",

[    1.569250] iio-core: ******** masklength is 16
[    1.569261] iio-core: ******** longs_per_mask is 1
[    1.573834] iio-core: ******** mask1[0] is 0x1
[    1.583173] iio-core: ******** mask2[0] is 0x2
[    1.587629] iio-core: ******** mask2[0] is 0x4
[    1.592091] iio-core: ******** mask2[0] is 0x8
[    1.596569] iio-core: ******** mask2[0] is 0x3
[    1.601027] iio-core: ******** mask2[0] is 0x7
[    1.605482] iio-core: ******** mask2[0] is 0xc
[    1.609942] iio-core: ******** mask2[0] is 0xf
[    1.614400] iio-core: ******** mask2[0] is 0x1000
[    1.619118] iio-core: ******** mask2[0] is 0x2000
[    1.623832] iio-core: ******** mask2[0] is 0x40000
[    1.628642] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
[    1.635543] iio-core: ******** mask2[0] is 0x80000
[    1.640343] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
[    1.647229] iio-core: ******** mask2[0] is 0x3000
[    1.651943] iio-core: ******** mask2[0] is 0xc0000
[    1.656745] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
[    1.663631] iio-core: ******** mask1[1] is 0x2
[    1.668088] iio-core: ******** mask2[1] is 0x4
[    1.672544] iio-core: ******** mask2[1] is 0x8
[    1.676997] iio-core: ******** mask2[1] is 0x3
[    1.681452] iio-core: ******** mask2[1] is 0x7
[    1.685905] iio-core: ******** mask2[1] is 0xc
[    1.690365] iio-core: ******** mask2[1] is 0xf
[    1.694820] iio-core: ******** mask2[1] is 0x1000
[    1.699535] iio-core: ******** mask2[1] is 0x2000
[    1.704251] iio-core: ******** mask2[1] is 0x40000
[    1.709059] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
[    1.715945] iio-core: ******** mask2[1] is 0x80000
[    1.720747] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
[    1.727632] iio-core: ******** mask2[1] is 0x3000
[    1.732349] iio-core: ******** mask2[1] is 0xc0000
[    1.737150] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
[    1.744038] iio-core: ******** mask1[2] is 0x4
[    1.748488] iio-core: ******** mask2[2] is 0x8
[    1.752941] iio-core: ******** mask2[2] is 0x3
[    1.757393] iio-core: ******** mask2[2] is 0x7
[    1.761846] iio-core: ******** mask2[2] is 0xc
[    1.766300] iio-core: ******** mask2[2] is 0xf
[    1.770756] iio-core: ******** mask2[2] is 0x1000
[    1.775469] iio-core: ******** mask2[2] is 0x2000
[    1.780184] iio-core: ******** mask2[2] is 0x40000
[    1.784986] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
[    1.791871] iio-core: ******** mask2[2] is 0x80000
[    1.796673] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
[    1.803558] iio-core: ******** mask2[2] is 0x3000
[    1.808271] iio-core: ******** mask2[2] is 0xc0000
[    1.813072] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
[    1.819961] iio-core: ******** mask1[3] is 0x8
[    1.824415] iio-core: ******** mask2[3] is 0x3
[    1.828865] iio-core: ******** mask2[3] is 0x7
[    1.833317] iio-core: ******** mask2[3] is 0xc
[    1.837771] iio-core: ******** mask2[3] is 0xf
[    1.842224] iio-core: ******** mask2[3] is 0x1000
[    1.846937] iio-core: ******** mask2[3] is 0x2000
[    1.851649] iio-core: ******** mask2[3] is 0x40000
[    1.856448] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
[    1.863334] iio-core: ******** mask2[3] is 0x80000
[    1.868135] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
[    1.875026] iio-core: ******** mask2[3] is 0x3000
[    1.879739] iio-core: ******** mask2[3] is 0xc0000
[    1.884540] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
[    1.891427] iio-core: ******** mask1[4] is 0x3
[    1.895882] iio-core: ******** mask2[4] is 0x7
[    1.900334] iio-core: ******** mask2[4] is 0xc
[    1.904787] iio-core: ******** mask2[4] is 0xf
[    1.909239] iio-core: ******** mask2[4] is 0x1000
[    1.913952] iio-core: ******** mask2[4] is 0x2000
[    1.918666] iio-core: ******** mask2[4] is 0x40000
[    1.923467] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
[    1.930353] iio-core: ******** mask2[4] is 0x80000
[    1.935154] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
[    1.942045] iio-core: ******** mask2[4] is 0x3000
[    1.946759] iio-core: ******** mask2[4] is 0xc0000
[    1.951560] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
[    1.958445] iio-core: ******** mask1[5] is 0x7
[    1.962898] iio-core: ******** mask2[5] is 0xc
[    1.967351] iio-core: ******** mask2[5] is 0xf
[    1.971804] iio-core: ******** mask2[5] is 0x1000
[    1.976515] iio-core: ******** mask2[5] is 0x2000
[    1.981233] iio-core: ******** mask2[5] is 0x40000
[    1.986034] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
[    1.992920] iio-core: ******** mask2[5] is 0x80000
[    1.997722] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
[    2.004612] iio-core: ******** mask2[5] is 0x3000
[    2.009327] iio-core: ******** mask2[5] is 0xc0000
[    2.014125] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
[    2.021011] iio-core: ******** mask1[6] is 0xc
[    2.025463] iio-core: ******** mask2[6] is 0xf
[    2.029916] iio-core: ******** mask2[6] is 0x1000
[    2.034629] iio-core: ******** mask2[6] is 0x2000
[    2.039343] iio-core: ******** mask2[6] is 0x40000
[    2.044146] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
[    2.051031] iio-core: ******** mask2[6] is 0x80000
[    2.055832] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
[    2.062717] iio-core: ******** mask2[6] is 0x3000
[    2.067435] iio-core: ******** mask2[6] is 0xc0000
[    2.072237] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
[    2.079123] iio-core: ******** mask1[7] is 0xf
[    2.083579] iio-core: ******** mask2[7] is 0x1000
[    2.088293] iio-core: ******** mask2[7] is 0x2000
[    2.093006] iio-core: ******** mask2[7] is 0x40000
[    2.097808] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
[    2.104694] iio-core: ******** mask2[7] is 0x80000
[    2.109493] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
[    2.116378] iio-core: ******** mask2[7] is 0x3000
[    2.121091] iio-core: ******** mask2[7] is 0xc0000
[    2.125892] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
[    2.132777] iio-core: ******** mask1[8] is 0x1000
[    2.137490] iio-core: ******** mask2[8] is 0x2000
[    2.142203] iio-core: ******** mask2[8] is 0x40000
[    2.147009] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
[    2.153896] iio-core: ******** mask2[8] is 0x80000
[    2.158698] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
[    2.165583] iio-core: ******** mask2[8] is 0x3000
[    2.170297] iio-core: ******** mask2[8] is 0xc0000
[    2.175098] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
[    2.181983] iio-core: ******** mask1[9] is 0x2000
[    2.186698] iio-core: ******** mask2[9] is 0x40000
[    2.191504] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
[    2.198390] iio-core: ******** mask2[9] is 0x80000
[    2.203191] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
[    2.210077] iio-core: ******** mask2[9] is 0x3000
[    2.214788] iio-core: ******** mask2[9] is 0xc0000
[    2.219591] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
[    2.226476] iio-core: ******** mask1[10] is 0x40000
[    2.231363] iio-core: ******** mask2[10] is 0x80000
[    2.236250] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
[    2.243222] iio-core: ******** mask2[10] is 0x3000
[    2.248022] iio-core: ******** mask2[10] is 0xc0000
[    2.252910] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
[    2.259882] iio-core: ******** mask1[11] is 0x80000
[    2.264770] iio-core: ******** mask2[11] is 0x3000
[    2.269570] iio-core: ******** mask2[11] is 0xc0000
[    2.274458] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
[    2.281430] iio-core: ******** mask1[12] is 0x3000
[    2.286229] iio-core: ******** mask2[12] is 0xc0000
[    2.291120] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
maintainer
#12 lore raw
In reply to Fabio Estevam
Quoted 43 lines · On Sat, 3 May 2025 09:02:58 -0300 Fabio Estevam <[email protected]> wrote:
Quoted 9 lines · Fabio Estevam

I have applied your suggestion.

Please take a look and let me know your thoughts.

drivers/iio/adc/max1363.c +0 -0
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 511

Quoted 10 lines
drivers/iio/adc/max1363.c +4 -4
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \  

I have also tried changing it like this:

drivers/iio/adc/max1363.c +4 -4
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 28, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 29, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 30, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 31, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
 

In this case, the warnings are gone.

Quoted 1 line

Should the masks be 32-bit?

Their depth depends on particular channels but is between 18 and 24 (assuming I'm finally reading the tables right!)

Jonathan

Quoted 2 lines

Thanks

author Tested-by
#14 lore raw
In reply to Jonathan Cameron

Hi Jonathan,

Quoted 5 lines · Jonathan Cameron

Ah. I was wrong for last two channels above. The scan masks for single channel for differential channels also index a bunch we aren't using in this device.

Review

Quoted 2 lines
(quoted diff) +2 -0
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
Quoted 7 lines

//gap here as we aren't using 4,5 6,7 8,9, 10,11

Quoted 1 line

+ MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec), \

Should be 18
https://elixir.bootlin.com/linux/v6.14.5/source/drivers/iio/adc/max1363.c#L262

Quoted 1 line

+ MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec), \

and 19 I believe.

This works fine for me, thanks:

drivers/iio/adc/max1363.c +4 -4
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 18, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 19, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
 
Quoted 25 lines

Maybe we can simplify this and make it less error prone. These scan indices are always the same as the enum max1363_mode entries in the 2nd or 3rd parameter. We can just reuse those I think. Only the single channel ones apply here but those are the first set of entries in that enum.

Bonus points for just dropping the parameter and using the existing addr parameter for the macro as si as well.

That is:

#define MAX1363_CHAN_U(num, addr, bits, ev_spec, num_ev_spec)   \
        {                                                               \
                .type = IIO_VOLTAGE,                                    \
                .indexed = 1,                                           \
                .channel = num,                                         \
                .address = addr,                                        \
                .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),           \
                .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
                .datasheet_name = "AIN"#num,                            \
                .scan_type = {                                          \
                        .sign = 'u',                                    \
                        .realbits = bits,                               \
                        .storagebits = (bits > 8) ? 16 : 8,             \
                        .endianness = IIO_BE,                           \
                },                                                      \
                .scan_index = (addr),                                   \
Quoted 1 line

The above changed from si to addr

I tried this change on top of the previous one, and it still works.

How do you think we should proceed? Can you please submit formal patches?

You can add:

Thanks

maintainer
#15 lore raw
Quoted 63 lines · On Mon, 5 May 2025 11:24:36 -0300 Fabio Estevam <[email protected]> wrote:

Hi Jonathan,

Quoted 5 lines · Jonathan Cameron

Ah. I was wrong for last two channels above. The scan masks for single channel for differential channels also index a bunch we aren't using in this device.

drivers/iio/adc/max1363.c static const struct iio_event_spec max1363_events[] = { · line 508

Quoted 2 lines
drivers/iio/adc/max1363.c +2 -0
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \  
Quoted 7 lines

//gap here as we aren't using 4,5 6,7 8,9, 10,11

Quoted 1 line

+ MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec), \

Should be 18
https://elixir.bootlin.com/linux/v6.14.5/source/drivers/iio/adc/max1363.c#L262

Quoted 1 line

+ MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec), \

and 19 I believe.

This works fine for me, thanks:

drivers/iio/adc/max1363.c +4 -4
@@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
        MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
        MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
-       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
-       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(1, 0, d1m0, 18, bits, ev_spec, num_ev_spec),     \
+       MAX1363_CHAN_B(3, 2, d3m2, 19, bits, ev_spec, num_ev_spec),     \
        IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
        }
 
Quoted 25 lines

Maybe we can simplify this and make it less error prone. These scan indices are always the same as the enum max1363_mode entries in the 2nd or 3rd parameter. We can just reuse those I think. Only the single channel ones apply here but those are the first set of entries in that enum.

Bonus points for just dropping the parameter and using the existing addr parameter for the macro as si as well.

That is:

#define MAX1363_CHAN_U(num, addr, bits, ev_spec, num_ev_spec)   \
        {                                                               \
                .type = IIO_VOLTAGE,                                    \
                .indexed = 1,                                           \
                .channel = num,                                         \
                .address = addr,                                        \
                .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),           \
                .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
                .datasheet_name = "AIN"#num,                            \
                .scan_type = {                                          \
                        .sign = 'u',                                    \
                        .realbits = bits,                               \
                        .storagebits = (bits > 8) ? 16 : 8,             \
                        .endianness = IIO_BE,                           \
                },                                                      \
                .scan_index = (addr),                                   \
Quoted 1 line

The above changed from si to addr

Quoted 3 lines

I tried this change on top of the previous one, and it still works.

How do you think we should proceed? Can you please submit formal patches?

That would be perfect! If you can do it by modifying the macro as that is going to be the simplest path to ensure there are no others even better.

Jonathan

Quoted 7 lines

You can add:

Thanks

#16 lore raw

Hi Jonathan,

Quoted 2 lines · Jonathan Cameron

That would be perfect! If you can do it by modifying the macro as that is going to be the simplest path to ensure there are no others even better.

I'm sorry, but I am unsure I understood your proposal correctly.

Do you plan to submit a formal patch?

Thanks

maintainer
#17 lore raw
Quoted 4 lines · On Thu, 8 May 2025 10:29:47 -0300 Fabio Estevam <[email protected]> wrote:

Hi Jonathan,

On Mon, May 5, 2025 at 12:16 PM Jonathan Cameron <[email protected]> wrote:

Quoted 9 lines
Quoted 2 lines

That would be perfect! If you can do it by modifying the macro as that is going to be the simplest path to ensure there are no others even better.

I'm sorry, but I am unsure I understood your proposal correctly.

Do you plan to submit a formal patch?

Thanks

I'm snowed under. If you have the time to write one that would be great. If not I'll get to it but not until maybe 2 weeks time.

Jonathan