Skip to contentSkip to conversation

iio: adc: ad7606_spi: use bitmap_full() in ad7606_spi_update_scan_mode()

PATCH In review Yury Norov (NVIDIA) 3 participants 4 messages Dec 16, 2025 – Dec 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ad7606_spi: use bitmap_full() in ad7606_spi_update_scan_mode()

bitmap_empty() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st set bit found.

---
 drivers/iio/adc/ad7606_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +1 -1
index f28e4ca37707..7e17ccbcedd0 100644
@@ -345,7 +345,7 @@ static int ad7606_spi_update_scan_mode(struct iio_dev *indio_dev,
 		 * has no way of demuxing the data to filter out unwanted
 		 * channels.
 		 */
-		if (bitmap_weight(scan_mask, num_adc_ch) != num_adc_ch)
+		if (!bitmap_full(scan_mask, num_adc_ch))
 			return -EINVAL;
 	}
 
Signature · 1 line
2.43.0
author
#1 lore raw
Quoted 2 lines · Yury Norov (NVIDIA)

bitmap_empty() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st set bit found.

Ah, please read this as:

bitmap_full() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st unset bit found.

Sorry for miswording the commit message.

Quoted 20 lines
---
 drivers/iio/adc/ad7606_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +1 -1
index f28e4ca37707..7e17ccbcedd0 100644
@@ -345,7 +345,7 @@ static int ad7606_spi_update_scan_mode(struct iio_dev *indio_dev,
 		 * has no way of demuxing the data to filter out unwanted
 		 * channels.
 		 */
-		if (bitmap_weight(scan_mask, num_adc_ch) != num_adc_ch)
+		if (!bitmap_full(scan_mask, num_adc_ch))
 			return -EINVAL;
 	}
 
Signature · 1 line
2.43.0
reviewer Reviewed-by
#2 lore raw
Quoted 9 lines · Yury Norov
Quoted 2 lines · Yury Norov (NVIDIA)

bitmap_empty() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st set bit found.

Ah, please read this as:

bitmap_full() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st unset bit found.

I think you mean "bitmap_full() is less verbose"?

This isn't a hot path, so efficiency isn't important.

This makes the code easier to understand anyway, so a worthy change.

Quoted 20 lines

Sorry for miswording the commit message.

Quoted 18 lines
---
 drivers/iio/adc/ad7606_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +1 -1
index f28e4ca37707..7e17ccbcedd0 100644
@@ -345,7 +345,7 @@ static int ad7606_spi_update_scan_mode(struct iio_dev *indio_dev,
 		 * has no way of demuxing the data to filter out unwanted
 		 * channels.
 		 */
-		if (bitmap_weight(scan_mask, num_adc_ch) != num_adc_ch)
+		if (!bitmap_full(scan_mask, num_adc_ch))
 			return -EINVAL;
 	}
 
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.43.0

With the commit message fixed:

maintainer
#3 lore raw
Quoted 11 lines · On Mon, 15 Dec 2025 18:26:46 -0600 David Lechner <[email protected]> wrote:
Quoted 9 lines · Yury Norov
Quoted 2 lines · Yury Norov (NVIDIA)

bitmap_empty() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st set bit found.

Ah, please read this as:

bitmap_full() is more verbose and efficient, as it stops traversing scan_mask as soon as the 1st unset bit found.

Quoted 6 lines

I think you mean "bitmap_full() is less verbose"?

This isn't a hot path, so efficiency isn't important.

This makes the code easier to understand anyway, so a worthy change.

Tweaked patch description as discussed (with a more inserted before efficient as it's "less verbose and more efficient" and applied.

Thanks,

Jonathan

Quoted 28 lines
Quoted 21 lines

Sorry for miswording the commit message.

Quoted 18 lines
---
 drivers/iio/adc/ad7606_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +1 -1
index f28e4ca37707..7e17ccbcedd0 100644
@@ -345,7 +345,7 @@ static int ad7606_spi_update_scan_mode(struct iio_dev *indio_dev,
 		 * has no way of demuxing the data to filter out unwanted
 		 * channels.
 		 */
-		if (bitmap_weight(scan_mask, num_adc_ch) != num_adc_ch)
+		if (!bitmap_full(scan_mask, num_adc_ch))
 			return -EINVAL;
 	}
 
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.43.0  

With the commit message fixed: