linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment
@ 2021-05-01 17:01 Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
                   ` (19 more replies)
  0 siblings, 20 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Peter Meerwald, Andy Shevchenko,
	Srinivas Pandruvada, Daniel Baluta, Stefan-Gabriel Mirea,
	Sanchayan Maity, Stephan Gerhold, Andreas Klinger, Matt Ranostay,
	Linus Walleij

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I finally got around to do a manual audit of all the calls to
iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
of:
1. 8 byte alignment of the provided buffer.
2. space for an 8 byte naturally aligned timestamp to be inserted at the
   end.

Unfortuantely there were rather a lot of these left, but time to bite the bullet
and clean them up.

As discussed previous in
https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
it is not easy to fix the alignment issue without requiring a bounce buffer
(see part 4 of the alignment fixes for a proposal for that where it is
absolutely necessary).

Part 2 is the simple cases where the timestamp position is always the same
(as not more than 8 bytes of other scan elements) and where it is either
in a structure that is kzalloc'd or there was already an explicit memset
that would clear any holes in the structure (and hence avoid a potential
kernel data leak).

Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Cc: Sanchayan Maity <maitysanchayan@gmail.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Andreas Klinger <ak@it-klinger.de>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: Linus Walleij <linus.walleij@linaro.org>

Jonathan Cameron (19):
  iio: accel: bma180: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: accel: bma220: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: accel: hid: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: accel: kxcjk-1013: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: accel: mxc4005: Fix overread of data and alignment issue.
  iio: accel: stk8312: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: accel: stk8ba50: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: adc: ti-ads1015: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: adc: vf610: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: gyro: bmg160: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: humidity: am2315: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: prox: srf08: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: prox: pulsed-light: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: prox: as3935: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: magn: hmc5843: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: magn: bmc150: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: light: isl29125: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: light: tcs3414: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()
  iio: light: tcs3472: Fix buffer alignment in
    iio_push_to_buffers_with_timestamp()

 drivers/iio/accel/bma180.c                    | 10 +++++---
 drivers/iio/accel/bma220_spi.c                | 10 +++++---
 drivers/iio/accel/hid-sensor-accel-3d.c       | 13 ++++++----
 drivers/iio/accel/kxcjk-1013.c                | 24 +++++++++++--------
 drivers/iio/accel/mxc4005.c                   | 10 +++++---
 drivers/iio/accel/stk8312.c                   | 12 ++++++----
 drivers/iio/accel/stk8ba50.c                  | 17 +++++++------
 drivers/iio/adc/ti-ads1015.c                  | 12 ++++++----
 drivers/iio/adc/vf610_adc.c                   | 10 +++++---
 drivers/iio/gyro/bmg160_core.c                | 10 +++++---
 drivers/iio/humidity/am2315.c                 | 16 ++++++++-----
 drivers/iio/light/isl29125.c                  | 10 +++++---
 drivers/iio/light/tcs3414.c                   | 10 +++++---
 drivers/iio/light/tcs3472.c                   | 10 +++++---
 drivers/iio/magnetometer/bmc150_magn.c        | 11 +++++----
 drivers/iio/magnetometer/hmc5843.h            |  8 +++++--
 drivers/iio/magnetometer/hmc5843_core.c       |  4 ++--
 drivers/iio/proximity/as3935.c                | 10 +++++---
 .../iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++---
 drivers/iio/proximity/srf08.c                 | 14 +++++------
 20 files changed, 148 insertions(+), 83 deletions(-)

-- 
2.31.1


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

* [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-13 17:22   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 02/19] iio: accel: bma220: " Jonathan Cameron
                   ` (18 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Peter Meerwald

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/accel/bma180.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index b8a7469cdae4..2e901f900ea7 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -162,7 +162,11 @@ struct bma180_data {
 	int scale;
 	int bw;
 	bool pmode;
-	u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s16 chan[3];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 enum bma180_chan {
@@ -938,12 +942,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
 			mutex_unlock(&data->mutex);
 			goto err;
 		}
-		((s16 *)data->buff)[i++] = ret;
+		data->scan.chan[i++] = ret;
 	}
 
 	mutex_unlock(&data->mutex);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
2.31.1


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

* [PATCH 02/19] iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-13 17:26   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 03/19] iio: accel: hid: " Jonathan Cameron
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Andy Shevchenko

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 194dc4c71413 ("iio: accel: Add triggered buffer support for BMA220")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/accel/bma220_spi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index 36fc9876dbca..2802ce1852ef 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -63,7 +63,11 @@ static const int bma220_scale_table[][2] = {
 struct bma220_data {
 	struct spi_device *spi_device;
 	struct mutex lock;
-	s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 8x8 timestamp */
+	struct {
+		s8 chans[2];
+		/* Ensure timestamp is naturally aligned. */
+		s64 timestamp __aligned(8);
+	} scan;
 	u8 tx_buf[2] ____cacheline_aligned;
 };
 
@@ -94,12 +98,12 @@ static irqreturn_t bma220_trigger_handler(int irq, void *p)
 
 	mutex_lock(&data->lock);
 	data->tx_buf[0] = BMA220_REG_ACCEL_X | BMA220_READ_MASK;
-	ret = spi_write_then_read(spi, data->tx_buf, 1, data->buffer,
+	ret = spi_write_then_read(spi, data->tx_buf, 1, &data->scan.chans,
 				  ARRAY_SIZE(bma220_channels) - 1);
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 err:
 	mutex_unlock(&data->lock);
-- 
2.31.1


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

* [PATCH 03/19] iio: accel: hid: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 02/19] iio: accel: bma220: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-13 17:28   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 04/19] iio: accel: kxcjk-1013: " Jonathan Cameron
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Srinivas Pandruvada

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.
Note this matches what was done in all the other hid sensor drivers.
This one was missed previously due to an extra level of indirection.

Found during an audit of all calls of this function.

Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2f9465cb382f..27f47e1c251e 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -28,8 +28,11 @@ struct accel_3d_state {
 	struct hid_sensor_hub_callbacks callbacks;
 	struct hid_sensor_common common_attributes;
 	struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX];
-	/* Reserve for 3 channels + padding + timestamp */
-	u32 accel_val[ACCEL_3D_CHANNEL_MAX + 3];
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u32 accel_val[3];
+		s64 timestamp __aligned(8);
+	} scan;
 	int scale_pre_decml;
 	int scale_post_decml;
 	int scale_precision;
@@ -245,8 +248,8 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
 			accel_state->timestamp = iio_get_time_ns(indio_dev);
 
 		hid_sensor_push_data(indio_dev,
-				     accel_state->accel_val,
-				     sizeof(accel_state->accel_val),
+				     &accel_state->scan,
+				     sizeof(accel_state->scan),
 				     accel_state->timestamp);
 
 		accel_state->timestamp = 0;
@@ -271,7 +274,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
 	case HID_USAGE_SENSOR_ACCEL_Y_AXIS:
 	case HID_USAGE_SENSOR_ACCEL_Z_AXIS:
 		offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS;
-		accel_state->accel_val[CHANNEL_SCAN_INDEX_X + offset] =
+		accel_state->scan.accel_val[CHANNEL_SCAN_INDEX_X + offset] =
 						*(u32 *)raw_data;
 		ret = 0;
 	break;
-- 
2.31.1


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

* [PATCH 04/19] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (2 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 03/19] iio: accel: hid: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 19:10   ` Andy Shevchenko
  2021-05-01 17:01 ` [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue Jonathan Cameron
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Srinivas Pandruvada

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/iio/accel/kxcjk-1013.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index ff724bc17a45..96ab247f17b3 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -133,6 +133,13 @@ enum kx_acpi_type {
 	ACPI_KIOX010A,
 };
 
+enum kxcjk1013_axis {
+	AXIS_X,
+	AXIS_Y,
+	AXIS_Z,
+	AXIS_MAX,
+};
+
 struct kxcjk1013_data {
 	struct regulator_bulk_data regulators[2];
 	struct i2c_client *client;
@@ -140,7 +147,11 @@ struct kxcjk1013_data {
 	struct iio_trigger *motion_trig;
 	struct iio_mount_matrix orientation;
 	struct mutex mutex;
-	s16 buffer[8];
+	/* Ensure timestamp naturally aligned */
+	struct {
+		s16 chans[AXIS_MAX];
+		s64 timestamp __aligned(8);
+	} scan;
 	u8 odr_bits;
 	u8 range;
 	int wake_thres;
@@ -154,13 +165,6 @@ struct kxcjk1013_data {
 	enum kx_acpi_type acpi_type;
 };
 
-enum kxcjk1013_axis {
-	AXIS_X,
-	AXIS_Y,
-	AXIS_Z,
-	AXIS_MAX,
-};
-
 enum kxcjk1013_mode {
 	STANDBY,
 	OPERATION,
@@ -1094,12 +1098,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
 	ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
 							KXCJK1013_REG_XOUT_L,
 							AXIS_MAX * 2,
-							(u8 *)data->buffer);
+							(u8 *)data->scan.chans);
 	mutex_unlock(&data->mutex);
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   data->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
2.31.1


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

* [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue.
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (3 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 04/19] iio: accel: kxcjk-1013: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-13 17:37   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The bulk read size is based on the size of an array that also has
space for the timestamp alongside the channels.
Fix that and also fix alignment of the buffer passed
to iio_push_to_buffers_with_timestamp.

Found during an audit of all calls to this function.

Fixes: 1ce0eda0f757 ("iio: mxc4005: add triggered buffer mode for mxc4005")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/mxc4005.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
index fb3cbaa62bd8..9e6066c6a2df 100644
--- a/drivers/iio/accel/mxc4005.c
+++ b/drivers/iio/accel/mxc4005.c
@@ -56,7 +56,11 @@ struct mxc4005_data {
 	struct mutex mutex;
 	struct regmap *regmap;
 	struct iio_trigger *dready_trig;
-	__be16 buffer[8];
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		__be16 chans[3];
+		s64 timestamp;
+	} scan;
 	bool trigger_enabled;
 };
 
@@ -135,7 +139,7 @@ static int mxc4005_read_xyz(struct mxc4005_data *data)
 	int ret;
 
 	ret = regmap_bulk_read(data->regmap, MXC4005_REG_XOUT_UPPER,
-			       data->buffer, sizeof(data->buffer));
+			       data->scan.chans, sizeof(data->scan.chans));
 	if (ret < 0) {
 		dev_err(data->dev, "failed to read axes\n");
 		return ret;
@@ -301,7 +305,7 @@ static irqreturn_t mxc4005_trigger_handler(int irq, void *private)
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 
 err:
-- 
2.31.1


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

* [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (4 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-13 17:39   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 07/19] iio: accel: stk8ba50: " Jonathan Cameron
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 95c12bba51c3 ("iio: accel: Add buffer mode for Sensortek STK8312")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/stk8312.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 157d8faefb9e..c8b6915a757c 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -103,7 +103,11 @@ struct stk8312_data {
 	u8 mode;
 	struct iio_trigger *dready_trig;
 	bool dready_trigger_on;
-	s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s8 chans[3];
+		s64 timestamp;
+	} scan;
 };
 
 static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
@@ -438,7 +442,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
 		ret = i2c_smbus_read_i2c_block_data(data->client,
 						    STK8312_REG_XOUT,
 						    STK8312_ALL_CHANNEL_SIZE,
-						    data->buffer);
+						    data->scan.chans);
 		if (ret < STK8312_ALL_CHANNEL_SIZE) {
 			dev_err(&data->client->dev, "register read failed\n");
 			mutex_unlock(&data->lock);
@@ -452,12 +456,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
 				mutex_unlock(&data->lock);
 				goto err;
 			}
-			data->buffer[i++] = ret;
+			data->scan.chans[i++] = ret;
 		}
 	}
 	mutex_unlock(&data->lock);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
2.31.1


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

* [PATCH 07/19] iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (5 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 08/19] iio: adc: ti-ads1015: " Jonathan Cameron
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: db6a19b8251f ("iio: accel: Add trigger support for STK8BA50")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/stk8ba50.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 7cf9cb7e8666..eb9daa4e623a 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -91,12 +91,11 @@ struct stk8ba50_data {
 	u8 sample_rate_idx;
 	struct iio_trigger *dready_trig;
 	bool dready_trigger_on;
-	/*
-	 * 3 x 16-bit channels (10-bit data, 6-bit padding) +
-	 * 1 x 16 padding +
-	 * 4 x 16 64-bit timestamp
-	 */
-	s16 buffer[8];
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s16 chans[3];
+		s64 timetamp __aligned(8);
+	} scan;
 };
 
 #define STK8BA50_ACCEL_CHANNEL(index, reg, axis) {			\
@@ -324,7 +323,7 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
 		ret = i2c_smbus_read_i2c_block_data(data->client,
 						    STK8BA50_REG_XOUT,
 						    STK8BA50_ALL_CHANNEL_SIZE,
-						    (u8 *)data->buffer);
+						    (u8 *)data->scan.chans);
 		if (ret < STK8BA50_ALL_CHANNEL_SIZE) {
 			dev_err(&data->client->dev, "register read failed\n");
 			goto err;
@@ -337,10 +336,10 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
 			if (ret < 0)
 				goto err;
 
-			data->buffer[i++] = ret;
+			data->scan.chans[i++] = ret;
 		}
 	}
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 err:
 	mutex_unlock(&data->lock);
-- 
2.31.1


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

* [PATCH 08/19] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (6 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 07/19] iio: accel: stk8ba50: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 09/19] iio: adc: vf610: " Jonathan Cameron
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Daniel Baluta, Andy Shevchenko

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: ecc24e72f437 ("iio: adc: Add TI ADS1015 ADC driver support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/ti-ads1015.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 9fef39bcf997..5b828428be77 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -395,10 +395,14 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ads1015_data *data = iio_priv(indio_dev);
-	s16 buf[8]; /* 1x s16 ADC val + 3x s16 padding +  4x s16 timestamp */
+	/* Ensure natural alignment of timestamp */
+	struct {
+		s16 chan;
+		s64 timestamp __aligned(8);
+	} scan;
 	int chan, ret, res;
 
-	memset(buf, 0, sizeof(buf));
+	memset(&scan, 0, sizeof(scan));
 
 	mutex_lock(&data->lock);
 	chan = find_first_bit(indio_dev->active_scan_mask,
@@ -409,10 +413,10 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
 		goto err;
 	}
 
-	buf[0] = res;
+	scan.chan = res;
 	mutex_unlock(&data->lock);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, buf,
+	iio_push_to_buffers_with_timestamp(indio_dev, &scan,
 					   iio_get_time_ns(indio_dev));
 
 err:
-- 
2.31.1


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

* [PATCH 09/19] iio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (7 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 08/19] iio: adc: ti-ads1015: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 10/19] iio: gyro: bmg160: " Jonathan Cameron
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Stefan-Gabriel Mirea, Sanchayan Maity

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 0010d6b44406 ("iio: adc: vf610: Add IIO buffer support for Vybrid ADC")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Cc: Sanchayan Maity <maitysanchayan@gmail.com>
---
 drivers/iio/adc/vf610_adc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 1d794cf3e3f1..fd57fc43e8e5 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -167,7 +167,11 @@ struct vf610_adc {
 	u32 sample_freq_avail[5];
 
 	struct completion completion;
-	u16 buffer[8];
+	/* Ensure the timestamp is naturally aligned */
+	struct {
+		u16 chan;
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 };
@@ -579,9 +583,9 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id)
 	if (coco & VF610_ADC_HS_COCO0) {
 		info->value = vf610_adc_read_data(info);
 		if (iio_buffer_enabled(indio_dev)) {
-			info->buffer[0] = info->value;
+			info->scan.chan = info->value;
 			iio_push_to_buffers_with_timestamp(indio_dev,
-					info->buffer,
+					&info->scan,
 					iio_get_time_ns(indio_dev));
 			iio_trigger_notify_done(indio_dev->trig);
 		} else
-- 
2.31.1


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

* [PATCH 10/19] iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (8 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 09/19] iio: adc: vf610: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 11/19] iio: humidity: am2315: " Jonathan Cameron
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Stephan Gerhold

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 13426454b649 ("iio: bmg160: Separate i2c and core driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
---
 drivers/iio/gyro/bmg160_core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index b11ebd9bb7a4..7bc13ff2c3ac 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -98,7 +98,11 @@ struct bmg160_data {
 	struct iio_trigger *motion_trig;
 	struct iio_mount_matrix orientation;
 	struct mutex mutex;
-	s16 buffer[8];
+	/* Ensure naturally aligned timestamp */
+	struct {
+		s16 chans[3];
+		s64 timestamp __aligned(8);
+	} scan;
 	u32 dps_range;
 	int ev_enable_state;
 	int slope_thres;
@@ -882,12 +886,12 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
 
 	mutex_lock(&data->mutex);
 	ret = regmap_bulk_read(data->regmap, BMG160_REG_XOUT_L,
-			       data->buffer, AXIS_MAX * 2);
+			       data->scan.chans, AXIS_MAX * 2);
 	mutex_unlock(&data->mutex);
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
2.31.1


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

* [PATCH 11/19] iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (9 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 10/19] iio: gyro: bmg160: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 12/19] iio: prox: srf08: " Jonathan Cameron
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 0d96d5ead3f7 ("iio: humidity: Add triggered buffer support for AM2315")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/humidity/am2315.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
index 23bc9c784ef4..248d0f262d60 100644
--- a/drivers/iio/humidity/am2315.c
+++ b/drivers/iio/humidity/am2315.c
@@ -33,7 +33,11 @@
 struct am2315_data {
 	struct i2c_client *client;
 	struct mutex lock;
-	s16 buffer[8]; /* 2x16-bit channels + 2x16 padding + 4x16 timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s16 chans[2];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 struct am2315_sensor_data {
@@ -167,20 +171,20 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
 
 	mutex_lock(&data->lock);
 	if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) {
-		data->buffer[0] = sensor_data.hum_data;
-		data->buffer[1] = sensor_data.temp_data;
+		data->scan.chans[0] = sensor_data.hum_data;
+		data->scan.chans[1] = sensor_data.temp_data;
 	} else {
 		i = 0;
 		for_each_set_bit(bit, indio_dev->active_scan_mask,
 				 indio_dev->masklength) {
-			data->buffer[i] = (bit ? sensor_data.temp_data :
-						 sensor_data.hum_data);
+			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->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
2.31.1


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

* [PATCH 12/19] iio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (10 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 11/19] iio: humidity: am2315: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 13/19] iio: prox: pulsed-light: " Jonathan Cameron
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Andreas Klinger

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 78f839029e1d ("iio: distance: srf08: add IIO driver for us ranger")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andreas Klinger <ak@it-klinger.de>
---
 drivers/iio/proximity/srf08.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
index 70beac5c9c1d..9b0886760f76 100644
--- a/drivers/iio/proximity/srf08.c
+++ b/drivers/iio/proximity/srf08.c
@@ -63,11 +63,11 @@ struct srf08_data {
 	int			range_mm;
 	struct mutex		lock;
 
-	/*
-	 * triggered buffer
-	 * 1x16-bit channel + 3x16 padding + 4x16 timestamp
-	 */
-	s16			buffer[8];
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s16 chan;
+		s64 timestamp __aligned(8);
+	} scan;
 
 	/* Sensor-Type */
 	enum srf08_sensor_type	sensor_type;
@@ -190,9 +190,9 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p)
 
 	mutex_lock(&data->lock);
 
-	data->buffer[0] = sensor_data;
+	data->scan.chan = sensor_data;
 	iio_push_to_buffers_with_timestamp(indio_dev,
-						data->buffer, pf->timestamp);
+					   &data->scan, pf->timestamp);
 
 	mutex_unlock(&data->lock);
 err:
-- 
2.31.1


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

* [PATCH 13/19] iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (11 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 12/19] iio: prox: srf08: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-06  6:46   ` Matt Ranostay
  2021-05-01 17:01 ` [PATCH 14/19] iio: prox: as3935: " Jonathan Cameron
                   ` (6 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Matt Ranostay

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: cb119d535083 ("iio: proximity: add support for PulsedLight LIDAR")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index c685f10b5ae4..822a68ae5e03 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -44,7 +44,11 @@ struct lidar_data {
 	int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len);
 	int i2c_enabled;
 
-	u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u16 chan;
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 static const struct iio_chan_spec lidar_channels[] = {
@@ -229,9 +233,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
 	struct lidar_data *data = iio_priv(indio_dev);
 	int ret;
 
-	ret = lidar_get_measurement(data, data->buffer);
+	ret = lidar_get_measurement(data, &data->scan.chan);
 	if (!ret) {
-		iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+		iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 						   iio_get_time_ns(indio_dev));
 	} else if (ret != -EINVAL) {
 		dev_err(&data->client->dev, "cannot read LIDAR measurement");
-- 
2.31.1


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

* [PATCH 14/19] iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (12 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 13/19] iio: prox: pulsed-light: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-06  6:45   ` Matt Ranostay
  2021-05-01 17:01 ` [PATCH 15/19] iio: magn: hmc5843: " Jonathan Cameron
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Matt Ranostay

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 37b1ba2c68cf ("iio: proximity: as3935: fix buffer stack trashing")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/proximity/as3935.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index edc4a35ae66d..1d5ace2bde44 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -59,7 +59,11 @@ struct as3935_state {
 	unsigned long noise_tripped;
 	u32 tune_cap;
 	u32 nflwdth_reg;
-	u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u8 chan;
+		s64 timestamp __aligned(8);
+	} scan;
 	u8 buf[2] ____cacheline_aligned;
 };
 
@@ -225,8 +229,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
 	if (ret)
 		goto err_read;
 
-	st->buffer[0] = val & AS3935_DATA_MASK;
-	iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
+	st->scan.chan = val & AS3935_DATA_MASK;
+	iio_push_to_buffers_with_timestamp(indio_dev, &st->scan,
 					   iio_get_time_ns(indio_dev));
 err_read:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
2.31.1


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

* [PATCH 15/19] iio: magn: hmc5843: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (13 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 14/19] iio: prox: as3935: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 7247645f6865 ("iio: hmc5843: Move hmc5843 out of staging")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/magnetometer/hmc5843.h      | 8 ++++++--
 drivers/iio/magnetometer/hmc5843_core.c | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
index 3f6c0b662941..242f742f2643 100644
--- a/drivers/iio/magnetometer/hmc5843.h
+++ b/drivers/iio/magnetometer/hmc5843.h
@@ -33,7 +33,8 @@ enum hmc5843_ids {
  * @lock:		update and read regmap data
  * @regmap:		hardware access register maps
  * @variant:		describe chip variants
- * @buffer:		3x 16-bit channels + padding + 64-bit timestamp
+ * @scan:		buffer to pack data for passing to
+ *			iio_push_to_buffers_with_timestamp()
  */
 struct hmc5843_data {
 	struct device *dev;
@@ -41,7 +42,10 @@ struct hmc5843_data {
 	struct regmap *regmap;
 	const struct hmc5843_chip_info *variant;
 	struct iio_mount_matrix orientation;
-	__be16 buffer[8];
+	struct {
+		__be16 chans[3];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c
index 780faea61d82..221563e0c18f 100644
--- a/drivers/iio/magnetometer/hmc5843_core.c
+++ b/drivers/iio/magnetometer/hmc5843_core.c
@@ -446,13 +446,13 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
 	}
 
 	ret = regmap_bulk_read(data->regmap, HMC5843_DATA_OUT_MSB_REGS,
-			       data->buffer, 3 * sizeof(__be16));
+			       data->scan.chans, sizeof(data->scan.chans));
 
 	mutex_unlock(&data->lock);
 	if (ret < 0)
 		goto done;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   iio_get_time_ns(indio_dev));
 
 done:
-- 
2.31.1


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

* [PATCH 16/19] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (14 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 15/19] iio: magn: hmc5843: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-05 12:57   ` Linus Walleij
  2021-05-13 17:50   ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 17/19] iio: light: isl29125: " Jonathan Cameron
                   ` (3 subsequent siblings)
  19 siblings, 2 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Stephan Gerhold, Linus Walleij

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/magnetometer/bmc150_magn.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
index 00f9766bad5c..dd5f80093a18 100644
--- a/drivers/iio/magnetometer/bmc150_magn.c
+++ b/drivers/iio/magnetometer/bmc150_magn.c
@@ -138,8 +138,11 @@ struct bmc150_magn_data {
 	struct regmap *regmap;
 	struct regulator_bulk_data regulators[2];
 	struct iio_mount_matrix orientation;
-	/* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
-	s32 buffer[6];
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		s32 chans[4];
+		s64 timestamp __aligned(8);
+	} scan;
 	struct iio_trigger *dready_trig;
 	bool dready_trigger_on;
 	int max_odr;
@@ -675,11 +678,11 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
 	int ret;
 
 	mutex_lock(&data->mutex);
-	ret = bmc150_magn_read_xyz(data, data->buffer);
+	ret = bmc150_magn_read_xyz(data, data->scan.chans);
 	if (ret < 0)
 		goto err;
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 					   pf->timestamp);
 
 err:
-- 
2.31.1


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

* [PATCH 17/19] iio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (15 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 18/19] iio: light: tcs3414: " Jonathan Cameron
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 6c25539cbc46 ("iio: Add Intersil isl29125 digital color light sensor driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/isl29125.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index b93b85dbc3a6..ba53b50d711a 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -51,7 +51,11 @@
 struct isl29125_data {
 	struct i2c_client *client;
 	u8 conf1;
-	u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u16 chans[3];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 #define ISL29125_CHANNEL(_color, _si) { \
@@ -184,10 +188,10 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
 		if (ret < 0)
 			goto done;
 
-		data->buffer[j++] = ret;
+		data->scan.chans[j++] = ret;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 		iio_get_time_ns(indio_dev));
 
 done:
-- 
2.31.1


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

* [PATCH 18/19] iio: light: tcs3414: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (16 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 17/19] iio: light: isl29125: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 17:01 ` [PATCH 19/19] iio: light: tcs3472: " Jonathan Cameron
  2021-05-01 19:12 ` [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Andy Shevchenko
  19 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: a244e7b57f0f ("iio: Add driver for AMS/TAOS tcs3414 digital color sensor")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/tcs3414.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
index 6fe5d46f80d4..0593abd600ec 100644
--- a/drivers/iio/light/tcs3414.c
+++ b/drivers/iio/light/tcs3414.c
@@ -53,7 +53,11 @@ struct tcs3414_data {
 	u8 control;
 	u8 gain;
 	u8 timing;
-	u16 buffer[8]; /* 4x 16-bit + 8 bytes timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u16 chans[4];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 #define TCS3414_CHANNEL(_color, _si, _addr) { \
@@ -209,10 +213,10 @@ static irqreturn_t tcs3414_trigger_handler(int irq, void *p)
 		if (ret < 0)
 			goto done;
 
-		data->buffer[j++] = ret;
+		data->scan.chans[j++] = ret;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 		iio_get_time_ns(indio_dev));
 
 done:
-- 
2.31.1


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

* [PATCH 19/19] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (17 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 18/19] iio: light: tcs3414: " Jonathan Cameron
@ 2021-05-01 17:01 ` Jonathan Cameron
  2021-05-01 19:09   ` Andy Shevchenko
  2021-05-01 19:12 ` [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Andy Shevchenko
  19 siblings, 1 reply; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-01 17:01 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes tag is not strictly accurate as prior to that patch there was
potentially an unaligned write.  However, any backport past there will
need to be done manually.

Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/tcs3472.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index a0dc447aeb68..90dc3fef59e6 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -64,7 +64,11 @@ struct tcs3472_data {
 	u8 control;
 	u8 atime;
 	u8 apers;
-	u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */
+	/* Ensure timestamp is naturally aligned */
+	struct {
+		u16 chans[4];
+		s64 timestamp __aligned(8);
+	} scan;
 };
 
 static const struct iio_event_spec tcs3472_events[] = {
@@ -386,10 +390,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
 		if (ret < 0)
 			goto done;
 
-		data->buffer[j++] = ret;
+		data->scan.chans[j++] = ret;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
 		iio_get_time_ns(indio_dev));
 
 done:
-- 
2.31.1


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

* Re: [PATCH 19/19] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 19/19] iio: light: tcs3472: " Jonathan Cameron
@ 2021-05-01 19:09   ` Andy Shevchenko
  0 siblings, 0 replies; 35+ messages in thread
From: Andy Shevchenko @ 2021-05-01 19:09 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron

On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
>
> Found during an audit of all calls of uses of
> iio_push_to_buffers_with_timestamp()

Missed period at the end of the line.

> Fixes tag is not strictly accurate as prior to that patch there was
> potentially an unaligned write.  However, any backport past there will
> need to be done manually.
>
> Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  drivers/iio/light/tcs3472.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
> index a0dc447aeb68..90dc3fef59e6 100644
> --- a/drivers/iio/light/tcs3472.c
> +++ b/drivers/iio/light/tcs3472.c
> @@ -64,7 +64,11 @@ struct tcs3472_data {
>         u8 control;
>         u8 atime;
>         u8 apers;
> -       u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */
> +       /* Ensure timestamp is naturally aligned */
> +       struct {
> +               u16 chans[4];
> +               s64 timestamp __aligned(8);
> +       } scan;
>  };
>
>  static const struct iio_event_spec tcs3472_events[] = {
> @@ -386,10 +390,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
>                 if (ret < 0)
>                         goto done;
>
> -               data->buffer[j++] = ret;
> +               data->scan.chans[j++] = ret;
>         }
>
> -       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>                 iio_get_time_ns(indio_dev));
>
>  done:
> --
> 2.31.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 04/19] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 04/19] iio: accel: kxcjk-1013: " Jonathan Cameron
@ 2021-05-01 19:10   ` Andy Shevchenko
  2021-05-13 17:33     ` Jonathan Cameron
  0 siblings, 1 reply; 35+ messages in thread
From: Andy Shevchenko @ 2021-05-01 19:10 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron, Srinivas Pandruvada

On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
>
> Found during an audit of all calls of this function.
>
> Fixes: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/iio/accel/kxcjk-1013.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> index ff724bc17a45..96ab247f17b3 100644
> --- a/drivers/iio/accel/kxcjk-1013.c
> +++ b/drivers/iio/accel/kxcjk-1013.c
> @@ -133,6 +133,13 @@ enum kx_acpi_type {
>         ACPI_KIOX010A,
>  };
>
> +enum kxcjk1013_axis {
> +       AXIS_X,
> +       AXIS_Y,
> +       AXIS_Z,

> +       AXIS_MAX,

I see that this is from original code, though I think you have a
chance to remove unneeded comma here. Let's make the terminator line
terminate.

> +};
> +
>  struct kxcjk1013_data {
>         struct regulator_bulk_data regulators[2];
>         struct i2c_client *client;
> @@ -140,7 +147,11 @@ struct kxcjk1013_data {
>         struct iio_trigger *motion_trig;
>         struct iio_mount_matrix orientation;
>         struct mutex mutex;
> -       s16 buffer[8];
> +       /* Ensure timestamp naturally aligned */
> +       struct {
> +               s16 chans[AXIS_MAX];
> +               s64 timestamp __aligned(8);
> +       } scan;
>         u8 odr_bits;
>         u8 range;
>         int wake_thres;
> @@ -154,13 +165,6 @@ struct kxcjk1013_data {
>         enum kx_acpi_type acpi_type;
>  };
>
> -enum kxcjk1013_axis {
> -       AXIS_X,
> -       AXIS_Y,
> -       AXIS_Z,
> -       AXIS_MAX,
> -};
> -
>  enum kxcjk1013_mode {
>         STANDBY,
>         OPERATION,
> @@ -1094,12 +1098,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
>         ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
>                                                         KXCJK1013_REG_XOUT_L,
>                                                         AXIS_MAX * 2,
> -                                                       (u8 *)data->buffer);
> +                                                       (u8 *)data->scan.chans);
>         mutex_unlock(&data->mutex);
>         if (ret < 0)
>                 goto err;
>
> -       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>                                            data->timestamp);
>  err:
>         iio_trigger_notify_done(indio_dev->trig);
> --
> 2.31.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment
  2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
                   ` (18 preceding siblings ...)
  2021-05-01 17:01 ` [PATCH 19/19] iio: light: tcs3472: " Jonathan Cameron
@ 2021-05-01 19:12 ` Andy Shevchenko
  2021-05-13 17:54   ` Jonathan Cameron
  19 siblings, 1 reply; 35+ messages in thread
From: Andy Shevchenko @ 2021-05-01 19:12 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Jonathan Cameron, Peter Meerwald, Andy Shevchenko,
	Srinivas Pandruvada, Daniel Baluta, Stefan-Gabriel Mirea,
	Sanchayan Maity, Stephan Gerhold, Andreas Klinger, Matt Ranostay,
	Linus Walleij

On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> I finally got around to do a manual audit of all the calls to
> iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
> of:
> 1. 8 byte alignment of the provided buffer.
> 2. space for an 8 byte naturally aligned timestamp to be inserted at the
>    end.
>
> Unfortuantely there were rather a lot of these left, but time to bite the bullet

Unfortunately

> and clean them up.
>
> As discussed previous in
> https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
> it is not easy to fix the alignment issue without requiring a bounce buffer
> (see part 4 of the alignment fixes for a proposal for that where it is
> absolutely necessary).
>
> Part 2 is the simple cases where the timestamp position is always the same
> (as not more than 8 bytes of other scan elements) and where it is either
> in a structure that is kzalloc'd or there was already an explicit memset
> that would clear any holes in the structure (and hence avoid a potential
> kernel data leak).
>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>

> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

1

> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Daniel Baluta <daniel.baluta@nxp.com>

> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

2

One time is enough :-)

Anyway, I looked at them all and haven't seen any issues on the first glance, so
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
> Cc: Sanchayan Maity <maitysanchayan@gmail.com>
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: Andreas Klinger <ak@it-klinger.de>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
>
> Jonathan Cameron (19):
>   iio: accel: bma180: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: accel: bma220: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: accel: hid: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: accel: kxcjk-1013: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: accel: mxc4005: Fix overread of data and alignment issue.
>   iio: accel: stk8312: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: accel: stk8ba50: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: adc: ti-ads1015: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: adc: vf610: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: gyro: bmg160: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: humidity: am2315: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: prox: srf08: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: prox: pulsed-light: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: prox: as3935: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: magn: hmc5843: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: magn: bmc150: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: light: isl29125: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: light: tcs3414: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>   iio: light: tcs3472: Fix buffer alignment in
>     iio_push_to_buffers_with_timestamp()
>
>  drivers/iio/accel/bma180.c                    | 10 +++++---
>  drivers/iio/accel/bma220_spi.c                | 10 +++++---
>  drivers/iio/accel/hid-sensor-accel-3d.c       | 13 ++++++----
>  drivers/iio/accel/kxcjk-1013.c                | 24 +++++++++++--------
>  drivers/iio/accel/mxc4005.c                   | 10 +++++---
>  drivers/iio/accel/stk8312.c                   | 12 ++++++----
>  drivers/iio/accel/stk8ba50.c                  | 17 +++++++------
>  drivers/iio/adc/ti-ads1015.c                  | 12 ++++++----
>  drivers/iio/adc/vf610_adc.c                   | 10 +++++---
>  drivers/iio/gyro/bmg160_core.c                | 10 +++++---
>  drivers/iio/humidity/am2315.c                 | 16 ++++++++-----
>  drivers/iio/light/isl29125.c                  | 10 +++++---
>  drivers/iio/light/tcs3414.c                   | 10 +++++---
>  drivers/iio/light/tcs3472.c                   | 10 +++++---
>  drivers/iio/magnetometer/bmc150_magn.c        | 11 +++++----
>  drivers/iio/magnetometer/hmc5843.h            |  8 +++++--
>  drivers/iio/magnetometer/hmc5843_core.c       |  4 ++--
>  drivers/iio/proximity/as3935.c                | 10 +++++---
>  .../iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++---
>  drivers/iio/proximity/srf08.c                 | 14 +++++------
>  20 files changed, 148 insertions(+), 83 deletions(-)
>
> --
> 2.31.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 16/19] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
@ 2021-05-05 12:57   ` Linus Walleij
  2021-05-07  9:23     ` Jonathan Cameron
  2021-05-13 17:50   ` Jonathan Cameron
  1 sibling, 1 reply; 35+ messages in thread
From: Linus Walleij @ 2021-05-05 12:57 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron, Stephan Gerhold

On Sat, May 1, 2021 at 7:03 PM Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
>
> Found during an audit of all calls of uses of
> iio_push_to_buffers_with_timestamp()
>
> Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Excellent work Jonathan.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I wonder if there is some way for us to abstract this into the core so
we can't get it wrong.

Yours,
Linus Walleij

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

* Re: [PATCH 14/19] iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 14/19] iio: prox: as3935: " Jonathan Cameron
@ 2021-05-06  6:45   ` Matt Ranostay
  0 siblings, 0 replies; 35+ messages in thread
From: Matt Ranostay @ 2021-05-06  6:45 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: open list:IIO SUBSYSTEM AND DRIVERS, Jonathan Cameron

On Sat, May 1, 2021 at 10:03 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
>
> Found during an audit of all calls of uses of
> iio_push_to_buffers_with_timestamp()
>
> Fixes: 37b1ba2c68cf ("iio: proximity: as3935: fix buffer stack trashing")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/proximity/as3935.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index edc4a35ae66d..1d5ace2bde44 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -59,7 +59,11 @@ struct as3935_state {
>         unsigned long noise_tripped;
>         u32 tune_cap;
>         u32 nflwdth_reg;
> -       u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */
> +       /* Ensure timestamp is naturally aligned */
> +       struct {
> +               u8 chan;
> +               s64 timestamp __aligned(8);
> +       } scan;
>         u8 buf[2] ____cacheline_aligned;
>  };
>
> @@ -225,8 +229,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
>         if (ret)
>                 goto err_read;
>
> -       st->buffer[0] = val & AS3935_DATA_MASK;
> -       iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
> +       st->scan.chan = val & AS3935_DATA_MASK;
> +       iio_push_to_buffers_with_timestamp(indio_dev, &st->scan,
>                                            iio_get_time_ns(indio_dev));
>  err_read:
>         iio_trigger_notify_done(indio_dev->trig);
> --
> 2.31.1
>

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

* Re: [PATCH 13/19] iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 13/19] iio: prox: pulsed-light: " Jonathan Cameron
@ 2021-05-06  6:46   ` Matt Ranostay
  0 siblings, 0 replies; 35+ messages in thread
From: Matt Ranostay @ 2021-05-06  6:46 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: open list:IIO SUBSYSTEM AND DRIVERS, Jonathan Cameron

On Sat, May 1, 2021 at 10:03 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
>
> Found during an audit of all calls of uses of
> iio_push_to_buffers_with_timestamp()
>
> Fixes: cb119d535083 ("iio: proximity: add support for PulsedLight LIDAR")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> index c685f10b5ae4..822a68ae5e03 100644
> --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> @@ -44,7 +44,11 @@ struct lidar_data {
>         int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len);
>         int i2c_enabled;
>
> -       u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */
> +       /* Ensure timestamp is naturally aligned */
> +       struct {
> +               u16 chan;
> +               s64 timestamp __aligned(8);
> +       } scan;
>  };
>
>  static const struct iio_chan_spec lidar_channels[] = {
> @@ -229,9 +233,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
>         struct lidar_data *data = iio_priv(indio_dev);
>         int ret;
>
> -       ret = lidar_get_measurement(data, data->buffer);
> +       ret = lidar_get_measurement(data, &data->scan.chan);
>         if (!ret) {
> -               iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +               iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>                                                    iio_get_time_ns(indio_dev));
>         } else if (ret != -EINVAL) {
>                 dev_err(&data->client->dev, "cannot read LIDAR measurement");
> --
> 2.31.1
>

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

* Re: [PATCH 16/19] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-05 12:57   ` Linus Walleij
@ 2021-05-07  9:23     ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-07  9:23 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jonathan Cameron, linux-iio, Stephan Gerhold

On Wed, 5 May 2021 14:57:12 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:

> On Sat, May 1, 2021 at 7:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > To make code more readable, use a structure to express the channel
> > layout and ensure the timestamp is 8 byte aligned.
> >
> > Found during an audit of all calls of uses of
> > iio_push_to_buffers_with_timestamp()
> >
> > Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Stephan Gerhold <stephan@gerhold.net>
> > Cc: Linus Walleij <linus.walleij@linaro.org>  
> 
> Excellent work Jonathan.
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> I wonder if there is some way for us to abstract this into the core so
> we can't get it wrong.

Abstracting is a bit of a pain, because we end up creating unnecessary
limitations on what can be done.  Often having buffer a lot larger than
it needs to be is sensible for example...

However, I'm definitely thinking we should look at what checks we can
add once all these cases are fixed and there might be a nice
pattern to use for those cases where we currently have a bounce buffer
anyway due to hardware restrictions.  In most others, moving to the pattern
where the timestamp is explicit in the structure makes it obvious (subject
to the fun question of x86_32 alignment and whether that matters - we don't
know of any bugs as a result but it's possible some buffer consumer will assume
8 byte alignment - hence the hardening in these cases).

The size being too small case for example should be easy - we just augment
iio_push_to_buffers_with_timestamp() to take the size and check it against
scan_bytes.  Alignment is trickier... 

Jonathan


> Yours,
> Linus Walleij


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

* Re: [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
@ 2021-05-13 17:22   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:22 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Peter Meerwald

On Sat,  1 May 2021 18:01:03 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
> 
> Found during an audit of all calls of this function.
> 
> Fixes: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>

Applied to the togreg branch of iio.git with a minor fix.

Note I'm taking these the slow way and nor marking them for stable
as they've been there a very long time.

> ---
>  drivers/iio/accel/bma180.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index b8a7469cdae4..2e901f900ea7 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -162,7 +162,11 @@ struct bma180_data {
>  	int scale;
>  	int bw;
>  	bool pmode;
> -	u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */
> +	/* Ensure timestamp is naturally aligned */
> +	struct {
> +		s16 chan[3];
The 8 bit in the comment above is misleading, but made me take another
look at this.   There are actually 4 channels on some devices, the last
of which (temp) is 8 bits in a 16bit field. 

I changed this to be s16 chan[4] to reflect that.

Thanks,

Jonathan

> +		s64 timestamp __aligned(8);
> +	} scan;
>  };
>  
>  enum bma180_chan {
> @@ -938,12 +942,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
>  			mutex_unlock(&data->mutex);
>  			goto err;
>  		}
> -		((s16 *)data->buff)[i++] = ret;
> +		data->scan.chan[i++] = ret;
>  	}
>  
>  	mutex_unlock(&data->mutex);
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
> +	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns);
>  err:
>  	iio_trigger_notify_done(indio_dev->trig);
>  


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

* Re: [PATCH 02/19] iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 02/19] iio: accel: bma220: " Jonathan Cameron
@ 2021-05-13 17:26   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:26 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Andy Shevchenko

On Sat,  1 May 2021 18:01:04 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
> 
> Found during an audit of all calls of this function.
~Gah. Clearly wasn't on my best form when I originally wrote these.
Number of chans in this one is wrong as well.  Fixed to 3 as per the
comment that got dropped because it should have been obvious.

As you might imagine, the error in patch 1 made me look closer at
the rest of these whilst applying.
> 
> Fixes: 194dc4c71413 ("iio: accel: Add triggered buffer support for BMA220")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to poke at.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/bma220_spi.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
> index 36fc9876dbca..2802ce1852ef 100644
> --- a/drivers/iio/accel/bma220_spi.c
> +++ b/drivers/iio/accel/bma220_spi.c
> @@ -63,7 +63,11 @@ static const int bma220_scale_table[][2] = {
>  struct bma220_data {
>  	struct spi_device *spi_device;
>  	struct mutex lock;
> -	s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 8x8 timestamp */
> +	struct {
> +		s8 chans[2];
> +		/* Ensure timestamp is naturally aligned. */
> +		s64 timestamp __aligned(8);
> +	} scan;
>  	u8 tx_buf[2] ____cacheline_aligned;
>  };
>  
> @@ -94,12 +98,12 @@ static irqreturn_t bma220_trigger_handler(int irq, void *p)
>  
>  	mutex_lock(&data->lock);
>  	data->tx_buf[0] = BMA220_REG_ACCEL_X | BMA220_READ_MASK;
> -	ret = spi_write_then_read(spi, data->tx_buf, 1, data->buffer,
> +	ret = spi_write_then_read(spi, data->tx_buf, 1, &data->scan.chans,
>  				  ARRAY_SIZE(bma220_channels) - 1);
>  	if (ret < 0)
>  		goto err;
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>  					   pf->timestamp);
>  err:
>  	mutex_unlock(&data->lock);


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

* Re: [PATCH 03/19] iio: accel: hid: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 03/19] iio: accel: hid: " Jonathan Cameron
@ 2021-05-13 17:28   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:28 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Srinivas Pandruvada

On Sat,  1 May 2021 18:01:05 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
> Note this matches what was done in all the other hid sensor drivers.
> This one was missed previously due to an extra level of indirection.
> 
> Found during an audit of all calls of this function.
> 
> Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to poke at.

Thanks,

Jonathan
> ---
>  drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 2f9465cb382f..27f47e1c251e 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -28,8 +28,11 @@ struct accel_3d_state {
>  	struct hid_sensor_hub_callbacks callbacks;
>  	struct hid_sensor_common common_attributes;
>  	struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX];
> -	/* Reserve for 3 channels + padding + timestamp */
> -	u32 accel_val[ACCEL_3D_CHANNEL_MAX + 3];
> +	/* Ensure timestamp is naturally aligned */
> +	struct {
> +		u32 accel_val[3];
> +		s64 timestamp __aligned(8);
> +	} scan;
>  	int scale_pre_decml;
>  	int scale_post_decml;
>  	int scale_precision;
> @@ -245,8 +248,8 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
>  			accel_state->timestamp = iio_get_time_ns(indio_dev);
>  
>  		hid_sensor_push_data(indio_dev,
> -				     accel_state->accel_val,
> -				     sizeof(accel_state->accel_val),
> +				     &accel_state->scan,
> +				     sizeof(accel_state->scan),
>  				     accel_state->timestamp);
>  
>  		accel_state->timestamp = 0;
> @@ -271,7 +274,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
>  	case HID_USAGE_SENSOR_ACCEL_Y_AXIS:
>  	case HID_USAGE_SENSOR_ACCEL_Z_AXIS:
>  		offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS;
> -		accel_state->accel_val[CHANNEL_SCAN_INDEX_X + offset] =
> +		accel_state->scan.accel_val[CHANNEL_SCAN_INDEX_X + offset] =
>  						*(u32 *)raw_data;
>  		ret = 0;
>  	break;


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

* Re: [PATCH 04/19] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 19:10   ` Andy Shevchenko
@ 2021-05-13 17:33     ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Srinivas Pandruvada,
	Stephan Gerhold, Michał Mirosław, Hans de Goede

On Sat, 1 May 2021 22:10:48 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > To make code more readable, use a structure to express the channel
> > layout and ensure the timestamp is 8 byte aligned.
> >
> > Found during an audit of all calls of this function.
> >
> > Fixes: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > ---
> >  drivers/iio/accel/kxcjk-1013.c | 24 ++++++++++++++----------
> >  1 file changed, 14 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> > index ff724bc17a45..96ab247f17b3 100644
> > --- a/drivers/iio/accel/kxcjk-1013.c
> > +++ b/drivers/iio/accel/kxcjk-1013.c
> > @@ -133,6 +133,13 @@ enum kx_acpi_type {
> >         ACPI_KIOX010A,
> >  };
> >
> > +enum kxcjk1013_axis {
> > +       AXIS_X,
> > +       AXIS_Y,
> > +       AXIS_Z,  
> 
> > +       AXIS_MAX,  
> 
> I see that this is from original code, though I think you have a
> chance to remove unneeded comma here. Let's make the terminator line
> terminate.

Good idea.  Did that whilst applying.  This one had a lot of fuzz
due to support of new parts added to the driver in the meantime, but
the patch seems to have applied cleanly.

+CC various people involved in that series so they know this change
is going in as well (and can perhaps give it a spin!:)

Thanks,

Jonathan

> 
> > +};
> > +
> >  struct kxcjk1013_data {
> >         struct regulator_bulk_data regulators[2];
> >         struct i2c_client *client;
> > @@ -140,7 +147,11 @@ struct kxcjk1013_data {
> >         struct iio_trigger *motion_trig;
> >         struct iio_mount_matrix orientation;
> >         struct mutex mutex;
> > -       s16 buffer[8];
> > +       /* Ensure timestamp naturally aligned */
> > +       struct {
> > +               s16 chans[AXIS_MAX];
> > +               s64 timestamp __aligned(8);
> > +       } scan;
> >         u8 odr_bits;
> >         u8 range;
> >         int wake_thres;
> > @@ -154,13 +165,6 @@ struct kxcjk1013_data {
> >         enum kx_acpi_type acpi_type;
> >  };
> >
> > -enum kxcjk1013_axis {
> > -       AXIS_X,
> > -       AXIS_Y,
> > -       AXIS_Z,
> > -       AXIS_MAX,
> > -};
> > -
> >  enum kxcjk1013_mode {
> >         STANDBY,
> >         OPERATION,
> > @@ -1094,12 +1098,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
> >         ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
> >                                                         KXCJK1013_REG_XOUT_L,
> >                                                         AXIS_MAX * 2,
> > -                                                       (u8 *)data->buffer);
> > +                                                       (u8 *)data->scan.chans);
> >         mutex_unlock(&data->mutex);
> >         if (ret < 0)
> >                 goto err;
> >
> > -       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> > +       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
> >                                            data->timestamp);
> >  err:
> >         iio_trigger_notify_done(indio_dev->trig);
> > --
> > 2.31.1
> >  
> 
> 


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

* Re: [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue.
  2021-05-01 17:01 ` [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue Jonathan Cameron
@ 2021-05-13 17:37   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:37 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

On Sat,  1 May 2021 18:01:07 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> The bulk read size is based on the size of an array that also has
> space for the timestamp alongside the channels.
> Fix that and also fix alignment of the buffer passed
> to iio_push_to_buffers_with_timestamp.
> 
> Found during an audit of all calls to this function.
> 
> Fixes: 1ce0eda0f757 ("iio: mxc4005: add triggered buffer mode for mxc4005")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to see if they can find anything.  Minor tweak to enforce the
8 byte alignment as done in other drivers.
> ---
>  drivers/iio/accel/mxc4005.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
> index fb3cbaa62bd8..9e6066c6a2df 100644
> --- a/drivers/iio/accel/mxc4005.c
> +++ b/drivers/iio/accel/mxc4005.c
> @@ -56,7 +56,11 @@ struct mxc4005_data {
>  	struct mutex mutex;
>  	struct regmap *regmap;
>  	struct iio_trigger *dready_trig;
> -	__be16 buffer[8];
> +	/* Ensure timestamp is naturally aligned */
> +	struct {
> +		__be16 chans[3];
> +		s64 timestamp;
Added __aligned(8) here to be consistent and ensure natural alignment.

> +	} scan;
>  	bool trigger_enabled;
>  };
>  
> @@ -135,7 +139,7 @@ static int mxc4005_read_xyz(struct mxc4005_data *data)
>  	int ret;
>  
>  	ret = regmap_bulk_read(data->regmap, MXC4005_REG_XOUT_UPPER,
> -			       data->buffer, sizeof(data->buffer));
> +			       data->scan.chans, sizeof(data->scan.chans));
>  	if (ret < 0) {
>  		dev_err(data->dev, "failed to read axes\n");
>  		return ret;
> @@ -301,7 +305,7 @@ static irqreturn_t mxc4005_trigger_handler(int irq, void *private)
>  	if (ret < 0)
>  		goto err;
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>  					   pf->timestamp);
>  
>  err:


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

* Re: [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
@ 2021-05-13 17:39   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:39 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

On Sat,  1 May 2021 18:01:08 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
> 
> Found during an audit of all calls of this function.
> 
> Fixes: 95c12bba51c3 ("iio: accel: Add buffer mode for Sensortek STK8312")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Also missing the __aligned(8) for the timestamp.  Added it.

thanks,

Jonathan

> ---
>  drivers/iio/accel/stk8312.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
> index 157d8faefb9e..c8b6915a757c 100644
> --- a/drivers/iio/accel/stk8312.c
> +++ b/drivers/iio/accel/stk8312.c
> @@ -103,7 +103,11 @@ struct stk8312_data {
>  	u8 mode;
>  	struct iio_trigger *dready_trig;
>  	bool dready_trigger_on;
> -	s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */
> +	/* Ensure timestamp is naturally aligned */
> +	struct {
> +		s8 chans[3];
> +		s64 timestamp;
> +	} scan;
>  };
>  
>  static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
> @@ -438,7 +442,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
>  		ret = i2c_smbus_read_i2c_block_data(data->client,
>  						    STK8312_REG_XOUT,
>  						    STK8312_ALL_CHANNEL_SIZE,
> -						    data->buffer);
> +						    data->scan.chans);
>  		if (ret < STK8312_ALL_CHANNEL_SIZE) {
>  			dev_err(&data->client->dev, "register read failed\n");
>  			mutex_unlock(&data->lock);
> @@ -452,12 +456,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
>  				mutex_unlock(&data->lock);
>  				goto err;
>  			}
> -			data->buffer[i++] = ret;
> +			data->scan.chans[i++] = ret;
>  		}
>  	}
>  	mutex_unlock(&data->lock);
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>  					   pf->timestamp);
>  err:
>  	iio_trigger_notify_done(indio_dev->trig);


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

* Re: [PATCH 16/19] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
  2021-05-05 12:57   ` Linus Walleij
@ 2021-05-13 17:50   ` Jonathan Cameron
  1 sibling, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:50 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Stephan Gerhold, Linus Walleij

On Sat,  1 May 2021 18:01:18 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> To make code more readable, use a structure to express the channel
> layout and ensure the timestamp is 8 byte aligned.
> 
> Found during an audit of all calls of uses of
> iio_push_to_buffers_with_timestamp()
> 
> Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Applied, but with a tiny tweak to make this more obviously correct.

> ---
>  drivers/iio/magnetometer/bmc150_magn.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
> index 00f9766bad5c..dd5f80093a18 100644
> --- a/drivers/iio/magnetometer/bmc150_magn.c
> +++ b/drivers/iio/magnetometer/bmc150_magn.c
> @@ -138,8 +138,11 @@ struct bmc150_magn_data {
>  	struct regmap *regmap;
>  	struct regulator_bulk_data regulators[2];
>  	struct iio_mount_matrix orientation;
> -	/* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
> -	s32 buffer[6];
> +	/* Ensure timestamp is naturally aligned */
> +	struct {
> +		s32 chans[4];
The whole point of the structure is to enforce the alignment without needing
to specify padding.   There are only 3 actual chans, so I've reduced this to
s32 chans[3]

Result is exactly the same in practice, but it's more readable.

Thanks,

Jonathan

> +		s64 timestamp __aligned(8);
> +	} scan;
>  	struct iio_trigger *dready_trig;
>  	bool dready_trigger_on;
>  	int max_odr;
> @@ -675,11 +678,11 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
>  	int ret;
>  
>  	mutex_lock(&data->mutex);
> -	ret = bmc150_magn_read_xyz(data, data->buffer);
> +	ret = bmc150_magn_read_xyz(data, data->scan.chans);
>  	if (ret < 0)
>  		goto err;
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +	iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
>  					   pf->timestamp);
>  
>  err:


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

* Re: [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment
  2021-05-01 19:12 ` [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Andy Shevchenko
@ 2021-05-13 17:54   ` Jonathan Cameron
  0 siblings, 0 replies; 35+ messages in thread
From: Jonathan Cameron @ 2021-05-13 17:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Peter Meerwald, Andy Shevchenko,
	Srinivas Pandruvada, Daniel Baluta, Stefan-Gabriel Mirea,
	Sanchayan Maity, Stephan Gerhold, Andreas Klinger, Matt Ranostay,
	Linus Walleij

On Sat, 1 May 2021 22:12:40 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > I finally got around to do a manual audit of all the calls to
> > iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
> > of:
> > 1. 8 byte alignment of the provided buffer.
> > 2. space for an 8 byte naturally aligned timestamp to be inserted at the
> >    end.
> >
> > Unfortuantely there were rather a lot of these left, but time to bite the bullet  
> 
> Unfortunately
> 
> > and clean them up.
> >
> > As discussed previous in
> > https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
> > it is not easy to fix the alignment issue without requiring a bounce buffer
> > (see part 4 of the alignment fixes for a proposal for that where it is
> > absolutely necessary).
> >
> > Part 2 is the simple cases where the timestamp position is always the same
> > (as not more than 8 bytes of other scan elements) and where it is either
> > in a structure that is kzalloc'd or there was already an explicit memset
> > that would clear any holes in the structure (and hence avoid a potential
> > kernel data leak).
> >
> > Cc: Peter Meerwald <pmeerw@pmeerw.net>  
> 
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>  
> 
> 1
> 
> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > Cc: Daniel Baluta <daniel.baluta@nxp.com>  
> 
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>  
> 
> 2
> 
> One time is enough :-)
> 
> Anyway, I looked at them all and haven't seen any issues on the first glance, so
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Thanks.  Whole series applied though seems I was being more than a bit careless
in some of the early ones so I took a very close look at all them whilst applying.

Do too many similar patches, and mistakes slip in :(

Thanks,

Jonathan

> 
> > Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
> > Cc: Sanchayan Maity <maitysanchayan@gmail.com>
> > Cc: Stephan Gerhold <stephan@gerhold.net>
> > Cc: Andreas Klinger <ak@it-klinger.de>
> > Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> >
> > Jonathan Cameron (19):
> >   iio: accel: bma180: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: accel: bma220: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: accel: hid: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: accel: kxcjk-1013: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: accel: mxc4005: Fix overread of data and alignment issue.
> >   iio: accel: stk8312: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: accel: stk8ba50: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: adc: ti-ads1015: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: adc: vf610: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: gyro: bmg160: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: humidity: am2315: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: prox: srf08: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: prox: pulsed-light: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: prox: as3935: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: magn: hmc5843: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: magn: bmc150: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: light: isl29125: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: light: tcs3414: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >   iio: light: tcs3472: Fix buffer alignment in
> >     iio_push_to_buffers_with_timestamp()
> >
> >  drivers/iio/accel/bma180.c                    | 10 +++++---
> >  drivers/iio/accel/bma220_spi.c                | 10 +++++---
> >  drivers/iio/accel/hid-sensor-accel-3d.c       | 13 ++++++----
> >  drivers/iio/accel/kxcjk-1013.c                | 24 +++++++++++--------
> >  drivers/iio/accel/mxc4005.c                   | 10 +++++---
> >  drivers/iio/accel/stk8312.c                   | 12 ++++++----
> >  drivers/iio/accel/stk8ba50.c                  | 17 +++++++------
> >  drivers/iio/adc/ti-ads1015.c                  | 12 ++++++----
> >  drivers/iio/adc/vf610_adc.c                   | 10 +++++---
> >  drivers/iio/gyro/bmg160_core.c                | 10 +++++---
> >  drivers/iio/humidity/am2315.c                 | 16 ++++++++-----
> >  drivers/iio/light/isl29125.c                  | 10 +++++---
> >  drivers/iio/light/tcs3414.c                   | 10 +++++---
> >  drivers/iio/light/tcs3472.c                   | 10 +++++---
> >  drivers/iio/magnetometer/bmc150_magn.c        | 11 +++++----
> >  drivers/iio/magnetometer/hmc5843.h            |  8 +++++--
> >  drivers/iio/magnetometer/hmc5843_core.c       |  4 ++--
> >  drivers/iio/proximity/as3935.c                | 10 +++++---
> >  .../iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++---
> >  drivers/iio/proximity/srf08.c                 | 14 +++++------
> >  20 files changed, 148 insertions(+), 83 deletions(-)
> >
> > --
> > 2.31.1
> >  
> 
> 


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

end of thread, other threads:[~2021-05-13 17:53 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
2021-05-13 17:22   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 02/19] iio: accel: bma220: " Jonathan Cameron
2021-05-13 17:26   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 03/19] iio: accel: hid: " Jonathan Cameron
2021-05-13 17:28   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 04/19] iio: accel: kxcjk-1013: " Jonathan Cameron
2021-05-01 19:10   ` Andy Shevchenko
2021-05-13 17:33     ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue Jonathan Cameron
2021-05-13 17:37   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
2021-05-13 17:39   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 07/19] iio: accel: stk8ba50: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 08/19] iio: adc: ti-ads1015: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 09/19] iio: adc: vf610: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 10/19] iio: gyro: bmg160: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 11/19] iio: humidity: am2315: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 12/19] iio: prox: srf08: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 13/19] iio: prox: pulsed-light: " Jonathan Cameron
2021-05-06  6:46   ` Matt Ranostay
2021-05-01 17:01 ` [PATCH 14/19] iio: prox: as3935: " Jonathan Cameron
2021-05-06  6:45   ` Matt Ranostay
2021-05-01 17:01 ` [PATCH 15/19] iio: magn: hmc5843: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
2021-05-05 12:57   ` Linus Walleij
2021-05-07  9:23     ` Jonathan Cameron
2021-05-13 17:50   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 17/19] iio: light: isl29125: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 18/19] iio: light: tcs3414: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 19/19] iio: light: tcs3472: " Jonathan Cameron
2021-05-01 19:09   ` Andy Shevchenko
2021-05-01 19:12 ` [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Andy Shevchenko
2021-05-13 17:54   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).