Skip to contentSkip to conversation

IIO: Continue removing deprecated iio_push_to_buffers_with_timestamp()

PATCH Applied Jonathan Cameron 9 participants 91 messages Oct 26 – Nov 15

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

cover IIO: Continue removing deprecated iio_push_to_buffers_with_timestamp()

A bit of technical debt cleanup that was partly a discovery exercise in using AI tooling for this sort of somewhat messy subsystem maintenance activity.

Replace iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts() which includes a runtime check that there is sufficient space to insert the timestamp.

A few other modifications of related code seen whilst working through these and a couple of fixes for DMA safety. Those are not sent as separate fixes as they are in old drivers and we have had no reports of problems. So no rush to get upstream.

The remaining users of iio_push_to_buffers_with_timestamp() are the more complex cases that will require more careful review so are left for the next series.

I appreciate this is a large series, so if you have time to take a look review what you can and I'll nibble away at applying the ones that have received sufficient review.

Thanks,

Jonathan

p.s. First time I've used b4 prep for a series, so fingers crossed :)

---
Jonathan Cameron (39):

      iio: adc: ti-adc161s626: use iio_push_to_buffers_with_ts()
      iio: adc: mt6360-adc: use iio_push_to_buffers_with_ts()
      iio: adc: ad4130: use iio_push_to_buffers_with_ts()
      iio: addac: ad74413r: use iio_push_to_buffers_with_ts()
      iio: hid-sensors: use iio_push_to_buffers_with_ts()
      iio: gyro: mpu3050: use iio_push_to_buffers_with_ts()
      iio: imu: bno055: use iio_push_to_buffers_with_ts()
      iio: light: as73211: use iio_push_to_buffers_with_ts()
      iio: light: vcnl4035: use iio_push_to_buffers_with_ts()
      iio: pressure: mprls0025pa: use iio_push_to_buffers_with_ts()
      iio: pressure: ms5611: use iio_push_to_buffers_with_ts()
      iio: proximity: isl29501: use iio_push_to_buffers_with_ts()
      iio: proximity: sx9500: use iio_push_to_buffers_with_ts()
      iio: imu: smi330: use iio_push_to_buffers_with_ts()
      iio: imu: bmi270: use iio_push_to_buffers_with_ts()
      iio: imu: inv_icm42600: use iio_push_to_buffers_with_ts()
      iio: health: afe4403: use iio_push_to_buffers_with_ts()
      iio: health: afe4404: use iio_push_to_buffers_with_ts()
      iio: adc: ad799x: use iio_push_to_buffers_with_ts()
      iio: common: scmi_sensors: use iio_push_to_buffers_with_ts()
      iio: adc: ad7766: use iio_push_to_buffers_with_ts()
      iio: imu: smi240: use iio_push_to_buffers_with_ts()
      iio: adc: cc10001_adc: use iio_push_to_buffers_with_ts()
      iio: adc: hx711: use iio_push_to_buffers_with_ts()
      iio: potentiostat: lmp91000: use iio_push_to_buffers_with_ts() with a scan struct on stack
      iio: humidity: am2315: use iio_push_to_buffers_with_ts() with a scan struct on stack
      iio: humidity: hdc100x: use iio_push_to_buffers_with_ts() with a scan struct on stack
      iio: imu: bmi323: use iio_push_to_buffers_with_ts()
      iio: gyro: fxas21002c: restrict available_scan_masks to all angular velocity channels
      iio: gyro: fxas21002c: use iio_push_to_buffers_with_ts() with explicit structure
      iio: adc: ad7887: ensure tx_cmd_buf is DMA safe
      iio: adc: ad7887: use iio_push_to_buffers_with_ts()
      iio: humidity: hts221: align scan buffer for DMA safety
      iio: humidity: hts221: use iio_push_to_buffers_with_ts()
      iio: accel: bmc150-accel-core: use iio_push_to_buffers_with_ts()
      iio: common: cros_ec_sensors: use iio_push_to_buffers_with_ts()
      iio: common: ssp_sensors: use iio_push_to_buffers_with_ts()
      iio: imu: st_lsm6dsx: use iio_push_to_buffers_with_ts()
      iio: imu: bmi160: use iio_push_to_buffers_with_ts()
 drivers/iio/accel/bmc150-accel-core.c              | 12 ++++-----
 drivers/iio/accel/bmc150-accel.h                   |  1 -
 drivers/iio/adc/ad4130.c                           |  5 ++--
 drivers/iio/adc/ad7766.c                           | 14 +++-------
 drivers/iio/adc/ad7887.c                           | 20 +++++---------
 drivers/iio/adc/ad799x.c                           |  9 +++----
 drivers/iio/adc/cc10001_adc.c                      | 22 +++------------
 drivers/iio/adc/hx711.c                            | 21 +++++----------
 drivers/iio/adc/mt6360-adc.c                       |  3 ++-
 drivers/iio/adc/ti-adc161s626.c                    |  3 ++-
 drivers/iio/addac/ad74413r.c                       |  5 ++--
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  | 24 ++++++++---------
 drivers/iio/common/scmi_sensors/scmi_iio.c         |  7 +++--
 drivers/iio/common/ssp_sensors/ssp_iio.c           | 28 ++++++-------------
 drivers/iio/gyro/fxas21002c_core.c                 | 31 ++++++++++++++--------
 drivers/iio/gyro/hid-sensor-gyro-3d.c              |  5 ++--
 drivers/iio/gyro/mpu3050-core.c                    |  2 +-
 drivers/iio/health/afe4403.c                       | 10 +++----
 drivers/iio/health/afe4404.c                       |  9 +++----
 drivers/iio/humidity/am2315.c                      | 23 +++++++---------
 drivers/iio/humidity/hdc100x.c                     | 15 +++++------
 drivers/iio/humidity/hid-sensor-humidity.c         |  5 ++--
 drivers/iio/humidity/hts221.h                      |  2 +-
 drivers/iio/humidity/hts221_buffer.c               |  4 +--
 drivers/iio/imu/bmi160/bmi160.h                    |  7 -----
 drivers/iio/imu/bmi160/bmi160_core.c               |  6 +++--
 drivers/iio/imu/bmi270/bmi270_core.c               |  4 +--
 drivers/iio/imu/bmi323/bmi323_core.c               | 20 +++++++-------
 drivers/iio/imu/bno055/bno055.c                    |  4 +--
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c  |  3 ++-
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c   |  3 ++-
 drivers/iio/imu/smi240.c                           | 13 +++------
 drivers/iio/imu/smi330/smi330_core.c               |  3 ++-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c     | 17 +++++++-----
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c       |  5 ++--
 drivers/iio/light/as73211.c                        |  3 ++-
 drivers/iio/light/vcnl4035.c                       |  4 +--
 drivers/iio/magnetometer/hid-sensor-magn-3d.c      | 21 +++++----------
 drivers/iio/orientation/hid-sensor-incl-3d.c       |  7 ++---
 .../iio/position/hid-sensor-custom-intel-hinge.c   |  4 +--
 drivers/iio/potentiostat/lmp91000.c                | 15 ++++++-----
 drivers/iio/pressure/mprls0025pa.c                 |  4 +--
 drivers/iio/pressure/ms5611_core.c                 |  4 +--
 drivers/iio/proximity/isl29501.c                   |  3 ++-
 drivers/iio/proximity/sx9500.c                     |  4 +--
 include/linux/iio/common/cros_ec_sensors_core.h    | 18 +++++--------
 include/linux/iio/common/ssp_sensors.h             |  2 --
 47 files changed, 196 insertions(+), 258 deletions(-)

---
base-commit: c9dbe2a47f635465c9985b7af74d2ae310e98125
change-id: 20261026-iio-b9364d28fa05

Best regards,

Signature · 1 line
Jonathan Cameron <[email protected]>
#1 lore raw

PATCH 1/39 iio: adc: ti-adc161s626: use iio_push_to_buffers_with_ts()

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to ti_adc_trigger_handler().

---
Cc: Matt Ranostay <[email protected]>

---
 drivers/iio/adc/ti-adc161s626.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-adc161s626.c +2 -1
index 422df0685580..a0ebe90cff3c 100644
@@ -118,7 +118,8 @@ static irqreturn_t ti_adc_trigger_handler(int irq, void *private)
 		goto exit_notify_done;
 
 	scan.data = val;
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
  exit_notify_done:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/39 iio: adc: mt6360-adc: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to mt6360_adc_trigger_handler().

---
Cc: Gene Chen <[email protected]>

---
 drivers/iio/adc/mt6360-adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/mt6360-adc.c +2 -1
index e59b13e88aa2..a09e3e38c390 100644
@@ -275,7 +275,8 @@ static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p)
 
 		data.values[i++] = val;
 	}
-	iio_push_to_buffers_with_timestamp(indio_dev, &data, iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &data, sizeof(data),
+				    iio_get_time_ns(indio_dev));
 out:
 	iio_trigger_notify_done(indio_dev->trig);
 
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/39 iio: adc: ad4130: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

---
Cc: Jonathan Santos <[email protected]>

---
 drivers/iio/adc/ad4130.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/ad4130.c +3 -2
index 3ffc4b765e0e..9763a811caa3 100644
@@ -704,8 +704,9 @@ static irqreturn_t ad4130_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto err_out;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &st->scan_channels,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &st->scan_channels,
+				    sizeof(st->scan_channels),
+				    iio_get_time_ns(indio_dev));
 
 err_out:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/39 iio: addac: ad74413r: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Antoniu Miclaus <[email protected]>

---
 drivers/iio/addac/ad74413r.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/addac/ad74413r.c +3 -2
index 2e5a58e48a89..8d9d3d5f09c6 100644
@@ -798,8 +798,9 @@ static irqreturn_t ad74413r_trigger_handler(int irq, void *p)
 	for (i = 0; i < st->adc_active_channels; i++)
 		ad74413r_crc_check(st, &rx_buf[i * AD74413R_FRAME_SIZE]);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &st->adc_samples_buf,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &st->adc_samples_buf,
+				    sizeof(st->adc_samples_buf),
+				    iio_get_time_ns(indio_dev));
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 04/39] iio: addac: ad74413r: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Mon, 26 Oct 2026 16:05:22 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

In the interests of nibbling down at the outstanding list, I've applied patches 1-4 as they are all on the trivial side.

Thanks,

Jonathan

Quoted 23 lines

---
Cc: Antoniu Miclaus <[email protected]>

---
 drivers/iio/addac/ad74413r.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/addac/ad74413r.c +3 -2
index 2e5a58e48a89..8d9d3d5f09c6 100644
@@ -798,8 +798,9 @@ static irqreturn_t ad74413r_trigger_handler(int irq, void *p)
 	for (i = 0; i < st->adc_active_channels; i++)
 		ad74413r_crc_check(st, &rx_buf[i * AD74413R_FRAME_SIZE]);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &st->adc_samples_buf,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &st->adc_samples_buf,
+				    sizeof(st->adc_samples_buf),
+				    iio_get_time_ns(indio_dev));
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);
#6 lore raw

PATCH 5/39 iio: hid-sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the buffer for the maximum number of channels supported avoiding need for separate allocation.

---
Cc: Jiri Kosina <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Zhang Lixu <[email protected]>

---
 drivers/iio/gyro/hid-sensor-gyro-3d.c               |  5 +++--
 drivers/iio/humidity/hid-sensor-humidity.c          |  5 +++--
 drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 21 ++++++---------------
 drivers/iio/orientation/hid-sensor-incl-3d.c        |  7 ++++---
 .../iio/position/hid-sensor-custom-intel-hinge.c    |  4 ++--
 5 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +3 -2
index 66778315e86d..083e82cf561c 100644
@@ -182,8 +182,9 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev,
 		if (!gyro_state->timestamp)
 			gyro_state->timestamp = iio_get_time_ns(indio_dev);
 
-		iio_push_to_buffers_with_timestamp(indio_dev, &gyro_state->scan,
-						   gyro_state->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev, &gyro_state->scan,
+					    sizeof(gyro_state->scan),
+					    gyro_state->timestamp);
 
 		gyro_state->timestamp = 0;
 	}
drivers/iio/humidity/hid-sensor-humidity.c +3 -2
index 12c88efe66be..c09986346c8f 100644
@@ -132,8 +132,9 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev,
 	struct hid_humidity_state *humid_st = iio_priv(indio_dev);
 
 	if (atomic_read(&humid_st->common_attributes.data_ready))
-		iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan,
-						   iio_get_time_ns(indio_dev));
+		iio_push_to_buffers_with_ts(indio_dev, &humid_st->scan,
+					    sizeof(humid_st->scan),
+					    iio_get_time_ns(indio_dev));
 
 	return 0;
 }
drivers/iio/magnetometer/hid-sensor-magn-3d.c +6 -15
index c8b4fa7785c9..f869560b47fc 100644
@@ -37,8 +37,8 @@ struct magn_3d_state {
 	struct hid_sensor_common rot_attributes;
 	struct hid_sensor_hub_attribute_info magn[MAGN_3D_CHANNEL_MAX];
 
-	/* dynamically sized array to hold sensor values */
-	u32 *iio_vals;
+	/* array sized to hold maximum set of sensor values */
+	IIO_DECLARE_BUFFER_WITH_TS(u32, iio_vals, MAGN_3D_CHANNEL_MAX);
 	/* array of pointers to sensor value */
 	u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];
 
@@ -275,9 +275,10 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
 		if (!magn_state->timestamp)
 			magn_state->timestamp = iio_get_time_ns(indio_dev);
 
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   magn_state->iio_vals,
-						   magn_state->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev,
+					    magn_state->iio_vals,
+					    sizeof(magn_state->iio_vals),
+					    magn_state->timestamp);
 		magn_state->timestamp = 0;
 	}
 
@@ -379,16 +380,6 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 		return -ENOMEM;
 	}
 
-	/* attr_count include timestamp channel, and the iio_vals should be aligned to 8byte */
-	st->iio_vals = devm_kcalloc(&pdev->dev,
-				    ((attr_count + 1) % 2 + (attr_count + 1) / 2) * 2,
-				    sizeof(u32), GFP_KERNEL);
-	if (!st->iio_vals) {
-		dev_err(&pdev->dev,
-			"failed to allocate space for iio values array\n");
-		return -ENOMEM;
-	}
-
 	for (i = 0, *chan_count = 0;
 	i < MAGN_3D_CHANNEL_MAX && *chan_count < attr_count;
 	i++){
drivers/iio/orientation/hid-sensor-incl-3d.c +4 -3
index b5f70732d035..3880e479a499 100644
@@ -194,9 +194,10 @@ static int incl_3d_proc_event(struct hid_sensor_hub_device *hsdev,
 		if (!incl_state->timestamp)
 			incl_state->timestamp = iio_get_time_ns(indio_dev);
 
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   &incl_state->scan,
-						   incl_state->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev,
+					    &incl_state->scan,
+					    sizeof(incl_state->scan),
+					    incl_state->timestamp);
 
 		incl_state->timestamp = 0;
 	}
drivers/iio/position/hid-sensor-custom-intel-hinge.c +2 -2
index 101d84b533c9..98a5e3e03bba 100644
@@ -198,8 +198,8 @@ static int hinge_proc_event(struct hid_sensor_hub_device *hsdev,
 		if (!st->timestamp)
 			st->timestamp = iio_get_time_ns(indio_dev);
 
-		iio_push_to_buffers_with_timestamp(indio_dev, &st->scan,
-						   st->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev, &st->scan,
+					    sizeof(st->scan), st->timestamp);
 
 		st->timestamp = 0;
 	}
Signature · 1 line
2.43.0
#7 lore raw

Re: [PATCH 05/39] iio: hid-sensors: use iio_push_to_buffers_with_ts()

Quoted 8 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the buffer for the maximum number of channels supported avoiding need for separate allocation.

LGTM.
I will do some quick test on this and let you know.

Thanks,
Srinivas

Quoted 159 lines

---
Cc: Jiri Kosina <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Zhang Lixu <[email protected]>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c               |  5 +++-- drivers/iio/humidity/hid-sensor-humidity.c          |  5 +++-- drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 21 ++++++-----
----------
 drivers/iio/orientation/hid-sensor-incl-3d.c        |  7 ++++--- .../iio/position/hid-sensor-custom-intel-hinge.c    |  4 ++--

 5 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -0
index 66778315e86d..083e82cf561c 100644
@@ -182,8 +182,9 @@ static int gyro_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!gyro_state->timestamp)

  gyro_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&gyro_state->scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-						   gyro_state-
Quoted 1 line

timestamp);

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &gyro_state-
Quoted 1 line

scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    sizeof(gyro_state-
Quoted 1 line

scan),

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    gyro_state->timestamp);


  gyro_state->timestamp = 0;
  }

drivers/iio/humidity/hid-sensor-humidity.c +0 -0
index 12c88efe66be..c09986346c8f 100644
@@ -132,8 +132,9 @@ static int humidity_proc_event(struct
 hid_sensor_hub_device *hsdev,
  	struct hid_humidity_state *humid_st = iio_priv(indio_dev);


  if (atomic_read(&humid_st->common_attributes.data_ready))

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&humid_st->scan,

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-						  

iio_get_time_ns(indio_dev));

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &humid_st-
Quoted 1 line

scan,

drivers/iio/humidity/hid-sensor-humidity.c +2 -0
+					    sizeof(humid_st->scan),
+					   

iio_get_time_ns(indio_dev));

  return 0;
 }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
index c8b4fa7785c9..f869560b47fc 100644
@@ -37,8 +37,8 @@ struct magn_3d_state {
  	struct hid_sensor_common rot_attributes;

  struct hid_sensor_hub_attribute_info
magn[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -2
-	/* dynamically sized array to hold sensor values */
-	u32 *iio_vals;
+	/* array sized to hold maximum set of sensor values */
+	IIO_DECLARE_BUFFER_WITH_TS(u32, iio_vals,

MAGN_3D_CHANNEL_MAX);
  /* array of pointers to sensor value */
  u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -275,9 +275,10 @@ static int magn_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!magn_state->timestamp)

  magn_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   magn_state-
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-						   magn_state-
Quoted 1 line

timestamp);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    magn_state->iio_vals,
+					    sizeof(magn_state-
Quoted 1 line

iio_vals),

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    magn_state->timestamp);

  magn_state->timestamp = 0;
  }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -379,16 +380,6 @@ static int magn_3d_parse_report(struct
 platform_device *pdev,
  		return -ENOMEM;
  	}

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-	/* attr_count include timestamp channel, and the iio_vals

should be aligned to 8byte */

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-	st->iio_vals = devm_kcalloc(&pdev->dev,
-				    ((attr_count + 1) % 2 +

(attr_count + 1) / 2) * 2,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -4
-				    sizeof(u32), GFP_KERNEL);
-	if (!st->iio_vals) {
-		dev_err(&pdev->dev,
-			"failed to allocate space for iio values

array\n");

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -3
-		return -ENOMEM;
-	}
-

  for (i = 0, *chan_count = 0;
  i < MAGN_3D_CHANNEL_MAX && *chan_count < attr_count; i++){

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -0
index b5f70732d035..3880e479a499 100644
@@ -194,9 +194,10 @@ static int incl_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!incl_state->timestamp)

  incl_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   &incl_state-
Quoted 1 line

scan,

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -1
-						   incl_state-
Quoted 1 line

timestamp);

drivers/iio/orientation/hid-sensor-incl-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    &incl_state->scan,
+					    sizeof(incl_state-
Quoted 1 line

scan),

drivers/iio/orientation/hid-sensor-incl-3d.c +1 -0
+					    incl_state->timestamp);


  incl_state->timestamp = 0;
  }

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -0
index 101d84b533c9..98a5e3e03bba 100644
@@ -198,8 +198,8 @@ static int hinge_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!st->timestamp)
  			st->timestamp = iio_get_time_ns(indio_dev);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev, &st-
Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +2 -1
-						   st->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev, &st->scan,
+					    sizeof(st->scan), st-
Quoted 1 line

timestamp);


  st->timestamp = 0;
  }

maintainer
#8 lore raw

Re: [PATCH 05/39] iio: hid-sensors: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Mon, 26 Oct 2026 17:06:23 -0700 srinivas pandruvada…
Quoted 3 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Quoted 8 lines
Quoted 5 lines

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the buffer for the maximum number of channels supported avoiding need for separate allocation.

LGTM.
I will do some quick test on this and let you know.

No huge rush. This is the only one I'm going to leave unapplied that doesn't need changes (as far as I know!) for now.

Thanks,

Jonathan

Quoted 164 lines

Thanks,
Srinivas

Quoted 159 lines

---
Cc: Jiri Kosina <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Zhang Lixu <[email protected]>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c               |  5 +++-- drivers/iio/humidity/hid-sensor-humidity.c          |  5 +++-- drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 21 ++++++-----
----------
 drivers/iio/orientation/hid-sensor-incl-3d.c        |  7 ++++--- .../iio/position/hid-sensor-custom-intel-hinge.c    |  4 ++--

 5 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -0
index 66778315e86d..083e82cf561c 100644
@@ -182,8 +182,9 @@ static int gyro_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!gyro_state->timestamp)

  gyro_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&gyro_state->scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-						   gyro_state-  
Quoted 1 line

timestamp);

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &gyro_state-  
Quoted 1 line

scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    sizeof(gyro_state-  
Quoted 1 line

scan),

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    gyro_state->timestamp);


  gyro_state->timestamp = 0;
  }

drivers/iio/humidity/hid-sensor-humidity.c +0 -0
index 12c88efe66be..c09986346c8f 100644
@@ -132,8 +132,9 @@ static int humidity_proc_event(struct
 hid_sensor_hub_device *hsdev,
  	struct hid_humidity_state *humid_st = iio_priv(indio_dev);


  if (atomic_read(&humid_st->common_attributes.data_ready))

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&humid_st->scan,

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-						  

iio_get_time_ns(indio_dev));

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &humid_st-  
Quoted 1 line

scan,

drivers/iio/humidity/hid-sensor-humidity.c +2 -0
+					    sizeof(humid_st->scan),
+					   

iio_get_time_ns(indio_dev));

  return 0;
 }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
index c8b4fa7785c9..f869560b47fc 100644
@@ -37,8 +37,8 @@ struct magn_3d_state {
  	struct hid_sensor_common rot_attributes;

  struct hid_sensor_hub_attribute_info
magn[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -2
-	/* dynamically sized array to hold sensor values */
-	u32 *iio_vals;
+	/* array sized to hold maximum set of sensor values */
+	IIO_DECLARE_BUFFER_WITH_TS(u32, iio_vals,

MAGN_3D_CHANNEL_MAX);
  /* array of pointers to sensor value */
  u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -275,9 +275,10 @@ static int magn_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!magn_state->timestamp)

  magn_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   magn_state-  
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-						   magn_state-  
Quoted 1 line

timestamp);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    magn_state->iio_vals,
+					    sizeof(magn_state-  
Quoted 1 line

iio_vals),

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    magn_state->timestamp);

  magn_state->timestamp = 0;
  }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -379,16 +380,6 @@ static int magn_3d_parse_report(struct
 platform_device *pdev,
  		return -ENOMEM;
  	}

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-	/* attr_count include timestamp channel, and the iio_vals

should be aligned to 8byte */

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-	st->iio_vals = devm_kcalloc(&pdev->dev,
-				    ((attr_count + 1) % 2 +

(attr_count + 1) / 2) * 2,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -4
-				    sizeof(u32), GFP_KERNEL);
-	if (!st->iio_vals) {
-		dev_err(&pdev->dev,
-			"failed to allocate space for iio values

array\n");

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -3
-		return -ENOMEM;
-	}
-

  for (i = 0, *chan_count = 0;
  i < MAGN_3D_CHANNEL_MAX && *chan_count < attr_count; i++){

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -0
index b5f70732d035..3880e479a499 100644
@@ -194,9 +194,10 @@ static int incl_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!incl_state->timestamp)

  incl_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   &incl_state-  
Quoted 1 line

scan,

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -1
-						   incl_state-  
Quoted 1 line

timestamp);

drivers/iio/orientation/hid-sensor-incl-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    &incl_state->scan,
+					    sizeof(incl_state-  
Quoted 1 line

scan),

drivers/iio/orientation/hid-sensor-incl-3d.c +1 -0
+					    incl_state->timestamp);


  incl_state->timestamp = 0;
  }

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -0
index 101d84b533c9..98a5e3e03bba 100644
@@ -198,8 +198,8 @@ static int hinge_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!st->timestamp)
  			st->timestamp = iio_get_time_ns(indio_dev);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev, &st-  
Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +2 -1
-						   st->timestamp);
+		iio_push_to_buffers_with_ts(indio_dev, &st->scan,
+					    sizeof(st->scan), st-  
Quoted 1 line

timestamp);


  st->timestamp = 0;
  }

maintainer Tested-by
#9 lore raw

Re: [PATCH 05/39] iio: hid-sensors: use iio_push_to_buffers_with_ts()

Hi Jonathan,

Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · On Mon, 26 Oct 2026 17:06:23 -0700 srinivas pandruvada…
Quoted 9 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the
buffer for the maximum number of channels supported avoiding need for separate allocation.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Signed-off-by: Jonathan Cameron
<[email protected]>

LGTM.
I will do some quick test on this and let you know.

No huge rush.  This is the only one I'm going to leave unapplied that doesn't need changes (as far as I know!) for now.

Thanks,
Srinivas

Quoted 184 lines

Thanks,

Jonathan

Quoted 180 lines

Thanks,
Srinivas

Quoted 175 lines

---
Cc: Jiri Kosina <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Zhang Lixu <[email protected]>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c               |  5 +++-- drivers/iio/humidity/hid-sensor-humidity.c          |  5 +++-- drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 21 ++++++-
----
----------
 drivers/iio/orientation/hid-sensor-incl-3d.c        |  7 ++++--- .../iio/position/hid-sensor-custom-intel-hinge.c    |  4 ++--

 5 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -0
index 66778315e86d..083e82cf561c 100644
@@ -182,8 +182,9 @@ static int gyro_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!gyro_state->timestamp)

  gyro_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&gyro_state->scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-						   gyro_state-  
Quoted 1 line

timestamp);

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev,

&gyro_state-

Quoted 1 line

scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    sizeof(gyro_state-  
Quoted 1 line

scan),

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    gyro_state-
Quoted 1 line

timestamp);


  gyro_state->timestamp = 0;
  }

drivers/iio/humidity/hid-sensor-humidity.c +0 -0
index 12c88efe66be..c09986346c8f 100644
@@ -132,8 +132,9 @@ static int humidity_proc_event(struct
 hid_sensor_hub_device *hsdev,

  struct hid_humidity_state *humid_st =
iio_priv(indio_dev);

  if (atomic_read(&humid_st-

Quoted 1 line

common_attributes.data_ready))

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&humid_st->scan,

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-						  

iio_get_time_ns(indio_dev));

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev,

&humid_st-

Quoted 1 line

scan,

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+					    sizeof(humid_st-
Quoted 1 line

scan),

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+					   

iio_get_time_ns(indio_dev));

  return 0;
 }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
index c8b4fa7785c9..f869560b47fc 100644
@@ -37,8 +37,8 @@ struct magn_3d_state {
  	struct hid_sensor_common rot_attributes;

  struct hid_sensor_hub_attribute_info
magn[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -2
-	/* dynamically sized array to hold sensor values */
-	u32 *iio_vals;
+	/* array sized to hold maximum set of sensor values */
+	IIO_DECLARE_BUFFER_WITH_TS(u32, iio_vals,

MAGN_3D_CHANNEL_MAX);
  /* array of pointers to sensor value */
  u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -275,9 +275,10 @@ static int magn_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!magn_state->timestamp)

  magn_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   magn_state-  
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-						   magn_state-  
Quoted 1 line

timestamp);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    magn_state-
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    sizeof(magn_state-  
Quoted 1 line

iio_vals),

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    magn_state-
Quoted 1 line

timestamp);

  magn_state->timestamp = 0;
  }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -379,16 +380,6 @@ static int magn_3d_parse_report(struct
 platform_device *pdev,
  		return -ENOMEM;
  	}

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-	/* attr_count include timestamp channel, and the

iio_vals
should be aligned to 8byte */

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-	st->iio_vals = devm_kcalloc(&pdev->dev,
-				    ((attr_count + 1) % 2 +

(attr_count + 1) / 2) * 2,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -4
-				    sizeof(u32), GFP_KERNEL);
-	if (!st->iio_vals) {
-		dev_err(&pdev->dev,
-			"failed to allocate space for iio values

array\n");

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -3
-		return -ENOMEM;
-	}
-

  for (i = 0, *chan_count = 0;
  i < MAGN_3D_CHANNEL_MAX && *chan_count < attr_count; i++){

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -0
index b5f70732d035..3880e479a499 100644
@@ -194,9 +194,10 @@ static int incl_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!incl_state->timestamp)

  incl_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   &incl_state- 
Quoted 1 line

scan,

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -1
-						   incl_state-  
Quoted 1 line

timestamp);

drivers/iio/orientation/hid-sensor-incl-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    &incl_state->scan,
+					    sizeof(incl_state-  
Quoted 1 line

scan),

drivers/iio/orientation/hid-sensor-incl-3d.c +1 -0
+					    incl_state-
Quoted 1 line

timestamp);


  incl_state->timestamp = 0;
  }

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -0
index 101d84b533c9..98a5e3e03bba 100644
@@ -198,8 +198,8 @@ static int hinge_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!st->timestamp)

  st->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&st-

Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-						   st-
Quoted 1 line

timestamp);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &st-
Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +1 -0
+					    sizeof(st->scan),

st-

Quoted 1 line

timestamp);


  st->timestamp = 0;
  }

maintainer
#10 lore raw

Re: [PATCH 05/39] iio: hid-sensors: use iio_push_to_buffers_with_ts()

Quoted 18 lines · On Sun, 15 Nov 2026 12:06:03 -0800 srinivas pandruvada…

Hi Jonathan,

Quoted 16 lines · Jonathan Cameron
Quoted 13 lines · On Mon, 26 Oct 2026 17:06:23 -0700 srinivas pandruvada…
Quoted 11 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the
buffer for the maximum number of channels supported avoiding need for separate allocation.

Signed-off-by: Jonathan Cameron
<[email protected]>

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

LGTM.
I will do some quick test on this and let you know.

No huge rush.  This is the only one I'm going to leave unapplied that doesn't need changes (as far as I know!) for now.

Thanks. Applied.

Quoted 188 lines

Thanks,
Srinivas

Quoted 184 lines

Thanks,

Jonathan

Quoted 180 lines

Thanks,
Srinivas

Quoted 175 lines

---
Cc: Jiri Kosina <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Zhang Lixu <[email protected]>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c               |  5 +++-- drivers/iio/humidity/hid-sensor-humidity.c          |  5 +++-- drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 21 ++++++-
----
----------
 drivers/iio/orientation/hid-sensor-incl-3d.c        |  7 ++++--- .../iio/position/hid-sensor-custom-intel-hinge.c    |  4 ++--

 5 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -0
index 66778315e86d..083e82cf561c 100644
@@ -182,8 +182,9 @@ static int gyro_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!gyro_state->timestamp)

  gyro_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&gyro_state->scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +0 -1
-						   gyro_state-    
Quoted 1 line

timestamp);

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev,

&gyro_state-

Quoted 1 line

scan,

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    sizeof(gyro_state-    
Quoted 1 line

scan),

drivers/iio/gyro/hid-sensor-gyro-3d.c +1 -0
+					    gyro_state-  
Quoted 1 line

timestamp);


  gyro_state->timestamp = 0;
  }

drivers/iio/humidity/hid-sensor-humidity.c +0 -0
index 12c88efe66be..c09986346c8f 100644
@@ -132,8 +132,9 @@ static int humidity_proc_event(struct
 hid_sensor_hub_device *hsdev,

  struct hid_humidity_state *humid_st =
iio_priv(indio_dev);

  if (atomic_read(&humid_st-

Quoted 1 line

common_attributes.data_ready))

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&humid_st->scan,

drivers/iio/humidity/hid-sensor-humidity.c +0 -1
-						  

iio_get_time_ns(indio_dev));

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev,

&humid_st-

Quoted 1 line

scan,

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+					    sizeof(humid_st-  
Quoted 1 line

scan),

drivers/iio/humidity/hid-sensor-humidity.c +1 -0
+					   

iio_get_time_ns(indio_dev));

  return 0;
 }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
index c8b4fa7785c9..f869560b47fc 100644
@@ -37,8 +37,8 @@ struct magn_3d_state {
  	struct hid_sensor_common rot_attributes;

  struct hid_sensor_hub_attribute_info
magn[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -2
-	/* dynamically sized array to hold sensor values */
-	u32 *iio_vals;
+	/* array sized to hold maximum set of sensor values */
+	IIO_DECLARE_BUFFER_WITH_TS(u32, iio_vals,

MAGN_3D_CHANNEL_MAX);
  /* array of pointers to sensor value */
  u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -275,9 +275,10 @@ static int magn_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!magn_state->timestamp)

  magn_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   magn_state-    
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-						   magn_state-    
Quoted 1 line

timestamp);

drivers/iio/magnetometer/hid-sensor-magn-3d.c +2 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    magn_state-  
Quoted 1 line

iio_vals,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    sizeof(magn_state-    
Quoted 1 line

iio_vals),

drivers/iio/magnetometer/hid-sensor-magn-3d.c +1 -0
+					    magn_state-  
Quoted 1 line

timestamp);

  magn_state->timestamp = 0;
  }

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -0
@@ -379,16 +380,6 @@ static int magn_3d_parse_report(struct
 platform_device *pdev,
  		return -ENOMEM;
  	}

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -1
-	/* attr_count include timestamp channel, and the

iio_vals
should be aligned to 8byte */

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -2
-	st->iio_vals = devm_kcalloc(&pdev->dev,
-				    ((attr_count + 1) % 2 +

(attr_count + 1) / 2) * 2,

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -4
-				    sizeof(u32), GFP_KERNEL);
-	if (!st->iio_vals) {
-		dev_err(&pdev->dev,
-			"failed to allocate space for iio values

array\n");

drivers/iio/magnetometer/hid-sensor-magn-3d.c +0 -3
-		return -ENOMEM;
-	}
-

  for (i = 0, *chan_count = 0;
  i < MAGN_3D_CHANNEL_MAX && *chan_count < attr_count; i++){

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -0
index b5f70732d035..3880e479a499 100644
@@ -194,9 +194,10 @@ static int incl_3d_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!incl_state->timestamp)

  incl_state->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -2
-		iio_push_to_buffers_with_timestamp(indio_dev,
-						   &incl_state-   
Quoted 1 line

scan,

drivers/iio/orientation/hid-sensor-incl-3d.c +0 -1
-						   incl_state-    
Quoted 1 line

timestamp);

drivers/iio/orientation/hid-sensor-incl-3d.c +3 -0
+		iio_push_to_buffers_with_ts(indio_dev,
+					    &incl_state->scan,
+					    sizeof(incl_state-    
Quoted 1 line

scan),

drivers/iio/orientation/hid-sensor-incl-3d.c +1 -0
+					    incl_state-  
Quoted 1 line

timestamp);


  incl_state->timestamp = 0;
  }

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -0
index 101d84b533c9..98a5e3e03bba 100644
@@ -198,8 +198,8 @@ static int hinge_proc_event(struct
 hid_sensor_hub_device *hsdev,
  		if (!st->timestamp)

  st->timestamp =
iio_get_time_ns(indio_dev);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-		iio_push_to_buffers_with_timestamp(indio_dev,

&st-

Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +0 -1
-						   st-  
Quoted 1 line

timestamp);

drivers/iio/position/hid-sensor-custom-intel-hinge.c +1 -0
+		iio_push_to_buffers_with_ts(indio_dev, &st-  
Quoted 1 line

scan,

drivers/iio/position/hid-sensor-custom-intel-hinge.c +1 -0
+					    sizeof(st->scan),

st-

Quoted 1 line

timestamp);


  st->timestamp = 0;
  }

#11 lore raw

Re: [PATCH 05/39] iio: hid-sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron
Quoted 6 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

For hid-sensor-magn-3d, use IIO_DECLARE_BUFFER_WITH_TS() to suize the buffer for the maximum number of channels supported avoiding need for separate allocation.

I was staring at this for a while. The feeling is that it has to work as we don't register more channels than it was reported by the HW. Since the patch makes the buffer static of maximum size, the _with_ts() should handle this correctly.

But it would be nice to check, indeed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

PATCH 6/39 iio: gyro: mpu3050: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to mpu3050_trigger_handler().

---
Cc: Cong Nguyen <[email protected]>
Cc: Ethan Tidmore <[email protected]>

---
 drivers/iio/gyro/mpu3050-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/mpu3050-core.c +1 -1
index 07c0f9011c63..f91b1173c2a2 100644
@@ -637,7 +637,7 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
 		goto out_trigger_unlock;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), timestamp);
 
 out_trigger_unlock:
 	mutex_unlock(&mpu3050->lock);
Signature · 1 line
2.43.0
#13 lore raw

PATCH 7/39 iio: imu: bno055: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
 drivers/iio/imu/bno055/bno055.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bno055/bno055.c +2 -2
index d0101607a9b3..b1c7b4f88bf1 100644
@@ -1543,8 +1543,8 @@ static irqreturn_t bno055_trigger_handler(int irq, void *p)
 			       mask, priv->buf.chans, &buf_idx);
 
 	if (!ret)
-		iio_push_to_buffers_with_timestamp(iio_dev,
-						   &priv->buf, pf->timestamp);
+		iio_push_to_buffers_with_ts(iio_dev, &priv->buf,
+					    sizeof(priv->buf), pf->timestamp);
 done:
 	mutex_unlock(&priv->lock);
 	iio_trigger_notify_done(iio_dev->trig);
Signature · 1 line
2.43.0
#14 lore raw

Re: [PATCH 07/39] iio: imu: bno055: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Mon, 26 Oct 2026 16:05:25 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

More nibbling. Applied 6 and 7.

I should have moved that hid one. Initially I had it incorrectly not using a fixed sized buffer for all cases and so it looked trivial. When I fixed that I failed to shuffle it to later in the series where the more 'interesting' cases lie.

Note there are still a few 'really interesting' cases that I haven't figure out how to deal with at all yet.

Jonathan

Quoted 20 lines
---
 drivers/iio/imu/bno055/bno055.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bno055/bno055.c +2 -2
index d0101607a9b3..b1c7b4f88bf1 100644
@@ -1543,8 +1543,8 @@ static irqreturn_t bno055_trigger_handler(int irq, void *p)
 			       mask, priv->buf.chans, &buf_idx);
 
 	if (!ret)
-		iio_push_to_buffers_with_timestamp(iio_dev,
-						   &priv->buf, pf->timestamp);
+		iio_push_to_buffers_with_ts(iio_dev, &priv->buf,
+					    sizeof(priv->buf), pf->timestamp);
 done:
 	mutex_unlock(&priv->lock);
 	iio_trigger_notify_done(iio_dev->trig);
#15 lore raw

PATCH 8/39 iio: light: as73211: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to as73211_trigger_handler().

---
Cc: Christian Eggers <[email protected]>
Cc: Javier Carrasco <[email protected]>

---
 drivers/iio/light/as73211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/as73211.c +2 -1
index 67f33bbe1c13..675866029cd7 100644
@@ -695,7 +695,8 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
 		}
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 done:
 	mutex_unlock(&data->mutex);
Signature · 1 line
2.43.0
Reviewed-by on v1 8/39
#16 lore raw

Re: [PATCH 08/39] iio: light: as73211: use iio_push_to_buffers_with_ts()

Quoted 17 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to as73211_trigger_handler().

---
Cc: Christian Eggers <[email protected]>
Cc: Javier Carrasco <[email protected]>

---
 drivers/iio/light/as73211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/as73211.c +0 -0
index 67f33bbe1c13..675866029cd7 100644

drivers/iio/light/as73211.c static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p) · line 702

Quoted 9 lines
drivers/iio/light/as73211.c +2 -1
@@ -695,7 +695,8 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
 		}
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 done:
 	mutex_unlock(&data->mutex);
maintainer
#17 lore raw

Re: [PATCH 08/39] iio: light: as73211: use iio_push_to_buffers_with_ts()

Quoted 21 lines · On Mon, 26 Oct 2026 21:09:05 -0500 "Javier Carrasco"…
Quoted 20 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to as73211_trigger_handler().

---
Cc: Christian Eggers <[email protected]>
Cc: Javier Carrasco <[email protected]>

---
 drivers/iio/light/as73211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/as73211.c +0 -0
index 67f33bbe1c13..675866029cd7 100644
@@ -695,7 +695,8 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
 		}
 	}
 
Quoted 8 lines

drivers/iio/light/as73211.c static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p) · line 702

Quoted 6 lines
drivers/iio/light/as73211.c +2 -1
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 done:
 	mutex_unlock(&data->mutex);  

Applied thanks,

J

Quoted 1 line
#18 lore raw

PATCH 9/39 iio: light: vcnl4035: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to vcnl4035_trigger_consumer_handler().

---
 drivers/iio/light/vcnl4035.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/light/vcnl4035.c +2 -2
index ce1bd42b0c7c..23bd0d42363d 100644
@@ -118,8 +118,8 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
 	}
 
 	buffer.als_data = val;
-	iio_push_to_buffers_with_timestamp(indio_dev, &buffer,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &buffer, sizeof(buffer),
+				    iio_get_time_ns(indio_dev));
 
 fail_read:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
#19 lore raw

PATCH 10/39 iio: pressure: mprls0025pa: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

---
Cc: Petre Rodan <[email protected]>

---
 drivers/iio/pressure/mprls0025pa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/mprls0025pa.c +2 -2
index c21f0a050660..1454c2837077 100644
@@ -277,8 +277,8 @@ static irqreturn_t mpr_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->chan,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &data->chan, sizeof(data->chan),
+				    iio_get_time_ns(indio_dev));
 
 err:
 	mutex_unlock(&data->lock);
Signature · 1 line
2.43.0
#20 lore raw

PATCH 11/39 iio: pressure: ms5611: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to ms5611_trigger_handler().

---
 drivers/iio/pressure/ms5611_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/ms5611_core.c +2 -2
index bdac27bd5a5d..72c769f9b6ad 100644
@@ -224,8 +224,8 @@ static irqreturn_t ms5611_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 err:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
maintainer
#21 lore raw

Re: [PATCH 11/39] iio: pressure: ms5611: use iio_push_to_buffers_with_ts()

Quoted 5 lines · On Mon, 26 Oct 2026 16:05:29 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to ms5611_trigger_handler().

Applied 9-11. More nibbling away at the set to cut down on what is outstanding.

My own fault of course for sending a large set :(

Jonathan

Quoted 20 lines
---
 drivers/iio/pressure/ms5611_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/ms5611_core.c +2 -2
index bdac27bd5a5d..72c769f9b6ad 100644
@@ -224,8 +224,8 @@ static irqreturn_t ms5611_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 err:
 	iio_trigger_notify_done(indio_dev->trig);
#22 lore raw

PATCH 12/39 iio: proximity: isl29501: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
 drivers/iio/proximity/isl29501.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/proximity/isl29501.c +2 -1
index a98a9975323c..149bd57bfdf0 100644
@@ -948,7 +948,8 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p)
 		scan.data = value;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);
 	iio_trigger_notify_done(indio_dev->trig);
 
 	return IRQ_HANDLED;
Signature · 1 line
2.43.0
#23 lore raw

Re: [PATCH 12/39] iio: proximity: isl29501: use iio_push_to_buffers_with_ts()

Quoted 2 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

...

drivers/iio/proximity/isl29501.c static irqreturn_t isl29501_trigger_handler(int irq, void *p) · line 952

Quoted 3 lines
drivers/iio/proximity/isl29501.c +2 -1
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);

I would leave it on a single line (83 characters only).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#24 lore raw

Re: [PATCH 12/39] iio: proximity: isl29501: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Tue, 27 Oct 2026 10:22:10 +0200 Andy Shevchenko…
Quoted 2 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Quoted 8 lines

...

drivers/iio/proximity/isl29501.c static irqreturn_t isl29501_trigger_handler(int irq, void *p) · line 952

Quoted 3 lines
drivers/iio/proximity/isl29501.c +2 -1
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);  

I would leave it on a single line (83 characters only).

Tweaked.

I'm also not sure why this one doesn't mention it's local and on the stack so I added that to the commit message whilst applying.

Thanks

Jonathan

#25 lore raw

PATCH 13/39 iio: proximity: sx9500: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is on the stack and local to sx9500_trigger_handler().

---
 drivers/iio/proximity/sx9500.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/sx9500.c +2 -2
index cd67d88d2be4..a2709faa0106 100644
@@ -647,8 +647,8 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
 		scan.chan[i++] = val;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 
 out:
 	mutex_unlock(&data->mutex);
Signature · 1 line
2.43.0
#26 lore raw

PATCH 14/39 iio: imu: smi330: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Jianping Shen <[email protected]>

---
 drivers/iio/imu/smi330/smi330_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/imu/smi330/smi330_core.c +2 -1
index 7ec5ae7f521a..ef7f00825b4a 100644
@@ -628,7 +628,8 @@ static irqreturn_t smi330_trigger_handler(int irq, void *p)
 	if (ret)
 		goto out;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, data->buf, sizeof(data->buf),
+				    pf->timestamp);
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
#27 lore raw

PATCH 15/39 iio: imu: bmi270: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Jianping Shen <[email protected]>
Cc: Alex Lanzano <[email protected]>
Cc: Justin Weiss <[email protected]>

---
 drivers/iio/imu/bmi270/bmi270_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bmi270/bmi270_core.c +2 -2
index fbcf6bb87acc..83a9a96c3ca9 100644
@@ -851,8 +851,8 @@ static irqreturn_t bmi270_trigger_handler(int irq, void *p)
 	if (ret)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
+				    sizeof(data->buffer), pf->timestamp);
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 	return IRQ_HANDLED;
Signature · 1 line
2.43.0
maintainer
#28 lore raw

Re: [PATCH 15/39] iio: imu: bmi270: use iio_push_to_buffers_with_ts()

Quoted 2 lines · On Mon, 26 Oct 2026 16:05:33 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Applied patches 13-15. I think I'll stop there for now as the patches are getting more complex perhaps and should have more review time.

Also, beer o'clock ;)

J

Quoted 26 lines

---
Cc: Jianping Shen <[email protected]>
Cc: Alex Lanzano <[email protected]>
Cc: Justin Weiss <[email protected]>

---
 drivers/iio/imu/bmi270/bmi270_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bmi270/bmi270_core.c +2 -2
index fbcf6bb87acc..83a9a96c3ca9 100644
@@ -851,8 +851,8 @@ static irqreturn_t bmi270_trigger_handler(int irq, void *p)
 	if (ret)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
+				    sizeof(data->buffer), pf->timestamp);
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 	return IRQ_HANDLED;
#29 lore raw

PATCH 16/39 iio: imu: inv_icm42600: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Jean-Baptiste Maneyrol <[email protected]>

---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 3 ++-
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -1
index cc8c074777c9..d40300af9b3c 100644
@@ -1250,7 +1250,8 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;
 		ts_val = inv_sensors_timestamp_pop(ts);
-		iio_push_to_buffers_with_timestamp(indio_dev, &buffer, ts_val);
+		iio_push_to_buffers_with_ts(indio_dev, &buffer, sizeof(buffer),
+					    ts_val);
 	}
 
 	if (st->timestamp.accel_force_odr) {
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -1
index 4e20d61d897b..f895226f4a39 100644
@@ -829,7 +829,8 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;
 		ts_val = inv_sensors_timestamp_pop(ts);
-		iio_push_to_buffers_with_timestamp(indio_dev, &buffer, ts_val);
+		iio_push_to_buffers_with_ts(indio_dev, &buffer, sizeof(buffer),
+					    ts_val);
 	}
 
 	return 0;
Signature · 1 line
2.43.0
maintainer Applied
#30 lore raw

Re: [PATCH 16/39] iio: imu: inv_icm42600: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Mon, 26 Oct 2026 16:05:34 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Applied. This one is obviously fine as the buffer is right there on the stack in both cases.

Quoted 36 lines

---
Cc: Jean-Baptiste Maneyrol <[email protected]>

---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 3 ++-
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -1
index cc8c074777c9..d40300af9b3c 100644
@@ -1250,7 +1250,8 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;
 		ts_val = inv_sensors_timestamp_pop(ts);
-		iio_push_to_buffers_with_timestamp(indio_dev, &buffer, ts_val);
+		iio_push_to_buffers_with_ts(indio_dev, &buffer, sizeof(buffer),
+					    ts_val);
 	}
 
 	if (st->timestamp.accel_force_odr) {
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -1
index 4e20d61d897b..f895226f4a39 100644
@@ -829,7 +829,8 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;
 		ts_val = inv_sensors_timestamp_pop(ts);
-		iio_push_to_buffers_with_timestamp(indio_dev, &buffer, ts_val);
+		iio_push_to_buffers_with_ts(indio_dev, &buffer, sizeof(buffer),
+					    ts_val);
 	}
 
 	return 0;
#31 lore raw

PATCH 17/39 iio: health: afe4403: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct SPI/DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

---
Cc: Andrew F. Davis <[email protected]>

---
 drivers/iio/health/afe4403.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iio/health/afe4403.c +4 -6
index 2a648532242a..d35c00a2bafe 100644
@@ -64,7 +64,6 @@ static const struct reg_field afe4403_reg_fields[] = {
  * @regulator: Pointer to the regulator for the IC
  * @trig: IIO trigger for this device
  * @irq: ADC_RDY line interrupt number
- * @buffer: Used to construct data layout to push into IIO buffer.
  */
 struct afe4403_data {
 	struct spi_device *spi;
@@ -73,8 +72,6 @@ struct afe4403_data {
 	struct regulator *regulator;
 	struct iio_trigger *trig;
 	int irq;
-	/* Ensure suitable alignment for timestamp */
-	s32 buffer[8] __aligned(8);
 };
 
 enum afe4403_chan_id {
@@ -313,6 +310,7 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 	int ret, bit, i = 0;
 	u8 tx[4] = {AFE440X_CONTROL0, 0x0, 0x0, AFE440X_CONTROL0_READ};
 	u8 rx[3];
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 8) = { };
 
 	/* Enable reading from the device */
 	ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0);
@@ -326,7 +324,7 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 		if (ret)
 			goto err;
 
-		afe->buffer[i++] = get_unaligned_be24(&rx[0]);
+		scan[i++] = get_unaligned_be24(&rx[0]);
 	}
 
 	/* Disable reading from the device */
@@ -335,8 +333,8 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 	if (ret)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
 
Signature · 1 line
2.43.0
#32 lore raw

Re: [PATCH 17/39] iio: health: afe4403: use iio_push_to_buffers_with_ts()

Quoted 7 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct SPI/DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

...

drivers/iio/health/afe4403.c static irqreturn_t afe4403_trigger_handler(int irq, void *private) · line 313

Quoted 6 lines

static irqreturn_t afe4403_trigger_handler(int irq, void *private)

drivers/iio/health/afe4403.c +1 -0
 	int ret, bit, i = 0;
 	u8 tx[4] = {AFE440X_CONTROL0, 0x0, 0x0, AFE440X_CONTROL0_READ};
 	u8 rx[3];
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 8) = { };

I would move it a bit up, giving the visible context to be even before 'int ret...' line.

...

drivers/iio/health/afe4403.c static irqreturn_t afe4403_trigger_handler(int irq, void *private) · line 337

Quoted 4 lines
drivers/iio/health/afe4403.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);

One line of 82 characters is okay I believe.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#33 lore raw

Re: [PATCH 17/39] iio: health: afe4403: use iio_push_to_buffers_with_ts()

Quoted 21 lines · On Tue, 27 Oct 2026 10:25:09 +0200 Andy Shevchenko…
Quoted 7 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct SPI/DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

...

drivers/iio/health/afe4403.c static irqreturn_t afe4403_trigger_handler(int irq, void *private) · line 313

Quoted 6 lines

static irqreturn_t afe4403_trigger_handler(int irq, void *private)

drivers/iio/health/afe4403.c +1 -0
 	int ret, bit, i = 0;
 	u8 tx[4] = {AFE440X_CONTROL0, 0x0, 0x0, AFE440X_CONTROL0_READ};
 	u8 rx[3];
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 8) = { };  

I would move it a bit up, giving the visible context to be even before 'int ret...' line.

Quoted 9 lines

...

drivers/iio/health/afe4403.c static irqreturn_t afe4403_trigger_handler(int irq, void *private) · line 337

Quoted 4 lines
drivers/iio/health/afe4403.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);  

One line of 82 characters is okay I believe.

Both done and applied.

Thanks,

J

#34 lore raw

PATCH 18/39 iio: health: afe4404: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

---
Cc: Andrew F. Davis <[email protected]>

---
 drivers/iio/health/afe4404.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/iio/health/afe4404.c +4 -5
index 22cd46eca217..561b563c98d5 100644
@@ -82,7 +82,6 @@ static const struct reg_field afe4404_reg_fields[] = {
  * @regulator: Pointer to the regulator for the IC
  * @trig: IIO trigger for this device
  * @irq: ADC_RDY line interrupt number
- * @buffer: Used to construct a scan to push to the iio buffer.
  */
 struct afe4404_data {
 	struct regmap *regmap;
@@ -90,7 +89,6 @@ struct afe4404_data {
 	struct regulator *regulator;
 	struct iio_trigger *trig;
 	int irq;
-	s32 buffer[10] __aligned(8);
 };
 
 enum afe4404_chan_id {
@@ -330,16 +328,17 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct afe4404_data *afe = iio_priv(indio_dev);
 	int ret, bit, i = 0;
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 10) = { };
 
 	iio_for_each_active_channel(indio_dev, bit) {
 		ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
-				  &afe->buffer[i++]);
+				  &scan[i++]);
 		if (ret)
 			goto err;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
 
Signature · 1 line
2.43.0
#35 lore raw

Re: [PATCH 18/39] iio: health: afe4404: use iio_push_to_buffers_with_ts()

Quoted 7 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 331

Quoted 6 lines

static irqreturn_t afe4404_trigger_handler(int irq, void *private)

drivers/iio/health/afe4404.c +1 -0
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct afe4404_data *afe = iio_priv(indio_dev);
 	int ret, bit, i = 0;
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 10) = { };

Move it one line up.

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 335

Quoted 4 lines
drivers/iio/health/afe4404.c +1 -1
 	iio_for_each_active_channel(indio_dev, bit) {
 		ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
-				  &afe->buffer[i++]);
+				  &scan[i++]);

Also possible to have now

	struct regmap *map = afe->regmap;
	...
		ret = regmap_read(map, afe4404_channel_values[bit], &scan[i++]);

(which will have the same amount of LoC).

Quoted 3 lines
drivers/iio/health/afe4404.c +0 -0
 		if (ret)
 			goto err;
 	}

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 341

Quoted 4 lines
drivers/iio/health/afe4404.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);

One line?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#36 lore raw

Re: [PATCH 18/39] iio: health: afe4404: use iio_push_to_buffers_with_ts()

Quoted 39 lines · On Tue, 27 Oct 2026 10:27:23 +0200 Andy Shevchenko…
Quoted 7 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

The pushed buffer is never a direct DMA transfer target, so move it from the per-device state to the stack. Use IIO_DECLARE_BUFFER_WITH_TS() since the timestamp offset depends on the number of enabled channels, and zero initialize it.

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 331

Quoted 6 lines

static irqreturn_t afe4404_trigger_handler(int irq, void *private)

drivers/iio/health/afe4404.c +1 -0
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct afe4404_data *afe = iio_priv(indio_dev);
 	int ret, bit, i = 0;
+	IIO_DECLARE_BUFFER_WITH_TS(s32, scan, 10) = { };  

Move it one line up.

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 335

Quoted 4 lines
drivers/iio/health/afe4404.c +1 -1
 	iio_for_each_active_channel(indio_dev, bit) {
 		ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
-				  &afe->buffer[i++]);
+				  &scan[i++]);  

Also possible to have now

	struct regmap *map = afe->regmap;
	...
		ret = regmap_read(map, afe4404_channel_values[bit], &scan[i++]);

(which will have the same amount of LoC).

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 338

Quoted 3 lines
drivers/iio/health/afe4404.c +0 -0
 		if (ret)
 			goto err;
 	}  
Quoted 9 lines

...

drivers/iio/health/afe4404.c static irqreturn_t afe4404_trigger_handler(int irq, void *private) · line 341

Quoted 4 lines
drivers/iio/health/afe4404.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);  

One line?

All tweaks made and applied.

J

#37 lore raw

PATCH 19/39 iio: adc: ad799x: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to ad799x_trigger_handler(), and declare it via IIO_DECLARE_BUFFER_WITH_TS().

---
Cc: Archit Anant <[email protected]>
Cc: Stefano Manni <[email protected]>

---
 drivers/iio/adc/ad799x.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/iio/adc/ad799x.c +4 -5
index bb076d8f5dd5..2282535e21ea 100644
@@ -138,8 +138,6 @@ struct ad799x_state {
 	unsigned int			transfer_size;
 
 	int				vref_uV;
-
-	IIO_DECLARE_BUFFER_WITH_TS(__be16, rx_buf, AD799X_MAX_CHANNELS);
 };
 
 static int ad799x_write_config(struct ad799x_state *st, u16 val)
@@ -197,6 +195,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad799x_state *st = iio_priv(indio_dev);
+	IIO_DECLARE_BUFFER_WITH_TS(__be16, rx_buf, AD799X_MAX_CHANNELS) = { };
 	int b_sent;
 	u8 cmd;
 
@@ -223,12 +222,12 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
 
 	b_sent = i2c_smbus_read_i2c_block_data(st->client,
 						cmd, st->transfer_size,
-						(u8 *)st->rx_buf);
+						(u8 *)rx_buf);
 	if (b_sent < 0)
 		goto out;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
-			iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, rx_buf, sizeof(rx_buf),
+				    iio_get_time_ns(indio_dev));
 out:
 	iio_trigger_notify_done(indio_dev->trig);
 
Signature · 1 line
2.43.0
#38 lore raw

Re: [PATCH 19/39] iio: adc: ad799x: use iio_push_to_buffers_with_ts()

Quoted 5 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to ad799x_trigger_handler(), and declare it via IIO_DECLARE_BUFFER_WITH_TS().

...

drivers/iio/adc/ad799x.c static irqreturn_t ad799x_trigger_handler(int irq, void *p) · line 225

Quoted 4 lines
drivers/iio/adc/ad799x.c +1 -1
 	b_sent = i2c_smbus_read_i2c_block_data(st->client,
 						cmd, st->transfer_size,
-						(u8 *)st->rx_buf);
+						(u8 *)rx_buf);

Indentation is broken (even in the original code). I would reformat as

	b_sent = i2c_smbus_read_i2c_block_data(st->client,
					       cmd, st->transfer_size,
					       (u8 *)rx_buf);

(yes, it's possible to move cmd up, but for the sake of less intrusiveness and
better reading the changes fixing indentation just good enough).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#39 lore raw

Re: [PATCH 19/39] iio: adc: ad799x: use iio_push_to_buffers_with_ts()

Quoted 16 lines · On Tue, 27 Oct 2026 10:29:57 +0200 Andy Shevchenko…
Quoted 5 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to ad799x_trigger_handler(), and declare it via IIO_DECLARE_BUFFER_WITH_TS().

...

drivers/iio/adc/ad799x.c static irqreturn_t ad799x_trigger_handler(int irq, void *p) · line 225

Quoted 4 lines
drivers/iio/adc/ad799x.c +1 -1
 	b_sent = i2c_smbus_read_i2c_block_data(st->client,
 						cmd, st->transfer_size,
-						(u8 *)st->rx_buf);
+						(u8 *)rx_buf);  

Indentation is broken (even in the original code). I would reformat as

Quoted 7 lines
	b_sent = i2c_smbus_read_i2c_block_data(st->client,
					       cmd, st->transfer_size,
					       (u8 *)rx_buf);

(yes, it's possible to move cmd up, but for the sake of less intrusiveness and
better reading the changes fixing indentation just good enough).

Tweaked and applied.
Thanks,
J

#40 lore raw

PATCH 20/39 iio: common: scmi_sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Replace the manually sized iio_buf array with IIO_DECLARE_BUFFER_WITH_TS() so that the timestamp space and alignment are handled consistently with other drivers.

---
Cc: Jyoti Bhayana <[email protected]>

---
 drivers/iio/common/scmi_sensors/scmi_iio.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/common/scmi_sensors/scmi_iio.c +3 -4
index 442b40ef27cf..f488dda0e386 100644
@@ -30,8 +30,7 @@ struct scmi_iio_priv {
 	struct iio_dev *indio_dev;
 	/* lock to protect against multiple access to the device */
 	struct mutex lock;
-	/* adding one additional channel for timestamp */
-	s64 iio_buf[SCMI_IIO_NUM_OF_AXIS + 1];
+	IIO_DECLARE_BUFFER_WITH_TS(s64, iio_buf, SCMI_IIO_NUM_OF_AXIS);
 	struct notifier_block sensor_update_nb;
 	u32 *freq_avail;
 };
@@ -78,8 +77,8 @@ static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
 	}
 
 	scmi_iio_dev = sensor->indio_dev;
-	iio_push_to_buffers_with_timestamp(scmi_iio_dev, sensor->iio_buf,
-					   time_ns);
+	iio_push_to_buffers_with_ts(scmi_iio_dev, sensor->iio_buf,
+				    sizeof(sensor->iio_buf), time_ns);
 	return NOTIFY_OK;
 }
 
Signature · 1 line
2.43.0
maintainer Applied
#41 lore raw

Re: [PATCH 20/39] iio: common: scmi_sensors: use iio_push_to_buffers_with_ts()

Quoted 10 lines · On Mon, 26 Oct 2026 16:05:38 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Replace the manually sized iio_buf array with IIO_DECLARE_BUFFER_WITH_TS() so that the timestamp space and alignment are handled consistently with other drivers.

---
Cc: Jyoti Bhayana <[email protected]>

Applied,

#42 lore raw

PATCH 21/39 iio: adc: ad7766: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts().

Replace the data buffer with one declared via
IIO_DECLARE_DMA_BUFFER_WITH_TS().

---
Cc: Sebastian Andrzej Siewior <[email protected]>

---
 drivers/iio/adc/ad7766.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/iio/adc/ad7766.c +4 -10
index 92957196de59..2afb466cf911 100644
@@ -44,13 +44,7 @@ struct ad7766 {
 	struct spi_transfer xfer;
 	struct spi_message msg;
 
-	/*
-	 * DMA (thus cache coherency maintenance) may require the
-	 * transfer buffers to live in their own cache lines.
-	 * Make the buffer large enough for one 24 bit sample and one 64 bit
-	 * aligned 64 bit timestamp.
-	 */
-	unsigned char data[ALIGN(3, sizeof(s64)) + sizeof(s64)]	__aligned(IIO_DMA_MINALIGN);
+	IIO_DECLARE_DMA_BUFFER_WITH_TS(s32, data, 1);
 };
 
 /*
@@ -74,8 +68,8 @@ static irqreturn_t ad7766_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, ad7766->data,
-		pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, ad7766->data,
+				    sizeof(ad7766->data), pf->timestamp);
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 
@@ -269,7 +263,7 @@ static int ad7766_probe(struct spi_device *spi)
 	ad7766->spi = spi;
 
 	/* First byte always 0 */
-	ad7766->xfer.rx_buf = &ad7766->data[1];
+	ad7766->xfer.rx_buf = (u8 *)ad7766->data + 1;
 	ad7766->xfer.len = 3;
 
 	spi_message_init(&ad7766->msg);
Signature · 1 line
2.43.0
maintainer Applied
#43 lore raw

Re: [PATCH 21/39] iio: adc: ad7766: use iio_push_to_buffers_with_ts()

Quoted 10 lines · On Mon, 26 Oct 2026 16:05:39 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts().

Replace the data buffer with one declared via
IIO_DECLARE_DMA_BUFFER_WITH_TS().

---
Cc: Sebastian Andrzej Siewior <[email protected]>

Applied.

#44 lore raw

PATCH 22/39 iio: imu: smi240: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to smi240_trigger_handler(), and declare it via IIO_DECLARE_BUFFER_WITH_TS().

---
Cc: Shen Jianping <[email protected]>

---
 drivers/iio/imu/smi240.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/iio/imu/smi240.c +3 -10
index f419296bba88..a9d9600be30c 100644
@@ -111,14 +111,6 @@ struct smi240_data {
 	u16 anglvel_filter_freq;
 	u8 built_in_self_test_count;
 	enum capture_mode capture;
-	/*
-	 * Ensure natural alignment for timestamp if present.
-	 * Channel size: 2 bytes.
-	 * Max length needed: 2 * 3 channels + temp channel + 2 bytes padding + 8 byte ts.
-	 * If fewer channels are enabled, less space may be needed, as
-	 * long as the timestamp is still aligned to 8 bytes.
-	 */
-	s16 buf[12] __aligned(8);
 
 	__be32 spi_buf __aligned(IIO_DMA_MINALIGN);
 };
@@ -370,6 +362,7 @@ static irqreturn_t smi240_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct smi240_data *data = iio_priv(indio_dev);
+	IIO_DECLARE_BUFFER_WITH_TS(s16, buf, SMI240_SCAN_GYRO_Z + 1) = { };
 	int base = SMI240_DATA_CAP_FIRST_REG, i = 0;
 	int ret, chan, sample;
 
@@ -380,10 +373,10 @@ static irqreturn_t smi240_trigger_handler(int irq, void *p)
 		data->capture = SMI240_CAPTURE_OFF;
 		if (ret)
 			goto out;
-		data->buf[i++] = sample;
+		buf[i++] = sample;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, buf, sizeof(buf), pf->timestamp);
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
maintainer Applied
#45 lore raw

Re: [PATCH 22/39] iio: imu: smi240: use iio_push_to_buffers_with_ts()

Quoted 9 lines · On Mon, 26 Oct 2026 16:05:40 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to smi240_trigger_handler(), and declare it via IIO_DECLARE_BUFFER_WITH_TS().

---
Cc: Shen Jianping <[email protected]>

Applied.

#46 lore raw

PATCH 23/39 iio: adc: cc10001_adc: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to cc10001_adc_trigger_h(), and declare it via IIO_DECLARE_BUFFER_WITH_TS(), removing the now unneeded update_scan_mode() callback.

---
 drivers/iio/adc/cc10001_adc.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/iio/adc/cc10001_adc.c +3 -19
index d42b747325aa..c7ea718305a2 100644
@@ -55,7 +55,6 @@ struct cc10001_adc_device {
 	void __iomem *reg_base;
 	struct clk *adc_clk;
 	struct regulator *reg;
-	u16 *buf;
 
 	bool shared;
 	struct mutex lock;
@@ -140,12 +139,11 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
 	unsigned int channel;
 	unsigned int scan_idx;
 	bool sample_invalid;
-	u16 *data;
+	IIO_DECLARE_BUFFER_WITH_TS(u16, data, CC10001_ADC_NUM_CHANNELS) = { };
 	int i;
 
 	indio_dev = pf->indio_dev;
 	adc_dev = iio_priv(indio_dev);
-	data = adc_dev->buf;
 
 	mutex_lock(&adc_dev->lock);
 
@@ -178,8 +176,8 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
 	mutex_unlock(&adc_dev->lock);
 
 	if (!sample_invalid)
-		iio_push_to_buffers_with_timestamp(indio_dev, data,
-						   iio_get_time_ns(indio_dev));
+		iio_push_to_buffers_with_ts(indio_dev, data, sizeof(data),
+					    iio_get_time_ns(indio_dev));
 	iio_trigger_notify_done(indio_dev->trig);
 
 	return IRQ_HANDLED;
@@ -241,22 +239,8 @@ static int cc10001_adc_read_raw(struct iio_dev *indio_dev,
 	}
 }
 
-static int cc10001_update_scan_mode(struct iio_dev *indio_dev,
-				    const unsigned long *scan_mask)
-{
-	struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
-
-	kfree(adc_dev->buf);
-	adc_dev->buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
-	if (!adc_dev->buf)
-		return -ENOMEM;
-
-	return 0;
-}
-
 static const struct iio_info cc10001_adc_info = {
 	.read_raw = &cc10001_adc_read_raw,
-	.update_scan_mode = &cc10001_update_scan_mode,
 };
 
 static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
Signature · 1 line
2.43.0
#47 lore raw

Re: [PATCH 23/39] iio: adc: cc10001_adc: use iio_push_to_buffers_with_ts()

Quoted 6 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to cc10001_adc_trigger_h(), and declare it via IIO_DECLARE_BUFFER_WITH_TS(), removing the now unneeded update_scan_mode() callback.

...

drivers/iio/adc/cc10001_adc.c static irqreturn_t cc10001_adc_trigger_h(int irq, void *p) · line 142

Quoted 7 lines

static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)

drivers/iio/adc/cc10001_adc.c +1 -1
 	unsigned int channel;
 	unsigned int scan_idx;
 	bool sample_invalid;
-	u16 *data;
+	IIO_DECLARE_BUFFER_WITH_TS(u16, data, CC10001_ADC_NUM_CHANNELS) = { };

Move it up?

Quoted 1 line

int i;

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#48 lore raw

Re: [PATCH 23/39] iio: adc: cc10001_adc: use iio_push_to_buffers_with_ts()

Quoted 12 lines · On Tue, 27 Oct 2026 10:32:22 +0200 Andy Shevchenko…
Quoted 6 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to cc10001_adc_trigger_h(), and declare it via IIO_DECLARE_BUFFER_WITH_TS(), removing the now unneeded update_scan_mode() callback.

...

Quoted 1 line

static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)

Quoted 7 lines

drivers/iio/adc/cc10001_adc.c static irqreturn_t cc10001_adc_trigger_h(int irq, void *p) · line 142

Quoted 5 lines
drivers/iio/adc/cc10001_adc.c +1 -1
 	unsigned int channel;
 	unsigned int scan_idx;
 	bool sample_invalid;
-	u16 *data;
+	IIO_DECLARE_BUFFER_WITH_TS(u16, data, CC10001_ADC_NUM_CHANNELS) = { };  

Move it up?

Tweaked whilst applying

Thanks,

Jonathan

Quoted 3 lines
Quoted 2 lines

int i;

#49 lore raw

PATCH 24/39 iio: adc: hx711: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to hx711_trigger().

---
Cc: Piyush Patle <[email protected]>

---
 drivers/iio/adc/hx711.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/iio/adc/hx711.c +7 -14
index 00adafa7cbd7..7eb089215f1e 100644
@@ -100,14 +100,6 @@ struct hx711_data {
 	int			gain_scale[HX711_GAIN_MAX];
 	const struct hx711_chip_info	*chip_info;
 	struct mutex		lock;
-	/*
-	 * triggered buffer
-	 * 2x32-bit channel + 64-bit naturally aligned timestamp
-	 */
-	struct {
-		u32 channel[2];
-		aligned_s64 timestamp;
-	} buffer;
 	/*
 	 * delay after a rising edge on SCK until the data is ready DOUT
 	 * this is dependent on the hx711 where the datasheet tells a
@@ -397,20 +389,21 @@ static irqreturn_t hx711_trigger(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct hx711_data *hx711_data = iio_priv(indio_dev);
+	struct {
+		u32 channel[2];
+		aligned_s64 timestamp;
+	} scan = { };
 	int i, j = 0;
 
 	mutex_lock(&hx711_data->lock);
 
-	memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer));
-
 	iio_for_each_active_channel(indio_dev, i) {
-		hx711_data->buffer.channel[j] =
-			hx711_reset_read(hx711_data, &indio_dev->channels[i]);
+		scan.channel[j] = hx711_reset_read(hx711_data, &indio_dev->channels[i]);
 		j++;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
-							pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);
 
 	mutex_unlock(&hx711_data->lock);
 
Signature · 1 line
2.43.0
#50 lore raw

Re: [PATCH 24/39] iio: adc: hx711: use iio_push_to_buffers_with_ts()

Quoted 4 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to hx711_trigger().

...

drivers/iio/adc/hx711.c static irqreturn_t hx711_trigger(int irq, void *p) · line 406

Quoted 4 lines
drivers/iio/adc/hx711.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
-							pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);

One line?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#51 lore raw

Re: [PATCH 24/39] iio: adc: hx711: use iio_push_to_buffers_with_ts()

Quoted 6 lines · On Tue, 27 Oct 2026 10:33:47 +0200 Andy Shevchenko…
Quoted 4 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the buffer onto the stack, local to hx711_trigger().

Quoted 9 lines

...

drivers/iio/adc/hx711.c static irqreturn_t hx711_trigger(int irq, void *p) · line 406

Quoted 4 lines
drivers/iio/adc/hx711.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
-							pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);  

One line?

Tweaked and applied.

#52 lore raw

PATCH 25/39 iio: potentiostat: lmp91000: use iio_push_to_buffers_with_ts() with a scan struct on stack

In reply to Jonathan Cameron

Move the scan buffer out of struct lmp91000_data and make it local to lmp91000_buffer_handler(), as it has no need to persist between calls.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
 drivers/iio/potentiostat/lmp91000.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/iio/potentiostat/lmp91000.c +8 -7
index 00cb3fea97ca..53f181cbc0b8 100644
@@ -70,8 +70,7 @@ struct lmp91000_data {
 
 	struct completion completion;
 	u8 chan_select;
-	/* 64-bit data + 64-bit naturally aligned timestamp */
-	u32 buffer[4] __aligned(8);
+	u32 buffer[2];
 };
 
 static const struct iio_chan_spec lmp91000_channels[] = {
@@ -135,15 +134,17 @@ static irqreturn_t lmp91000_buffer_handler(int irq, void *private)
 	struct iio_poll_func *pf = private;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct lmp91000_data *data = iio_priv(indio_dev);
+	struct {
+		s32 chan;
+		aligned_s64 ts;
+	} scan = { };
 	int ret, val;
 
-	memset(data->buffer, 0, sizeof(data->buffer));
-
 	ret = lmp91000_read(data, LMP91000_REG_MODECN_3LEAD, &val);
 	if (!ret) {
-		data->buffer[0] = val;
-		iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-						   iio_get_time_ns(indio_dev));
+		scan.chan = val;
+		iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+					    iio_get_time_ns(indio_dev));
 	}
 
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
author Applied
#53 lore raw

Re: [PATCH 25/39] iio: potentiostat: lmp91000: use iio_push_to_buffers_with_ts() with a scan struct on stack

Quoted 7 lines · On Mon, 26 Oct 2026 16:05:43 -0700 Jonathan Cameron…

Move the scan buffer out of struct lmp91000_data and make it local to lmp91000_buffer_handler(), as it has no need to persist between calls.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Applied.

Quoted 42 lines
---
 drivers/iio/potentiostat/lmp91000.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/iio/potentiostat/lmp91000.c +8 -7
index 00cb3fea97ca..53f181cbc0b8 100644
@@ -70,8 +70,7 @@ struct lmp91000_data {
 
 	struct completion completion;
 	u8 chan_select;
-	/* 64-bit data + 64-bit naturally aligned timestamp */
-	u32 buffer[4] __aligned(8);
+	u32 buffer[2];
 };
 
 static const struct iio_chan_spec lmp91000_channels[] = {
@@ -135,15 +134,17 @@ static irqreturn_t lmp91000_buffer_handler(int irq, void *private)
 	struct iio_poll_func *pf = private;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct lmp91000_data *data = iio_priv(indio_dev);
+	struct {
+		s32 chan;
+		aligned_s64 ts;
+	} scan = { };
 	int ret, val;
 
-	memset(data->buffer, 0, sizeof(data->buffer));
-
 	ret = lmp91000_read(data, LMP91000_REG_MODECN_3LEAD, &val);
 	if (!ret) {
-		data->buffer[0] = val;
-		iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-						   iio_get_time_ns(indio_dev));
+		scan.chan = val;
+		iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+					    iio_get_time_ns(indio_dev));
 	}
 
 	iio_trigger_notify_done(indio_dev->trig);
#54 lore raw

PATCH 26/39 iio: humidity: am2315: use iio_push_to_buffers_with_ts() with a scan struct on stack

In reply to Jonathan Cameron

Move the scan buffer out of struct am2315_data and make it local to am2315_trigger_handler(), as it has no need to persist between calls. This also removes the need to hold data->lock while filling it in.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Nicolás Antinori <[email protected]>

---
 drivers/iio/humidity/am2315.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/iio/humidity/am2315.c +10 -13
index 5c7582f3a4f9..1182b084fa84 100644
@@ -42,11 +42,6 @@ static const struct am2315_chip_info am2320_chip_info = {
 struct am2315_data {
 	struct i2c_client *client;
 	struct mutex lock;
-	/* Ensure timestamp is naturally aligned */
-	struct {
-		s16 chans[2];
-		aligned_s64 timestamp;
-	} scan;
 };
 
 struct am2315_sensor_data {
@@ -173,27 +168,29 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct am2315_data *data = iio_priv(indio_dev);
 	struct am2315_sensor_data sensor_data;
+	struct {
+		s16 chans[2];
+		aligned_s64 timestamp;
+	} scan = { };
 
 	ret = am2315_read_data(data, &sensor_data);
 	if (ret < 0)
 		goto err;
 
-	mutex_lock(&data->lock);
 	if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) {
-		data->scan.chans[0] = sensor_data.hum_data;
-		data->scan.chans[1] = sensor_data.temp_data;
+		scan.chans[0] = sensor_data.hum_data;
+		scan.chans[1] = sensor_data.temp_data;
 	} else {
 		i = 0;
 		iio_for_each_active_channel(indio_dev, bit) {
-			data->scan.chans[i] = (bit ? sensor_data.temp_data :
-					       sensor_data.hum_data);
+			scan.chans[i] = (bit ? sensor_data.temp_data :
+					sensor_data.hum_data);
 			i++;
 		}
 	}
-	mutex_unlock(&data->lock);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
 	return IRQ_HANDLED;
Signature · 1 line
2.43.0
#55 lore raw

Re: [PATCH 26/39] iio: humidity: am2315: use iio_push_to_buffers_with_ts() with a scan struct on stack

Quoted 6 lines · Jonathan Cameron

Move the scan buffer out of struct am2315_data and make it local to am2315_trigger_handler(), as it has no need to persist between calls. This also removes the need to hold data->lock while filling it in.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

...

drivers/iio/humidity/am2315.c static irqreturn_t am2315_trigger_handler(int irq, void *p) · line 187

Quoted 6 lines
drivers/iio/humidity/am2315.c +2 -2
 		i = 0;
 		iio_for_each_active_channel(indio_dev, bit) {
-			data->scan.chans[i] = (bit ? sensor_data.temp_data :
-					       sensor_data.hum_data);
+			scan.chans[i] = (bit ? sensor_data.temp_data :
+					sensor_data.hum_data);

You can drop redundant parentheses.

Quoted 2 lines
(quoted diff) +0 -0
 			i++;
 		}

...

drivers/iio/humidity/am2315.c static irqreturn_t am2315_trigger_handler(int irq, void *p) · line 193

Quoted 4 lines
drivers/iio/humidity/am2315.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    pf->timestamp);

One line?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Tested-by on v1 26/39
#56 lore raw

Re: [PATCH 26/39] iio: humidity: am2315: use iio_push_to_buffers_with_ts() with a scan struct on stack

In reply to Jonathan Cameron
Quoted 8 lines · Jonathan Cameron

Move the scan buffer out of struct am2315_data and make it local to am2315_trigger_handler(), as it has no need to persist between calls. This also removes the need to hold data->lock while filling it in.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Hi! I tested this on an AM2320 sensor in a Raspberry Pi 3b+.

Kernel version:
Linux version 7.3.0-rc1-v8+
Debian clang version 19.1.7 (3+b1), Debian LLD 19.1.7

Everything looks good (no warning or errors). This is the first time I test a patch, I'll add the Tested-by tag, but please tell me if I am doing something wrong.

maintainer Applied
#57 lore raw

Re: [PATCH 26/39] iio: humidity: am2315: use iio_push_to_buffers_with_ts() with a scan struct on stack

Quoted 16 lines · On Tue, 27 Oct 2026 13:13:13 -0300 Nicolás Antinori…
Quoted 8 lines · Jonathan Cameron

Move the scan buffer out of struct am2315_data and make it local to am2315_trigger_handler(), as it has no need to persist between calls. This also removes the need to hold data->lock while filling it in.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Hi! I tested this on an AM2320 sensor in a Raspberry Pi 3b+.

Kernel version:
Linux version 7.3.0-rc1-v8+
Debian clang version 19.1.7 (3+b1), Debian LLD 19.1.7

Quoted 6 lines

Everything looks good (no warning or errors). This is the first time I test a patch, I'll add the Tested-by tag, but please tell me if I am doing something wrong.

Thanks!

Applied

J

#58 lore raw

PATCH 27/39 iio: humidity: hdc100x: use iio_push_to_buffers_with_ts() with a scan struct on stack

In reply to Jonathan Cameron

Move the scan buffer out of struct hdc100x_data and make it local to hdc100x_trigger_handler(), as it has no need to persist between calls. i2c_master_recv() does not require a DMA safe buffer, so this is fine on the stack.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
 drivers/iio/humidity/hdc100x.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/iio/humidity/hdc100x.c +7 -8
index 9f07101d37f7..e045d340e18d 100644
@@ -41,11 +41,6 @@ struct hdc100x_data {
 
 	/* integration time of the sensor */
 	int adc_int_us[2];
-	/* Ensure natural alignment of timestamp */
-	struct {
-		__be16 channels[2];
-		aligned_s64 ts;
-	} scan;
 };
 
 /* integration time in us */
@@ -302,6 +297,10 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	struct hdc100x_data *data = iio_priv(indio_dev);
 	struct i2c_client *client = data->client;
 	int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2*USEC_PER_MSEC;
+	struct {
+		__be16 channels[2];
+		aligned_s64 ts;
+	} scan = { };
 	int ret;
 
 	/* dual read starts at temp register */
@@ -313,14 +312,14 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	}
 	usleep_range(delay, delay + 1000);
 
-	ret = i2c_master_recv(client, (u8 *)data->scan.channels, 4);
+	ret = i2c_master_recv(client, (u8 *)scan.channels, 4);
 	if (ret < 0) {
 		dev_err(&client->dev, "cannot read sensor data\n");
 		goto err;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+				    iio_get_time_ns(indio_dev));
 err:
 	mutex_unlock(&data->lock);
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
maintainer Applied
#59 lore raw

Re: [PATCH 27/39] iio: humidity: hdc100x: use iio_push_to_buffers_with_ts() with a scan struct on stack

Quoted 9 lines · On Mon, 26 Oct 2026 16:05:45 -0700 Jonathan Cameron…

Move the scan buffer out of struct hdc100x_data and make it local to hdc100x_trigger_handler(), as it has no need to persist between calls. i2c_master_recv() does not require a DMA safe buffer, so this is fine on the stack.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Applied.

#60 lore raw

PATCH 28/39 iio: imu: bmi323: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Also replace the two for_each_set_bit() loops over indio_dev->active_scan_mask with the equivalent iio_for_each_active_channel() helper and remove local variable that did not help readability.

---
 drivers/iio/imu/bmi323/bmi323_core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/iio/imu/bmi323/bmi323_core.c +9 -11
index ebeb1b10c38c..f1baf7304533 100644
@@ -1069,7 +1069,7 @@ static int __bmi323_fifo_flush(struct iio_dev *indio_dev)
 {
 	struct bmi323_data *data = iio_priv(indio_dev);
 	int i, ret, fifo_lvl, frame_count, bit, index;
-	__le16 *frame, *pchannels;
+	__le16 *frame;
 	u64 sample_period;
 	s64 tstamp;
 
@@ -1108,15 +1108,13 @@ static int __bmi323_fifo_flush(struct iio_dev *indio_dev)
 
 	for (i = 0; i < frame_count; i++) {
 		frame = &data->fifo_buff[i * BMI323_FIFO_FRAME_LENGTH];
-		pchannels = &data->buffer.channels[0];
 
 		index = 0;
-		for_each_set_bit(bit, indio_dev->active_scan_mask,
-				 BMI323_CHAN_MAX)
-			pchannels[index++] = frame[bit];
+		iio_for_each_active_channel(indio_dev, bit)
+			data->buffer.channels[index++] = frame[bit];
 
-		iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
-						   tstamp);
+		iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
+					    sizeof(data->buffer), tstamp);
 
 		tstamp += sample_period;
 	}
@@ -1425,8 +1423,7 @@ static irqreturn_t bmi323_trigger_handler(int irq, void *p)
 		if (ret)
 			goto out;
 	} else {
-		for_each_set_bit(bit, indio_dev->active_scan_mask,
-				 BMI323_CHAN_MAX) {
+		iio_for_each_active_channel(indio_dev, bit) {
 			ret = regmap_raw_read(data->regmap,
 					      BMI323_ACCEL_X_REG + bit,
 					      &data->buffer.channels[index++],
@@ -1436,8 +1433,9 @@ static irqreturn_t bmi323_trigger_handler(int irq, void *p)
 		}
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
+				    sizeof(data->buffer),
+				    iio_get_time_ns(indio_dev));
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 1 line
2.43.0
maintainer Applied
#61 lore raw

Re: [PATCH 28/39] iio: imu: bmi323: use iio_push_to_buffers_with_ts()

Quoted 9 lines · On Mon, 26 Oct 2026 16:05:46 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Also replace the two for_each_set_bit() loops over indio_dev->active_scan_mask with the equivalent iio_for_each_active_channel() helper and remove local variable that did not help readability.

Applied.

#62 lore raw

PATCH 29/39 iio: gyro: fxas21002c: restrict available_scan_masks to all angular velocity channels

In reply to Jonathan Cameron

fxas21002c_trigger_handler() always performs a single bulk read of all three angular velocity channels, regardless of which channels are actually enabled in indio_dev->active_scan_mask. Restrict available_scan_masks to the one valid combination of all three channels, so the IIO core demux can provide to buffer consumers only the channels they actually requested.

Fixes a0701b6263ae ("iio: gyro: add core driver for fxas21002c")
---
 drivers/iio/gyro/fxas21002c_core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/iio/gyro/fxas21002c_core.c +6 -0
index a88670207cec..6ef3ba2bd1f8 100644
@@ -714,6 +714,11 @@ static const struct iio_chan_spec fxas21002c_channels[] = {
 	FXAS21002C_CHANNEL(Z),
 };
 
+static const unsigned long fxas21002c_scan_masks[] = {
+	BIT(CHANNEL_SCAN_INDEX_X) | BIT(CHANNEL_SCAN_INDEX_Y) | BIT(CHANNEL_SCAN_INDEX_Z),
+	0
+};
+
 static const struct iio_info fxas21002c_info = {
 	.attrs			= &fxas21002c_attrs_group,
 	.read_raw		= &fxas21002c_read_raw,
@@ -969,6 +974,7 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq,
 
 	indio_dev->channels = fxas21002c_channels;
 	indio_dev->num_channels = ARRAY_SIZE(fxas21002c_channels);
+	indio_dev->available_scan_masks = fxas21002c_scan_masks;
 	indio_dev->name = name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &fxas21002c_info;
Signature · 1 line
2.43.0
#63 lore raw

PATCH 30/39 iio: gyro: fxas21002c: use iio_push_to_buffers_with_ts() with explicit structure

In reply to Jonathan Cameron

Replace the s16 buffer[8] with a struct containing the 3 channels followed by an aligned_s64 timestamp, named scan.

Correct the channel array type to __be16 to match the declared scan_type.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

---
 drivers/iio/gyro/fxas21002c_core.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/iio/gyro/fxas21002c_core.c +14 -11
index 6ef3ba2bd1f8..82379cd55b3f 100644
@@ -134,6 +134,13 @@ static const int fxas21002c_range_values[] = {
 	4000, 2000, 1000, 500, 250
 };
 
+enum fxas21002c_channel_index {
+	CHANNEL_SCAN_INDEX_X,
+	CHANNEL_SCAN_INDEX_Y,
+	CHANNEL_SCAN_INDEX_Z,
+	CHANNEL_SCAN_MAX
+};
+
 struct fxas21002c_data {
 	u8 chip_id;
 	enum fxas21002c_mode_state mode;
@@ -153,14 +160,10 @@ struct fxas21002c_data {
 	 * DMA (thus cache coherency maintenance) may require the
 	 * transfer buffers live in their own cache lines.
 	 */
-	s16 buffer[8] __aligned(IIO_DMA_MINALIGN);
-};
-
-enum fxas21002c_channel_index {
-	CHANNEL_SCAN_INDEX_X,
-	CHANNEL_SCAN_INDEX_Y,
-	CHANNEL_SCAN_INDEX_Z,
-	CHANNEL_SCAN_MAX,
+	struct {
+		__be16 chans[CHANNEL_SCAN_MAX];
+		aligned_s64 ts;
+	} scan __aligned(IIO_DMA_MINALIGN);
 };
 
 static int fxas21002c_odr_hz_from_value(struct fxas21002c_data *data, u8 value)
@@ -738,12 +741,12 @@ static irqreturn_t fxas21002c_trigger_handler(int irq, void *p)
 		goto out_unlock;
 
 	ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
-			       data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
+			       data->scan.chans, sizeof(data->scan.chans));
 	if (ret < 0)
 		goto out_pm_put;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-					   data->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &data->scan,
+				    sizeof(data->scan), data->timestamp);
 
 out_pm_put:
 	fxas21002c_pm_put(data);
Signature · 1 line
2.43.0
maintainer
#64 lore raw

Re: [PATCH 30/39] iio: gyro: fxas21002c: use iio_push_to_buffers_with_ts() with explicit structure

Quoted 11 lines · On Mon, 26 Oct 2026 16:05:48 -0700 Jonathan Cameron…

Replace the s16 buffer[8] with a struct containing the 3 channels followed by an aligned_s64 timestamp, named scan.

Correct the channel array type to __be16 to match the declared scan_type.

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

Applied 29 and 30. Some fuzz due to crossing with Brian's runtime pm work. Just line number changes so should be clean.

Thanks,

Jonathan

#65 lore raw

PATCH 31/39 iio: adc: ad7887: ensure tx_cmd_buf is DMA safe

In reply to Jonathan Cameron

SPI transfers require DMA safe buffers. Mark tx_cmd_buf with __aligned(IIO_DMA_MINALIGN) to ensure it does not share a cache line with other data.

tx_cmd_buf could share a cacheline with data, but the next patch will obscure that a little so separate marking used for readability purposes.

---
 drivers/iio/adc/ad7887.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7887.c +1 -1
index 62aaedbce748..b1d9da19e7a2 100644
@@ -63,7 +63,7 @@ struct ad7887_state {
 	struct spi_transfer		xfer[4];
 	struct spi_message		msg[3];
 	struct spi_message		*ring_msg;
-	unsigned char			tx_cmd_buf[4];
+	unsigned char			tx_cmd_buf[4] __aligned(IIO_DMA_MINALIGN);
 
 	/*
 	 * DMA (thus cache coherency maintenance) may require the
Signature · 1 line
2.43.0
maintainer Applied
#66 lore raw

Re: [PATCH 31/39] iio: adc: ad7887: ensure tx_cmd_buf is DMA safe

Quoted 9 lines · On Mon, 26 Oct 2026 16:05:49 -0700 Jonathan Cameron…

SPI transfers require DMA safe buffers. Mark tx_cmd_buf with __aligned(IIO_DMA_MINALIGN) to ensure it does not share a cache line with other data.

tx_cmd_buf could share a cacheline with data, but the next patch will obscure that a little so separate marking used for readability purposes.

Applied.

Quoted 18 lines
---
 drivers/iio/adc/ad7887.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7887.c +1 -1
index 62aaedbce748..b1d9da19e7a2 100644
@@ -63,7 +63,7 @@ struct ad7887_state {
 	struct spi_transfer		xfer[4];
 	struct spi_message		msg[3];
 	struct spi_message		*ring_msg;
-	unsigned char			tx_cmd_buf[4];
+	unsigned char			tx_cmd_buf[4] __aligned(IIO_DMA_MINALIGN);
 
 	/*
 	 * DMA (thus cache coherency maintenance) may require the
#67 lore raw

PATCH 32/39 iio: adc: ad7887: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

Replace the data buffer with one declared via IIO_DECLARE_DMA_BUFFER_WITH_TS(), for 2 __be16 channels.

Use be16_to_cpu() to replace the opencoded equivalent.

---
Note that the LLM I ran over this patch is unhappy with the data placement in the pdata path in here.

I have little idea how this is supposed to work and obviously don't really care about pdata. Would be good if someone who has a device could take a look at this and clean it up in general.

Otherwise I might just rip out the pdata path in the near future. This patch being an example of how it is causing maintenance burden.

---
 drivers/iio/adc/ad7887.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/iio/adc/ad7887.c +6 -12
index b1d9da19e7a2..dd1464add06a 100644
@@ -65,13 +65,7 @@ struct ad7887_state {
 	struct spi_message		*ring_msg;
 	unsigned char			tx_cmd_buf[4] __aligned(IIO_DMA_MINALIGN);
 
-	/*
-	 * DMA (thus cache coherency maintenance) may require the
-	 * transfer buffers to live in their own cache lines.
-	 * Buffer needs to be large enough to hold two 16 bit samples and a
-	 * 64 bit aligned 64 bit timestamp.
-	 */
-	unsigned char data[ALIGN(4, sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN);
+	IIO_DECLARE_DMA_BUFFER_WITH_TS(__be16, data, 2);
 };
 
 enum ad7887_supported_device_ids {
@@ -119,8 +113,8 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
 	if (b_sent)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, st->data,
-		iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, st->data, sizeof(st->data),
+				    iio_get_time_ns(indio_dev));
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 
@@ -138,7 +132,7 @@ static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch)
 	if (ret)
 		return ret;
 
-	return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1];
+	return be16_to_cpu(st->data[ch]);
 }
 
 static int ad7887_read_raw(struct iio_dev *indio_dev,
@@ -296,7 +290,7 @@ static int ad7887_probe(struct spi_device *spi)
 		st->xfer[1].tx_buf = &st->tx_cmd_buf[2];
 		st->xfer[1].len = 2;
 
-		st->xfer[2].rx_buf = &st->data[2];
+		st->xfer[2].rx_buf = &st->data[1];
 		st->xfer[2].tx_buf = &st->tx_cmd_buf[0];
 		st->xfer[2].len = 2;
 
@@ -304,7 +298,7 @@ static int ad7887_probe(struct spi_device *spi)
 		spi_message_add_tail(&st->xfer[1], &st->msg[AD7887_CH0_CH1]);
 		spi_message_add_tail(&st->xfer[2], &st->msg[AD7887_CH0_CH1]);
 
-		st->xfer[3].rx_buf = &st->data[2];
+		st->xfer[3].rx_buf = &st->data[1];
 		st->xfer[3].tx_buf = &st->tx_cmd_buf[2];
 		st->xfer[3].len = 2;
 
Signature · 1 line
2.43.0
#68 lore raw

Re: [PATCH 32/39] iio: adc: ad7887: use iio_push_to_buffers_with_ts()

Quoted 8 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

Replace the data buffer with one declared via IIO_DECLARE_DMA_BUFFER_WITH_TS(), for 2 __be16 channels.

Use be16_to_cpu() to replace the opencoded equivalent.

...

Quoted 2 lines

Otherwise I might just rip out the pdata path in the near future. This patch being an example of how it is causing maintenance burden.

I don't see users in the kernel, I think we may just drop it for good. If anybody wants that, they can use software nodes in the future, no revert will even be considered.

...

drivers/iio/adc/ad7887.c static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) · line 135

Quoted 2 lines
drivers/iio/adc/ad7887.c +1 -1
-	return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1];
+	return be16_to_cpu(st->data[ch]);

Add asm/byteorder.h into include block. And yes, the include block is a mess in this driver.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#69 lore raw

Re: [PATCH 32/39] iio: adc: ad7887: use iio_push_to_buffers_with_ts()

Quoted 19 lines · On Tue, 27 Oct 2026 12:24:14 +0200 Andy Shevchenko…
Quoted 8 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

Replace the data buffer with one declared via IIO_DECLARE_DMA_BUFFER_WITH_TS(), for 2 __be16 channels.

Use be16_to_cpu() to replace the opencoded equivalent.

...

Quoted 2 lines

Otherwise I might just rip out the pdata path in the near future. This patch being an example of how it is causing maintenance burden.

I don't see users in the kernel, I think we may just drop it for good. If anybody wants that, they can use software nodes in the future, no revert will even be considered.

Quoted 8 lines

...

drivers/iio/adc/ad7887.c static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) · line 135

Quoted 2 lines
drivers/iio/adc/ad7887.c +1 -1
-	return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1];
+	return be16_to_cpu(st->data[ch]);  

Add asm/byteorder.h into include block. And yes, the include block is a mess in this driver.

I will probably do a series removing kernel.h from a subset of drivers in IIO again (it's really painful though).

Signature · 2 lines
Kind regards,
Joshua Crofts
maintainer
#70 lore raw

Re: [PATCH 32/39] iio: adc: ad7887: use iio_push_to_buffers_with_ts()

Quoted 22 lines · On Tue, 27 Oct 2026 12:46:29 +0100 Joshua Crofts <[email protected]> wrote:
Quoted 19 lines · On Tue, 27 Oct 2026 12:24:14 +0200 Andy Shevchenko…
Quoted 8 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, which is a structure within the iio_priv() data.

Replace the data buffer with one declared via IIO_DECLARE_DMA_BUFFER_WITH_TS(), for 2 __be16 channels.

Use be16_to_cpu() to replace the opencoded equivalent.

...

Quoted 2 lines

Otherwise I might just rip out the pdata path in the near future. This patch being an example of how it is causing maintenance burden.

I don't see users in the kernel, I think we may just drop it for good. If anybody wants that, they can use software nodes in the future, no revert will even be considered.

Quoted 7 lines
Quoted 7 lines

...

drivers/iio/adc/ad7887.c static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) · line 135

Quoted 2 lines
drivers/iio/adc/ad7887.c +1 -1
-	return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1];
+	return be16_to_cpu(st->data[ch]);    

Add asm/byteorder.h into include block. And yes, the include block is a mess in this driver.

Done.

Quoted 5 lines
Quoted 1 line

I will probably do a series removing kernel.h from a subset of drivers in IIO again (it's really painful though).

That one can be a long term project. It's nice to have as cuts down on wrong choices in new drivers (via cut and paste), but it is isolated to each individual driver so the blast radius of bad includes isn't huge!

Jonathan

#71 lore raw

PATCH 33/39 iio: humidity: hts221: align scan buffer for DMA safety

In reply to Jonathan Cameron

hw->scan is used as the SPI transfer buffer in hts221_buffer_handler_thread() via regmap_bulk_read(), so it needs to be DMA safe. Add __aligned(IIO_DMA_MINALIGN).

---
Cc: Adi Nata <[email protected]>

---
 drivers/iio/humidity/hts221.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/hts221.h +1 -1
index 0215f11fc35e..59ed07c308d0 100644
@@ -41,7 +41,7 @@ struct hts221_hw {
 	struct {
 		__le16 channels[2];
 		aligned_s64 ts;
-	} scan;
+	} scan __aligned(IIO_DMA_MINALIGN);
 };
 
 extern const struct dev_pm_ops hts221_pm_ops;
Signature · 1 line
2.43.0
#72 lore raw

PATCH 34/39 iio: humidity: hts221: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Adi Nata <[email protected]>

---
 drivers/iio/humidity/hts221_buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hts221_buffer.c +2 -2
index df12c7a25b2e..25e7eff0436d 100644
@@ -179,8 +179,8 @@ static irqreturn_t hts221_buffer_handler_thread(int irq, void *p)
 	if (err < 0)
 		goto out;
 
-	iio_push_to_buffers_with_timestamp(iio_dev, &hw->scan,
-					   iio_get_time_ns(iio_dev));
+	iio_push_to_buffers_with_ts(iio_dev, &hw->scan, sizeof(hw->scan),
+				    iio_get_time_ns(iio_dev));
 
 out:
 	iio_trigger_notify_done(hw->trig);
Signature · 1 line
2.43.0
maintainer
#73 lore raw

Re: [PATCH 34/39] iio: humidity: hts221: use iio_push_to_buffers_with_ts()

Quoted 6 lines · On Mon, 26 Oct 2026 16:05:52 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Adi Nata <[email protected]>

Applied 33 and 34.

Thanks,

#74 lore raw

PATCH 35/39 iio: accel: bmc150-accel-core: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

The triggered buffer handler read into a separate fixed buffer rather than the scan buffer used for the FIFO path. Use the scan buffer directly and drop the now unused buffer field. This also corrects the type of the read destination to __le16 to match the scan buffer's channels array. Widen the mutex-held region to cover the use of scan.

---
 drivers/iio/accel/bmc150-accel-core.c | 12 ++++++------
 drivers/iio/accel/bmc150-accel.h      |  1 -
 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +6 -6
index 46bb36d9366e..4aa282183604 100644
@@ -1013,8 +1013,8 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
 			memcpy(&data->scan.channels[j++], &buffer[i * 3 + bit],
 			       sizeof(data->scan.channels[0]));
 
-		iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-						   tstamp);
+		iio_push_to_buffers_with_ts(indio_dev, &data->scan,
+					    sizeof(data->scan), tstamp);
 
 		tstamp += sample_period;
 	}
@@ -1193,14 +1193,14 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
 
 	mutex_lock(&data->mutex);
 	ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_REG_XOUT_L,
-			       data->buffer, AXIS_MAX * 2);
-	mutex_unlock(&data->mutex);
+			       data->scan.channels, AXIS_MAX * 2);
 	if (ret < 0)
 		goto err_read;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-					   pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, &data->scan,
+				    sizeof(data->scan), pf->timestamp);
 err_read:
+	mutex_unlock(&data->mutex);
 	iio_trigger_notify_done(indio_dev->trig);
 
 	return IRQ_HANDLED;
drivers/iio/accel/bmc150-accel.h +0 -1
index e8f26198359f..853709c0f46b 100644
@@ -64,7 +64,6 @@ struct bmc150_accel_data {
 	struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
 	struct mutex mutex;
 	u8 fifo_mode, watermark;
-	s16 buffer[8];
 	/*
 	 * Ensure there is sufficient space and correct alignment for
 	 * the timestamp if enabled
Signature · 1 line
2.43.0
#75 lore raw

Re: [PATCH 35/39] iio: accel: bmc150-accel-core: use iio_push_to_buffers_with_ts()

Quoted 9 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

The triggered buffer handler read into a separate fixed buffer rather than the scan buffer used for the FIFO path. Use the scan buffer directly and drop the now unused buffer field. This also corrects the type of the read destination to __le16 to match the scan buffer's channels array. Widen the mutex-held region to cover the use of scan.

...

drivers/iio/accel/bmc150-accel.h struct bmc150_accel_data { · line 67

Quoted 2 lines
drivers/iio/accel/bmc150-accel.h +0 -1
 	u8 fifo_mode, watermark;
-	s16 buffer[8];

I have a weak memory that I have seen a patch that reuses scan buffer instead of dedicated one, but I'm not sure if it was against this driver (and if so, why it got not applied).

It might be this one 8c5f649119f4 ("iio: accel: kionix-kx022a: use scan struct for one-shot and trigger reads").

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#76 lore raw

Re: [PATCH 35/39] iio: accel: bmc150-accel-core: use iio_push_to_buffers_with_ts()

Quoted 20 lines · On Tue, 27 Oct 2026 12:27:56 +0200 Andy Shevchenko…
Quoted 9 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

The triggered buffer handler read into a separate fixed buffer rather than the scan buffer used for the FIFO path. Use the scan buffer directly and drop the now unused buffer field. This also corrects the type of the read destination to __le16 to match the scan buffer's channels array. Widen the mutex-held region to cover the use of scan.

...

drivers/iio/accel/bmc150-accel.h struct bmc150_accel_data { · line 67

Quoted 2 lines
drivers/iio/accel/bmc150-accel.h +0 -1
 	u8 fifo_mode, watermark;
-	s16 buffer[8];  

I have a weak memory that I have seen a patch that reuses scan buffer instead of dedicated one, but I'm not sure if it was against this driver (and if so, why it got not applied).

Quoted 3 lines

It might be this one 8c5f649119f4 ("iio: accel: kionix-kx022a: use scan struct for one-shot and trigger reads").

There was indeed a discussion for this driver that touched on this for this driver. That also included a dma safety fix that I don't have here!

https://lore.kernel.org/all/[email protected]/

+CC Yash in case they intend to come back to this topic.

If not I'll come back to this one when I get to the nasty conversions and come up with a combination of Yash's series and the interface change this one is focused on.

Thanks and impressive memory given how many similar patches we've had come past recently!

Jonathan

#77 lore raw

PATCH 36/39 iio: common: cros_ec_sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

Replace the raw samples byte array with a scan struct containing the channel data and an aligned timestamp, matching the layout it was already manually maintaining and removing the need for the CROS_EC_SAMPLE_SIZE size calculation and the casts used to access it as an array of s16.

---
Cc: Cheng-Yi Chiang <[email protected]>
Cc: Tzung-Bi Shih <[email protected]>
Cc: Guenter Roeck <[email protected]>

---
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  | 24 ++++++++++------------
 include/linux/iio/common/cros_ec_sensors_core.h    | 18 +++++++---------
 2 files changed, 18 insertions(+), 24 deletions(-)
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +11 -13
index d03e40c91582..721e79f67f7f 100644
@@ -181,9 +181,8 @@ int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
 			      s64 timestamp)
 {
 	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
-	s16 *out;
+	unsigned int i, j;
 	s64 delta;
-	unsigned int i;
 
 	/*
 	 * Ignore samples if the buffer is not set: it is needed if the ODR is
@@ -192,19 +191,17 @@ int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
 	if (!iio_device_try_claim_buffer_mode(indio_dev))
 		return 0;
 
-	out = (s16 *)st->samples;
-	iio_for_each_active_channel(indio_dev, i) {
-		*out = data[i];
-		out++;
-	}
+	j = 0;
+	iio_for_each_active_channel(indio_dev, i)
+		st->scan.channels[j++] = data[i];
 
 	if (iio_device_get_clock(indio_dev) != CLOCK_BOOTTIME)
 		delta = iio_get_time_ns(indio_dev) - cros_ec_get_time_ns();
 	else
 		delta = 0;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, st->samples,
-					   timestamp + delta);
+	iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan),
+				    timestamp + delta);
 
 	iio_device_release_buffer_mode(indio_dev);
 	return 0;
@@ -718,17 +715,18 @@ irqreturn_t cros_ec_sensors_capture(int irq, void *p)
 	mutex_lock(&st->cmd_lock);
 
 	/* Clear capture data. */
-	memset(st->samples, 0, indio_dev->scan_bytes);
+	memset(&st->scan, 0, sizeof(st->scan));
 
 	/* Read data based on which channels are enabled in scan mask. */
 	ret = st->read_ec_sensors_data(indio_dev,
 				       *(indio_dev->active_scan_mask),
-				       (s16 *)st->samples);
+				       st->scan.channels);
 	if (ret < 0)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, st->samples,
-					   iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &st->scan,
+				    sizeof(st->scan),
+				    iio_get_time_ns(indio_dev));
 
 done:
 	/*
include/linux/iio/common/cros_ec_sensors_core.h +7 -11
index bb966abcde53..25af3bfbef42 100644
@@ -24,12 +24,6 @@ enum {
 /* EC returns sensor values using signed 16 bit registers */
 #define CROS_EC_SENSOR_BITS 16
 
-/*
- * 4 16 bit channels are allowed.
- * Good enough for current sensors, they use up to 3 16 bit vectors.
- */
-#define CROS_EC_SAMPLE_SIZE  (sizeof(s64) * 2)
-
 typedef irqreturn_t (*cros_ec_sensors_capture_t)(int irq, void *p);
 
 /**
@@ -48,10 +42,9 @@ typedef irqreturn_t (*cros_ec_sensors_capture_t)(int irq, void *p);
  * @calib:			calibration parameters. Note that trigger
  *				captured data will always provide the calibrated
  *				data
- * @samples:			static array to hold data from a single capture.
- *				For each channel we need 2 bytes, except for
- *				the timestamp. The timestamp is always last and
- *				is always 8-byte aligned.
+ * @scan:			structure to hold data from a single capture.
+ *				Up to 4 16 bit channels, followed by an 8-byte
+ *				aligned timestamp.
  * @read_ec_sensors_data:	function used for accessing sensors values
  * @fifo_max_event_count:	Size of the EC sensor FIFO
  * @frequencies:		Table of known available frequencies:
@@ -75,7 +68,10 @@ struct cros_ec_sensors_core_state {
 		u16 scale;
 	} calib[CROS_EC_SENSOR_MAX_AXIS];
 	s8 sign[CROS_EC_SENSOR_MAX_AXIS];
-	u8 samples[CROS_EC_SAMPLE_SIZE] __aligned(8);
+	struct {
+		s16 channels[4];
+		aligned_s64 timestamp;
+	} scan;
 
 	int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
 				    unsigned long scan_mask, s16 *data);
Signature · 1 line
2.43.0
Reviewed-by on v1 36/39
#78 lore raw

Re: [PATCH 36/39] iio: common: cros_ec_sensors: use iio_push_to_buffers_with_ts()

Quoted 11 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

Replace the raw samples byte array with a scan struct containing the channel data and an aligned timestamp, matching the layout it was already manually maintaining and removing the need for the CROS_EC_SAMPLE_SIZE size calculation and the casts used to access it as an array of s16.

The patch looks good to me. Just a minor note below.

Quoted 1 line
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -0

...

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_push_data(struct iio_dev *indio_dev, · line 196

Quoted 12 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -5
@@ -192,19 +191,17 @@ int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
 	if (!iio_device_try_claim_buffer_mode(indio_dev))
 		return 0;
 
-	out = (s16 *)st->samples;
-	iio_for_each_active_channel(indio_dev, i) {
-		*out = data[i];
-		out++;
-	}
+	j = 0;
+	iio_for_each_active_channel(indio_dev, i)
+		st->scan.channels[j++] = data[i];

This is a pre-existing issue, but there is no bounds check on j. I'm not sure if the number of active channels can ever exceed 4.

maintainer
#79 lore raw

Re: [PATCH 36/39] iio: common: cros_ec_sensors: use iio_push_to_buffers_with_ts()

Quoted 23 lines · On Tue, 27 Oct 2026 03:19:03 +0000 Tzung-Bi Shih <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

Replace the raw samples byte array with a scan struct containing the channel data and an aligned timestamp, matching the layout it was already manually maintaining and removing the need for the CROS_EC_SAMPLE_SIZE size calculation and the casts used to access it as an array of s16.

The patch looks good to me. Just a minor note below.

Quoted 1 line
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -0

...

Quoted 4 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -0
@@ -192,19 +191,17 @@ int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
 	if (!iio_device_try_claim_buffer_mode(indio_dev))
 		return 0;
 
Quoted 12 lines

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_push_data(struct iio_dev *indio_dev, · line 196

Quoted 8 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -5
-	out = (s16 *)st->samples;
-	iio_for_each_active_channel(indio_dev, i) {
-		*out = data[i];
-		out++;
-	}
+	j = 0;
+	iio_for_each_active_channel(indio_dev, i)
+		st->scan.channels[j++] = data[i];  

This is a pre-existing issue, but there is no bounds check on j. I'm not sure if the number of active channels can ever exceed 4.

It might be a good idea to add a sanity check for that, but job for another day.

Applied this one with the tweak that Andy requested.

Thanks,

Jonathan

#80 lore raw

Re: [PATCH 36/39] iio: common: cros_ec_sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron
Quoted 9 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer, at both call sites.

Replace the raw samples byte array with a scan struct containing the channel data and an aligned timestamp, matching the layout it was already manually maintaining and removing the need for the CROS_EC_SAMPLE_SIZE size calculation and the casts used to access it as an array of s16.

...

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c irqreturn_t cros_ec_sensors_capture(int irq, void *p)

Quoted 6 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +2 -2
-	iio_push_to_buffers_with_timestamp(indio_dev, st->samples,
-					   iio_get_time_ns(indio_dev));
 
+	iio_push_to_buffers_with_ts(indio_dev, &st->scan,
 
+				    sizeof(st->scan),

There is room on the previous line for this one.

Quoted 1 line
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +1 -0
+				    iio_get_time_ns(indio_dev));
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#81 lore raw

PATCH 37/39 iio: common: ssp_sensors: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
 drivers/iio/common/ssp_sensors/ssp_iio.c | 28 ++++++++--------------------
 include/linux/iio/common/ssp_sensors.h   |  2 --
 2 files changed, 8 insertions(+), 22 deletions(-)
drivers/iio/common/ssp_sensors/ssp_iio.c +8 -20
index 78ac689de2fe..a2a5a6292c47 100644
@@ -7,7 +7,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/unaligned.h>
 #include <linux/units.h>
 #include "ssp_iio_sensor.h"
@@ -24,13 +23,6 @@ int ssp_common_buffer_postenable(struct iio_dev *indio_dev)
 	struct ssp_sensor_data *spd = iio_priv(indio_dev);
 	struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
 
-	/* the allocation is made in post because scan size is known in this
-	 * moment
-	 * */
-	spd->buffer = kmalloc(indio_dev->scan_bytes, GFP_KERNEL | GFP_DMA);
-	if (!spd->buffer)
-		return -ENOMEM;
-
 	return ssp_enable_sensor(data, spd->type,
 				 ssp_get_sensor_delay(data, spd->type));
 }
@@ -45,17 +37,10 @@ EXPORT_SYMBOL_NS(ssp_common_buffer_postenable, "IIO_SSP_SENSORS");
  */
 int ssp_common_buffer_postdisable(struct iio_dev *indio_dev)
 {
-	int ret;
 	struct ssp_sensor_data *spd = iio_priv(indio_dev);
 	struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
 
-	ret = ssp_disable_sensor(data, spd->type);
-	if (ret < 0)
-		return ret;
-
-	kfree(spd->buffer);
-
-	return ret;
+	return ssp_disable_sensor(data, spd->type);
 }
 EXPORT_SYMBOL_NS(ssp_common_buffer_postdisable, "IIO_SSP_SENSORS");
 
@@ -72,8 +57,11 @@ EXPORT_SYMBOL_NS(ssp_common_buffer_postdisable, "IIO_SSP_SENSORS");
 int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
 			    unsigned int len, int64_t timestamp)
 {
+	struct {
+		__le16 channels[3];
+		aligned_s64 timestamp;
+	} scan = { };
 	int64_t calculated_time;
-	struct ssp_sensor_data *spd = iio_priv(indio_dev);
 
 	if (indio_dev->scan_bytes == 0)
 		return 0;
@@ -81,13 +69,13 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
 	/*
 	 * it always sends full set of samples, remember about available masks
 	 */
-	memcpy(spd->buffer, buf, len);
+	memcpy(scan.channels, buf, len);
 
 	calculated_time = timestamp +
 		(int64_t)get_unaligned_le32(buf + len) * MEGA;
 
-	return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer,
-						  calculated_time);
+	return iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+					    calculated_time);
 }
 EXPORT_SYMBOL_NS(ssp_common_process_data, "IIO_SSP_SENSORS");
 
include/linux/iio/common/ssp_sensors.h +0 -2
index 06c9b4b563b3..bfadf8eae558 100644
@@ -48,13 +48,11 @@ struct ssp_data;
  * struct ssp_sensor_data - Sensor object
  * @process_data:	Callback to feed sensor data.
  * @type:		Used sensor type.
- * @buffer:		Received data buffer.
  */
 struct ssp_sensor_data {
 	int (*process_data)(struct iio_dev *indio_dev, void *buf,
 			    int64_t timestamp);
 	enum ssp_sensor_type type;
-	u8 *buffer;
 };
 
 void ssp_register_consumer(struct iio_dev *indio_dev,
Signature · 1 line
2.43.0
maintainer Applied
#82 lore raw

Re: [PATCH 37/39] iio: common: ssp_sensors: use iio_push_to_buffers_with_ts()

Quoted 4 lines · On Mon, 26 Oct 2026 16:05:55 -0700 Jonathan Cameron…

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Applied.

#83 lore raw

PATCH 38/39 iio: imu: st_lsm6dsx: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

---
Cc: Francesco Lavra <[email protected]>
Cc: Lorenzo Bianconi <[email protected]>

---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 ++++++++++-------
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c   |  5 +++--
 2 files changed, 13 insertions(+), 9 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +10 -7
index 777d479f10c0..c60192775ce8 100644
@@ -496,9 +496,10 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
 				if (gyro_sensor->samples_to_discard > 0)
 					gyro_sensor->samples_to_discard--;
 				else
-					iio_push_to_buffers_with_timestamp(
+					iio_push_to_buffers_with_ts(
 						hw->iio_devs[ST_LSM6DSX_ID_GYRO],
 						&hw->scan[ST_LSM6DSX_ID_GYRO],
+						sizeof(hw->scan[ST_LSM6DSX_ID_GYRO]),
 						gyro_sensor->ts_ref + ts);
 				gyro_sip--;
 			}
@@ -510,16 +511,18 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
 				if (acc_sensor->samples_to_discard > 0)
 					acc_sensor->samples_to_discard--;
 				else
-					iio_push_to_buffers_with_timestamp(
+					iio_push_to_buffers_with_ts(
 						hw->iio_devs[ST_LSM6DSX_ID_ACC],
 						&hw->scan[ST_LSM6DSX_ID_ACC],
+						sizeof(hw->scan[ST_LSM6DSX_ID_ACC]),
 						acc_sensor->ts_ref + ts);
 				acc_sip--;
 			}
 			if (ext_sip > 0 && !(sip % ext_sensor->decimator)) {
-				iio_push_to_buffers_with_timestamp(
+				iio_push_to_buffers_with_ts(
 					hw->iio_devs[ST_LSM6DSX_ID_EXT0],
 					&hw->scan[ST_LSM6DSX_ID_EXT0],
+					sizeof(hw->scan[ST_LSM6DSX_ID_EXT0]),
 					ext_sensor->ts_ref + ts);
 				ext_sip--;
 			}
@@ -549,7 +552,7 @@ static bool st_lsm6dsx_check_data(u8 tag, __le16 *data)
 }
 
 static int st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag,
-				       __le16 *data, s64 ts)
+				       __le16 *data, size_t len, s64 ts)
 {
 	struct st_lsm6dsx_sensor *sensor;
 	struct iio_dev *iio_dev;
@@ -597,8 +600,7 @@ static int st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag,
 	}
 
 	sensor = iio_priv(iio_dev);
-	iio_push_to_buffers_with_timestamp(iio_dev, data,
-					   ts + sensor->ts_ref);
+	iio_push_to_buffers_with_ts(iio_dev, data, len, ts + sensor->ts_ref);
 
 	return 0;
 }
@@ -617,7 +619,7 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw)
 	u16 fifo_len, fifo_diff_mask;
 	/*
 	 * Alignment needed as this can ultimately be passed to a
-	 * call to iio_push_to_buffers_with_timestamp() which
+	 * call to iio_push_to_buffers_with_ts() which
 	 * must be passed a buffer that is aligned to 8 bytes so
 	 * as to allow insertion of a naturally aligned timestamp.
 	 */
@@ -690,6 +692,7 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw)
 			} else {
 				st_lsm6dsx_push_tagged_data(hw, tag,
 							    iio_buff.data,
+							    sizeof(iio_buff),
 							    ts);
 			}
 		}
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +3 -2
index 360f1365f892..81ff0b32ec40 100644
@@ -2798,8 +2798,9 @@ static irqreturn_t st_lsm6dsx_sw_trigger_handler_thread(int irq,
 				       hw->scan[sensor->id].channels,
 				       sizeof(hw->scan[sensor->id].channels));
 
-	iio_push_to_buffers_with_timestamp(iio_dev, &hw->scan[sensor->id],
-					   iio_get_time_ns(iio_dev));
+	iio_push_to_buffers_with_ts(iio_dev, &hw->scan[sensor->id],
+				    sizeof(hw->scan[sensor->id]),
+				    iio_get_time_ns(iio_dev));
 	iio_trigger_notify_done(iio_dev->trig);
 
 	return IRQ_HANDLED;
Signature · 1 line
2.43.0
#85 lore raw

Re: [PATCH 38/39] iio: imu: st_lsm6dsx: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron
Quoted 2 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

...

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) · line 503

Quoted 9 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +2 -1
 				if (gyro_sensor->samples_to_discard > 0)
 					gyro_sensor->samples_to_discard--;
 				else
-					iio_push_to_buffers_with_timestamp(
+					iio_push_to_buffers_with_ts(
 						hw->iio_devs[ST_LSM6DSX_ID_GYRO],
 						&hw->scan[ST_LSM6DSX_ID_GYRO],
+						sizeof(hw->scan[ST_LSM6DSX_ID_GYRO]),
 						gyro_sensor->ts_ref + ts);

Seems like a lot of code duplication in all three cases. But yeah, it's out of scope of this change.

Quoted 2 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +0 -0
 				gyro_sip--;
 			}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#86 lore raw

Re: [PATCH 38/39] iio: imu: st_lsm6dsx: use iio_push_to_buffers_with_ts()

Quoted 6 lines · On Tue, 27 Oct 2026 12:55:31 +0200 Andy Shevchenko…
Quoted 2 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

...

Quoted 12 lines

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) · line 503

Quoted 9 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +2 -1
 				if (gyro_sensor->samples_to_discard > 0)
 					gyro_sensor->samples_to_discard--;
 				else
-					iio_push_to_buffers_with_timestamp(
+					iio_push_to_buffers_with_ts(
 						hw->iio_devs[ST_LSM6DSX_ID_GYRO],
 						&hw->scan[ST_LSM6DSX_ID_GYRO],
+						sizeof(hw->scan[ST_LSM6DSX_ID_GYRO]),
 						gyro_sensor->ts_ref + ts);  

Seems like a lot of code duplication in all three cases. But yeah, it's out of scope of this change.

True. Maybe worth someone taking a look.

Applied this one.

Thanks,

Jonathan

Quoted 4 lines
Quoted 3 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +0 -0
 				gyro_sip--;
 			}  
#87 lore raw

PATCH 39/39 iio: imu: bmi160: use iio_push_to_buffers_with_ts()

In reply to Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the scan buffer off struct bmi160_data and onto the stack of bmi160_trigger_handler() as a zero-initialized IIO_DECLARE_BUFFER_WITH_TS() array, since it is only ever used locally within that function.

---
 drivers/iio/imu/bmi160/bmi160.h      | 7 -------
 drivers/iio/imu/bmi160/bmi160_core.c | 6 ++++--
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/iio/imu/bmi160/bmi160.h +0 -7
index ffbe8205e703..629844c34f1a 100644
@@ -10,13 +10,6 @@ struct bmi160_data {
 	struct iio_trigger *trig;
 	struct regulator_bulk_data supplies[2];
 	struct iio_mount_matrix orientation;
-	/*
-	 * Ensure natural alignment for timestamp if present.
-	 * Max length needed: 2 * 3 channels + 4 bytes padding + 8 byte ts.
-	 * If fewer channels are enabled, less space may be needed, as
-	 * long as the timestamp is still aligned to 8 bytes.
-	 */
-	__le16 buf[12] __aligned(8);
 };
 
 extern const struct regmap_config bmi160_regmap_config;
drivers/iio/imu/bmi160/bmi160_core.c +4 -2
index 1e73a7f1f017..1bbca85f9f14 100644
@@ -432,6 +432,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct bmi160_data *data = iio_priv(indio_dev);
+	IIO_DECLARE_BUFFER_WITH_TS(__le16, scan, 6) = { };
 	int i, ret, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L;
 	__le16 sample;
 
@@ -440,10 +441,11 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
 				       &sample, sizeof(sample));
 		if (ret)
 			goto done;
-		data->buf[j++] = sample;
+		scan[j++] = sample;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 	return IRQ_HANDLED;
Signature · 1 line
2.43.0
#88 lore raw

Re: [PATCH 39/39] iio: imu: bmi160: use iio_push_to_buffers_with_ts()

Quoted 6 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the scan buffer off struct bmi160_data and onto the stack of bmi160_trigger_handler() as a zero-initialized IIO_DECLARE_BUFFER_WITH_TS() array, since it is only ever used locally within that function.

...

drivers/iio/imu/bmi160/bmi160_core.c static irqreturn_t bmi160_trigger_handler(int irq, void *p) · line 448

Quoted 3 lines
drivers/iio/imu/bmi160/bmi160_core.c +2 -1
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);

One line?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#89 lore raw

Re: [PATCH 39/39] iio: imu: bmi160: use iio_push_to_buffers_with_ts()

Quoted 8 lines · On Tue, 27 Oct 2026 12:56:10 +0200 Andy Shevchenko…
Quoted 6 lines · Jonathan Cameron

Replace the deprecated iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts(), passing the size of the pushed buffer.

Move the scan buffer off struct bmi160_data and onto the stack of bmi160_trigger_handler() as a zero-initialized IIO_DECLARE_BUFFER_WITH_TS() array, since it is only ever used locally within that function.

Quoted 8 lines

...

drivers/iio/imu/bmi160/bmi160_core.c static irqreturn_t bmi160_trigger_handler(int irq, void *p) · line 448

Quoted 3 lines
drivers/iio/imu/bmi160/bmi160_core.c +2 -1
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp);
+	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan),
+				    pf->timestamp);  

One line?

Tweaked and applied.

Thanks for casting your eagle eyes over these!

Jonathan

Reviewed-by on the v1 series
#90 lore raw
In reply to Jonathan Cameron
Quoted 13 lines · Jonathan Cameron

A bit of technical debt cleanup that was partly a discovery exercise in using AI tooling for this sort of somewhat messy subsystem maintenance activity.

Replace iio_push_to_buffers_with_timestamp() with iio_push_to_buffers_with_ts() which includes a runtime check that there is sufficient space to insert the timestamp.

A few other modifications of related code seen whilst working through these and a couple of fixes for DMA safety. Those are not sent as separate fixes as they are in old drivers and we have had no reports of problems. So no rush to get upstream.

Quoted 7 lines

The remaining users of iio_push_to_buffers_with_timestamp() are the more complex cases that will require more careful review so are left for the next series.

I appreciate this is a large series, so if you have time to take a look review what you can and I'll nibble away at applying the ones that have received sufficient review.

assuming we get a positive feedback from Srinivas on testing HID sensors case.

Signature · 2 lines
With Best Regards,
Andy Shevchenko