On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote: > > From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > > 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@xxxxxxxxxx> > Cc: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx> > --- > 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