Skip to contentSkip to conversation

iio: make masklength __private (round 2)

PATCH Applied Nuno Sa 2 participants 32 messages Jul 18, 2024 – Jul 20, 2024

Subsystems (3)
lore
Share & tools
lore

Nuno Sa

author reviewer
#0 lore raw

cover iio: make masklength __private (round 2)

Hi Jonathan,

Here it goes the second round about annotating .masklength as __private.

Again, only compile tested for arm with allyesconfig.

---
Nuno Sa (22):
iio: adc: cc10001_adc: make use of iio_for_each_active_channel()
iio: adc: dln2-adc: use new '.masklength' accessors
iio: adc: hx711: make use of iio_for_each_active_channel()
iio: dummy: iio_simple_dummy_buffer: use iio_for_each_active_channel()
iio: health: afe4403: make use of iio_for_each_active_channel()
iio: health: max30102: make use of iio_get_masklength()
iio: health: afe4404: make use of iio_for_each_active_channel()
iio: humidity: am2315: make use of iio_for_each_active_channel()
iio: imu: bmi160_core: make use of iio_for_each_active_channel()
iio: imu: bno055: make use of iio_get_masklength()
iio: imu: kmx61: make use of iio_for_each_active_channel()
iio: light: adjd_s311: make use of iio_for_each_active_channel()
iio: light: gp2ap020a00f: make use of iio_for_each_active_channel()
iio: light: isl29125: make use of iio_for_each_active_channel()
iio: light: si1145: use new '.masklength' accessors
iio: light: tcs3414: make use of iio_for_each_active_channel()
iio: light: tcs3472: make use of iio_for_each_active_channel()
iio: magnetometer: rm3100-core: make use of iio_get_masklength()
iio: pressure: dlhl60d: make use of iio_for_each_active_channel()
iio: proximity: hx9023s: make use of iio_for_each_active_channel()
iio: proximity: sx9500: make use of iio_for_each_active_channel()
iio: proximity: sx_common: make use of iio_for_each_active_channel()

 drivers/iio/adc/cc10001_adc.c               | 4 +---
 drivers/iio/adc/dln2-adc.c                  | 8 +++-----
 drivers/iio/adc/hx711.c                     | 5 +----
 drivers/iio/dummy/iio_simple_dummy_buffer.c | 2 +-
 drivers/iio/health/afe4403.c                | 3 +--
 drivers/iio/health/afe4404.c                | 3 +--
 drivers/iio/health/max30102.c               | 2 +-
 drivers/iio/humidity/am2315.c               | 3 +--
 drivers/iio/imu/bmi160/bmi160_core.c        | 3 +--
 drivers/iio/imu/bno055/bno055.c             | 2 +-
 drivers/iio/imu/kmx61.c                     | 3 +--
 drivers/iio/light/adjd_s311.c               | 3 +--
 drivers/iio/light/gp2ap020a00f.c            | 9 +++------
 drivers/iio/light/isl29125.c                | 3 +--
 drivers/iio/light/si1145.c                  | 7 +++----
 drivers/iio/light/tcs3414.c                 | 3 +--
 drivers/iio/light/tcs3472.c                 | 3 +--
 drivers/iio/magnetometer/rm3100-core.c      | 2 +-
 drivers/iio/pressure/dlhl60d.c              | 3 +--
 drivers/iio/proximity/hx9023s.c             | 4 ++--
 drivers/iio/proximity/sx9500.c              | 3 +--
 drivers/iio/proximity/sx_common.c           | 6 ++----
 22 files changed, 30 insertions(+), 54 deletions(-)

---
base-commit: 986da024b99a72e64f6bdb3f3f0e52af024b1f50
change-id: 20240711-dev-iio-masklength-private2-cd8d93f07781 --

Thanks!
- Nuno Sá

author reviewer
#1 lore raw

PATCH 1/22 iio: adc: cc10001_adc: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/adc/cc10001_adc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/adc/cc10001_adc.c +1 -3
index a432342348abe..2c51b90b71018 100644
@@ -157,9 +157,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
 
 	i = 0;
 	sample_invalid = false;
-	for_each_set_bit(scan_idx, indio_dev->active_scan_mask,
-				  indio_dev->masklength) {
-
+	iio_for_each_active_channel(indio_dev, scan_idx) {
 		channel = indio_dev->channels[scan_idx].channel;
 		cc10001_adc_start(adc_dev, channel);
 
Signature · 1 line
2.45.2
maintainer Applied
#2 lore raw

Re: [PATCH 01/22] iio: adc: cc10001_adc: make use of iio_for_each_active_channel()

Quoted 7 lines · On Thu, 18 Jul 2024 15:37:47 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

Applied

author reviewer
#3 lore raw

PATCH 2/22 iio: adc: dln2-adc: use new '.masklength' accessors

In reply to Nuno Sa

Make use of iio_get_masklength) and iio_for_each_active_channel() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/adc/dln2-adc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/adc/dln2-adc.c +3 -5
index 06cfbbabaf8dc..de7252a10047d 100644
@@ -108,7 +108,7 @@ static void dln2_adc_update_demux(struct dln2_adc *dln2)
 	dln2->demux_count = 0;
 
 	/* Optimize all 8-channels case */
-	if (indio_dev->masklength &&
+	if (iio_get_masklength(indio_dev) &&
 	    (*indio_dev->active_scan_mask & 0xff) == 0xff) {
 		dln2_adc_add_demux(dln2, 0, 0, 16);
 		dln2->ts_pad_offset = 0;
@@ -117,9 +117,7 @@ static void dln2_adc_update_demux(struct dln2_adc *dln2)
 	}
 
 	/* Build demux table from fixed 8-channels to active_scan_mask */
-	for_each_set_bit(out_ind,
-			 indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, out_ind) {
 		/* Handle timestamp separately */
 		if (out_ind == DLN2_ADC_MAX_CHANNELS)
 			break;
@@ -541,7 +539,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
 
 	/* Assign trigger channel based on first enabled channel */
 	trigger_chan = find_first_bit(indio_dev->active_scan_mask,
-				      indio_dev->masklength);
+				      iio_get_masklength(indio_dev));
 	if (trigger_chan < DLN2_ADC_MAX_CHANNELS) {
 		dln2->trigger_chan = trigger_chan;
 		ret = dln2_adc_set_chan_period(dln2, dln2->trigger_chan,
Signature · 1 line
2.45.2
maintainer Applied
#4 lore raw

Re: [PATCH 02/22] iio: adc: dln2-adc: use new '.masklength' accessors

Quoted 7 lines · On Thu, 18 Jul 2024 15:37:48 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Make use of iio_get_masklength) and iio_for_each_active_channel() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

Applied

author reviewer
#5 lore raw

PATCH 3/22 iio: adc: hx711: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/adc/hx711.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/hx711.c +1 -4
index b3372ccff7d5..376f4e02de97 100644
@@ -363,10 +363,7 @@ static irqreturn_t hx711_trigger(int irq, void *p)
 
 	memset(hx711_data->buffer, 0, sizeof(hx711_data->buffer));
 
-	for (i = 0; i < indio_dev->masklength; i++) {
-		if (!test_bit(i, indio_dev->active_scan_mask))
-			continue;
-
+	iio_for_each_active_channel(indio_dev, i) {
 		hx711_data->buffer[j] = hx711_reset_read(hx711_data,
 					indio_dev->channels[i].channel);
 		j++;
Signature · 1 line
2.45.2
maintainer Applied
#6 lore raw

Re: [PATCH 03/22] iio: adc: hx711: make use of iio_for_each_active_channel()

Quoted 7 lines · On Thu, 18 Jul 2024 15:37:49 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

Even before this work from you, this code could certainly have been less contrary!

Applied.

Quoted 21 lines
---
 drivers/iio/adc/hx711.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/hx711.c +1 -4
index b3372ccff7d5..376f4e02de97 100644
@@ -363,10 +363,7 @@ static irqreturn_t hx711_trigger(int irq, void *p)
 
 	memset(hx711_data->buffer, 0, sizeof(hx711_data->buffer));
 
-	for (i = 0; i < indio_dev->masklength; i++) {
-		if (!test_bit(i, indio_dev->active_scan_mask))
-			continue;
-
+	iio_for_each_active_channel(indio_dev, i) {
 		hx711_data->buffer[j] = hx711_reset_read(hx711_data,
 					indio_dev->channels[i].channel);
 		j++;
author reviewer
#7 lore raw

PATCH 4/22 iio: dummy: iio_simple_dummy_buffer: use iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/dummy/iio_simple_dummy_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dummy/iio_simple_dummy_buffer.c +1 -1
index 9b2f99449a829..4ca3f1aaff999 100644
@@ -68,7 +68,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
 	 * Here let's pretend we have random access. And the values are in the
 	 * constant table fakedata.
 	 */
-	for_each_set_bit(j, indio_dev->active_scan_mask, indio_dev->masklength)
+	iio_for_each_active_channel(indio_dev, j)
 		data[i++] = fakedata[j];
 
 	iio_push_to_buffers_with_timestamp(indio_dev, data,
Signature · 1 line
2.45.2
maintainer Applied
#8 lore raw

Re: [PATCH 04/22] iio: dummy: iio_simple_dummy_buffer: use iio_for_each_active_channel()

Quoted 5 lines · On Thu, 18 Jul 2024 15:37:50 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

Even without the __private bit the new code is nicer!

Quoted 2 lines

Applied.

author reviewer
#9 lore raw

PATCH 5/22 iio: health: afe4403: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/health/afe4403.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/health/afe4403.c +1 -2
index 52326dc521ac..85637e8ac45f 100644
@@ -321,8 +321,7 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 	if (ret)
 		goto err;
 
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		ret = spi_write_then_read(afe->spi,
 					  &afe4403_channel_values[bit], 1,
 					  rx, sizeof(rx));
Signature · 1 line
2.45.2
maintainer Applied
#10 lore raw

Re: [PATCH 05/22] iio: health: afe4403: make use of iio_for_each_active_channel()

Quoted 7 lines · On Thu, 18 Jul 2024 15:37:51 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

Applied

author reviewer
#11 lore raw

PATCH 6/22 iio: health: max30102: make use of iio_get_masklength()

In reply to Nuno Sa

Use iio_get_masklength() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/health/max30102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/health/max30102.c +1 -1
index 07a343e35a81..1d074eb6a8c5 100644
@@ -293,7 +293,7 @@ static irqreturn_t max30102_interrupt_handler(int irq, void *private)
 	struct iio_dev *indio_dev = private;
 	struct max30102_data *data = iio_priv(indio_dev);
 	unsigned int measurements = bitmap_weight(indio_dev->active_scan_mask,
-						  indio_dev->masklength);
+						  iio_get_masklength(indio_dev));
 	int ret, cnt = 0;
 
 	mutex_lock(&data->lock);
Signature · 1 line
2.45.2
maintainer Applied
#12 lore raw

Re: [PATCH 06/22] iio: health: max30102: make use of iio_get_masklength()

Quoted 6 lines · On Thu, 18 Jul 2024 15:37:52 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_get_masklength() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

Applied

author reviewer
#13 lore raw

PATCH 7/22 iio: health: afe4404: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/health/afe4404.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/health/afe4404.c +1 -2
index 7f69baa1ed53..d49e1572a439 100644
@@ -333,8 +333,7 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private)
 	struct afe4404_data *afe = iio_priv(indio_dev);
 	int ret, bit, i = 0;
 
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
 				  &afe->buffer[i++]);
 		if (ret)
Signature · 1 line
2.45.2
maintainer Applied
#14 lore raw

Re: [PATCH 07/22] iio: health: afe4404: make use of iio_for_each_active_channel()

Quoted 7 lines · On Thu, 18 Jul 2024 15:37:53 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

Applied.
Hmm. Maybe I should have been optimistic an looked through whole lot first so as to save on emails ;)

author reviewer
#15 lore raw

PATCH 8/22 iio: humidity: am2315: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/humidity/am2315.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/humidity/am2315.c +1 -2
index a56474be5dd2..6b0aa3a3f025 100644
@@ -174,8 +174,7 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
 		data->scan.chans[1] = sensor_data.temp_data;
 	} else {
 		i = 0;
-		for_each_set_bit(bit, indio_dev->active_scan_mask,
-				 indio_dev->masklength) {
+		iio_for_each_active_channel(indio_dev, bit) {
 			data->scan.chans[i] = (bit ? sensor_data.temp_data :
 					       sensor_data.hum_data);
 			i++;
Signature · 1 line
2.45.2
author reviewer
#16 lore raw

PATCH 9/22 iio: imu: bmi160_core: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/imu/bmi160/bmi160_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/imu/bmi160/bmi160_core.c +1 -2
index 90aa04d94da54..495e8a74ac676 100644
@@ -435,8 +435,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
 	int i, ret, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L;
 	__le16 sample;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		ret = regmap_bulk_read(data->regmap, base + i * sizeof(sample),
 				       &sample, sizeof(sample));
 		if (ret)
Signature · 1 line
2.45.2
author reviewer
#17 lore raw

PATCH 10/22 iio: imu: bno055: make use of iio_get_masklength()

In reply to Nuno Sa

Use iio_get_masklength() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/imu/bno055/bno055.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/bno055/bno055.c +1 -1
index 52744dd98e65b..ea6519b22b2f3 100644
@@ -1458,7 +1458,7 @@ static irqreturn_t bno055_trigger_handler(int irq, void *p)
 	 * then we split the transfer, skipping the gap.
 	 */
 	for_each_set_bitrange(start, end, iio_dev->active_scan_mask,
-			      iio_dev->masklength) {
+			      iio_get_masklength(iio_dev)) {
 		/*
 		 * First transfer will start from the beginning of the first
 		 * ones-field in the bitmap
Signature · 1 line
2.45.2
author reviewer
#18 lore raw

PATCH 11/22 iio: imu: kmx61: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/imu/kmx61.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/imu/kmx61.c +1 -2
index d37eca5ef761..c61c012e25bb 100644
@@ -1200,8 +1200,7 @@ static irqreturn_t kmx61_trigger_handler(int irq, void *p)
 		base = KMX61_MAG_XOUT_L;
 
 	mutex_lock(&data->lock);
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		ret = kmx61_read_measurement(data, base, bit);
 		if (ret < 0) {
 			mutex_unlock(&data->lock);
Signature · 1 line
2.45.2
author reviewer
#19 lore raw

PATCH 12/22 iio: light: adjd_s311: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/adjd_s311.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/light/adjd_s311.c +1 -2
index 5169f12c3ebaf..c1b43053fbc73 100644
@@ -125,8 +125,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto done;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		ret = i2c_smbus_read_word_data(data->client,
 			ADJD_S311_DATA_REG(i));
 		if (ret < 0)
Signature · 1 line
2.45.2
author reviewer
#20 lore raw

PATCH 13/22 iio: light: gp2ap020a00f: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/gp2ap020a00f.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/light/gp2ap020a00f.c +3 -6
index 757383456da6..b3f87dded040 100644
@@ -965,8 +965,7 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data)
 	size_t d_size = 0;
 	int i, out_val, ret;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		ret = regmap_bulk_read(priv->regmap,
 				GP2AP020A00F_DATA_REG(i),
 				&priv->buffer[d_size], 2);
@@ -1397,8 +1396,7 @@ static int gp2ap020a00f_buffer_postenable(struct iio_dev *indio_dev)
 	 * two separate IIO channels they are treated in the driver logic
 	 * as if they were controlled independently.
 	 */
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		switch (i) {
 		case GP2AP020A00F_SCAN_MODE_LIGHT_CLEAR:
 			err = gp2ap020a00f_exec_cmd(data,
@@ -1435,8 +1433,7 @@ static int gp2ap020a00f_buffer_predisable(struct iio_dev *indio_dev)
 
 	mutex_lock(&data->lock);
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		switch (i) {
 		case GP2AP020A00F_SCAN_MODE_LIGHT_CLEAR:
 			err = gp2ap020a00f_exec_cmd(data,
Signature · 1 line
2.45.2
author reviewer
#21 lore raw

PATCH 14/22 iio: light: isl29125: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/isl29125.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/light/isl29125.c +1 -2
index 59329546df58..b176bf4c884b 100644
@@ -181,8 +181,7 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
 	struct isl29125_data *data = iio_priv(indio_dev);
 	int i, j = 0;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		int ret = i2c_smbus_read_word_data(data->client,
 			isl29125_regs[i].data);
 		if (ret < 0)
Signature · 1 line
2.45.2
author reviewer
#22 lore raw

PATCH 15/22 iio: light: si1145: use new '.masklength' accessors

In reply to Nuno Sa

Make use of iio_get_masklength) and iio_for_each_active_channel() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/si1145.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/light/si1145.c +3 -4
index 77666b780a5c5..66abda021696a 100644
@@ -465,11 +465,10 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private)
 			goto done;
 	}
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		int run = 1;
 
-		while (i + run < indio_dev->masklength) {
+		while (i + run < iio_get_masklength(indio_dev)) {
 			if (!test_bit(i + run, indio_dev->active_scan_mask))
 				break;
 			if (indio_dev->channels[i + run].address !=
@@ -514,7 +513,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask)
 	if (data->scan_mask == scan_mask)
 		return 0;
 
-	for_each_set_bit(i, &scan_mask, indio_dev->masklength) {
+	for_each_set_bit(i, &scan_mask, iio_get_masklength(indio_dev)) {
 		switch (indio_dev->channels[i].address) {
 		case SI1145_REG_ALSVIS_DATA:
 			reg |= SI1145_CHLIST_EN_ALSVIS;
Signature · 1 line
2.45.2
author reviewer
#23 lore raw

PATCH 16/22 iio: light: tcs3414: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/tcs3414.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/light/tcs3414.c +1 -2
index c9566615b964..4fecdf10aeb1 100644
@@ -206,8 +206,7 @@ static irqreturn_t tcs3414_trigger_handler(int irq, void *p)
 	struct tcs3414_data *data = iio_priv(indio_dev);
 	int i, j = 0;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		int ret = i2c_smbus_read_word_data(data->client,
 			TCS3414_DATA_GREEN + 2*i);
 		if (ret < 0)
Signature · 1 line
2.45.2
author reviewer
#24 lore raw

PATCH 17/22 iio: light: tcs3472: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/light/tcs3472.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/light/tcs3472.c +1 -2
index 89384dba83dd..04452b4664f3 100644
@@ -383,8 +383,7 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto done;
 
-	for_each_set_bit(i, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, i) {
 		ret = i2c_smbus_read_word_data(data->client,
 			TCS3472_CDATA + 2*i);
 		if (ret < 0)
Signature · 1 line
2.45.2
author reviewer
#25 lore raw

PATCH 18/22 iio: magnetometer: rm3100-core: make use of iio_get_masklength()

In reply to Nuno Sa

Use iio_get_masklength() to access '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/magnetometer/rm3100-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/rm3100-core.c +1 -1
index 42b70cd42b393..0e03a772fa43d 100644
@@ -464,7 +464,7 @@ static irqreturn_t rm3100_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	unsigned long scan_mask = *indio_dev->active_scan_mask;
-	unsigned int mask_len = indio_dev->masklength;
+	unsigned int mask_len = iio_get_masklength(indio_dev);
 	struct rm3100_data *data = iio_priv(indio_dev);
 	struct regmap *regmap = data->regmap;
 	int ret, i, bit;
Signature · 1 line
2.45.2
author reviewer
#26 lore raw

PATCH 19/22 iio: pressure: dlhl60d: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/pressure/dlhl60d.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/pressure/dlhl60d.c +1 -2
index 0bba4c5a8d405..c1cea9d40424e 100644
@@ -256,8 +256,7 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private)
 	if (ret)
 		goto out;
 
-	for_each_set_bit(chn, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, chn) {
 		memcpy(&tmp_buf[i++],
 			&st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES,
 			DLH_NUM_DATA_BYTES);
Signature · 1 line
2.45.2
author reviewer
#27 lore raw

PATCH 20/22 iio: proximity: hx9023s: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/proximity/hx9023s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/hx9023s.c +2 -2
index 63e3b56d4f4ce..fe14a62a13428 100644
@@ -936,7 +936,7 @@ static irqreturn_t hx9023s_trigger_handler(int irq, void *private)
 		goto out;
 	}
 
-	for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		index = indio_dev->channels[bit].channel;
 		data->buffer.channels[i++] = cpu_to_le16(data->ch_data[index].diff);
 	}
@@ -957,7 +957,7 @@ static int hx9023s_buffer_preenable(struct iio_dev *indio_dev)
 	unsigned int bit;
 
 	guard(mutex)(&data->mutex);
-	for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength)
+	iio_for_each_active_channel(indio_dev, bit)
 		__set_bit(indio_dev->channels[bit].channel, &channels);
 
 	hx9023s_update_chan_en(data, channels, data->chan_event);
Signature · 1 line
2.45.2
author reviewer
#28 lore raw

PATCH 21/22 iio: proximity: sx9500: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/proximity/sx9500.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/proximity/sx9500.c +1 -2
index 92630812ece2..3f4eace05cfc 100644
@@ -654,8 +654,7 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
 
 	mutex_lock(&data->mutex);
 
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		ret = sx9500_read_prox_data(data, &indio_dev->channels[bit],
 					    &val);
 		if (ret < 0)
Signature · 1 line
2.45.2
author reviewer
#29 lore raw

PATCH 22/22 iio: proximity: sx_common: make use of iio_for_each_active_channel()

In reply to Nuno Sa

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

---
 drivers/iio/proximity/sx_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/proximity/sx_common.c +2 -4
index a95e9814aaf2..71aa6dced7d3 100644
@@ -369,8 +369,7 @@ static irqreturn_t sx_common_trigger_handler(int irq, void *private)
 
 	mutex_lock(&data->mutex);
 
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength) {
+	iio_for_each_active_channel(indio_dev, bit) {
 		ret = data->chip_info->ops.read_prox_data(data,
 						     &indio_dev->channels[bit],
 						     &val);
@@ -398,8 +397,7 @@ static int sx_common_buffer_preenable(struct iio_dev *indio_dev)
 	int bit, ret;
 
 	mutex_lock(&data->mutex);
-	for_each_set_bit(bit, indio_dev->active_scan_mask,
-			 indio_dev->masklength)
+	iio_for_each_active_channel(indio_dev, bit)
 		__set_bit(indio_dev->channels[bit].channel, &channels);
 
 	ret = sx_common_update_chan_en(data, channels, data->chan_event);
Signature · 1 line
2.45.2
maintainer
#30 lore raw

Re: [PATCH 22/22] iio: proximity: sx_common: make use of iio_for_each_active_channel()

Quoted 7 lines · On Thu, 18 Jul 2024 15:38:08 +0200 Nuno Sa via B4 Relay…

From: Nuno Sa <[email protected]>

Use iio_for_each_active_channel() to iterate over active channels accessing '.masklength' so it can be annotated as __private when there are no more direct users of it.

I applied them all to the testing branch of iio.git which will be rebased on rc1 once available then pushed out as togreg for linux-next to pick up.

A few of the functions that got changes were pieces of nastiness that I'd long banished from my mind so at least I got to look at those again :) Datashuffling logic is 'fun'.

Thanks,

Jonathan

maintainer
#31 lore raw
In reply to Nuno Sa
Quoted 5 lines · On Thu, 18 Jul 2024 15:37:46 +0200 Nuno Sa via B4 Relay…

Hi Jonathan,

Here it goes the second round about annotating .masklength as __private.

Again, only compile tested for arm with allyesconfig.

I'm going to pick up as many of these as I'm happy with. However I'll only be putting them in the testing branch so there is plenty of time yet for additional feedback as I can rebase that as much as needed

Thanks,

Jonathan