Commit fc36da31 authored by Jonathan Cameron's avatar Jonathan Cameron

iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

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: b9a6a237 ("iio:bma180: Drop _update_scan_mode()")
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-2-jic23@kernel.org
parent 5937b860
...@@ -162,7 +162,11 @@ struct bma180_data { ...@@ -162,7 +162,11 @@ struct bma180_data {
int scale; int scale;
int bw; int bw;
bool pmode; bool pmode;
u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */ /* Ensure timestamp is naturally aligned */
struct {
s16 chan[4];
s64 timestamp __aligned(8);
} scan;
}; };
enum bma180_chan { enum bma180_chan {
...@@ -938,12 +942,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) ...@@ -938,12 +942,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
goto err; goto err;
} }
((s16 *)data->buff)[i++] = ret; data->scan.chan[i++] = ret;
} }
mutex_unlock(&data->mutex); 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: err:
iio_trigger_notify_done(indio_dev->trig); iio_trigger_notify_done(indio_dev->trig);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment