iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
[ Upstream commit 3ab3aa2e7bd57497f9a7c6275c00dce237d2c9ba ]
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: 1a4fbf6a92
("iio: accel: kxcjk1013 3-axis accelerometer driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-5-jic23@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
9eb5fb66b6
commit
0d220d40b3
@@ -132,13 +132,24 @@ enum kx_acpi_type {
|
|||||||
ACPI_KIOX010A,
|
ACPI_KIOX010A,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum kxcjk1013_axis {
|
||||||
|
AXIS_X,
|
||||||
|
AXIS_Y,
|
||||||
|
AXIS_Z,
|
||||||
|
AXIS_MAX
|
||||||
|
};
|
||||||
|
|
||||||
struct kxcjk1013_data {
|
struct kxcjk1013_data {
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
struct iio_trigger *dready_trig;
|
struct iio_trigger *dready_trig;
|
||||||
struct iio_trigger *motion_trig;
|
struct iio_trigger *motion_trig;
|
||||||
struct iio_mount_matrix orientation;
|
struct iio_mount_matrix orientation;
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
s16 buffer[8];
|
/* Ensure timestamp naturally aligned */
|
||||||
|
struct {
|
||||||
|
s16 chans[AXIS_MAX];
|
||||||
|
s64 timestamp __aligned(8);
|
||||||
|
} scan;
|
||||||
u8 odr_bits;
|
u8 odr_bits;
|
||||||
u8 range;
|
u8 range;
|
||||||
int wake_thres;
|
int wake_thres;
|
||||||
@@ -152,13 +163,6 @@ struct kxcjk1013_data {
|
|||||||
enum kx_acpi_type acpi_type;
|
enum kx_acpi_type acpi_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum kxcjk1013_axis {
|
|
||||||
AXIS_X,
|
|
||||||
AXIS_Y,
|
|
||||||
AXIS_Z,
|
|
||||||
AXIS_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum kxcjk1013_mode {
|
enum kxcjk1013_mode {
|
||||||
STANDBY,
|
STANDBY,
|
||||||
OPERATION,
|
OPERATION,
|
||||||
@@ -1092,12 +1096,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
|
|||||||
ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
|
ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
|
||||||
KXCJK1013_REG_XOUT_L,
|
KXCJK1013_REG_XOUT_L,
|
||||||
AXIS_MAX * 2,
|
AXIS_MAX * 2,
|
||||||
(u8 *)data->buffer);
|
(u8 *)data->scan.chans);
|
||||||
mutex_unlock(&data->mutex);
|
mutex_unlock(&data->mutex);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
|
iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
|
||||||
data->timestamp);
|
data->timestamp);
|
||||||
err:
|
err:
|
||||||
iio_trigger_notify_done(indio_dev->trig);
|
iio_trigger_notify_done(indio_dev->trig);
|
||||||
|
Reference in New Issue
Block a user