iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
[ Upstream commit 7692088f72865c41b6b531fd09486ee99a5da930 ]
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: c91746a236
("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>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-17-jic23@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e5e102f4b5
commit
f960139a3c
@@ -136,8 +136,11 @@ struct bmc150_magn_data {
|
|||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct iio_mount_matrix orientation;
|
struct iio_mount_matrix orientation;
|
||||||
/* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
|
/* Ensure timestamp is naturally aligned */
|
||||||
s32 buffer[6];
|
struct {
|
||||||
|
s32 chans[3];
|
||||||
|
s64 timestamp __aligned(8);
|
||||||
|
} scan;
|
||||||
struct iio_trigger *dready_trig;
|
struct iio_trigger *dready_trig;
|
||||||
bool dready_trigger_on;
|
bool dready_trigger_on;
|
||||||
int max_odr;
|
int max_odr;
|
||||||
@@ -673,11 +676,11 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&data->mutex);
|
mutex_lock(&data->mutex);
|
||||||
ret = bmc150_magn_read_xyz(data, data->buffer);
|
ret = bmc150_magn_read_xyz(data, data->scan.chans);
|
||||||
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,
|
||||||
pf->timestamp);
|
pf->timestamp);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
Reference in New Issue
Block a user