Commit 01b9cb0d authored by Daniel Campello's avatar Daniel Campello Committed by Jonathan Cameron

iio: sx9310: Fixes various memory handling

Makes use __aligned(8) to ensure that the timestamp is correctly aligned
when we call io_push_to_buffers_with_timestamp().
Also makes use of sizeof() for regmap_bulk_read instead of static value.
Signed-off-by: default avatarDaniel Campello <campello@chromium.org>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 9b2cac94
...@@ -132,8 +132,11 @@ struct sx9310_data { ...@@ -132,8 +132,11 @@ struct sx9310_data {
*/ */
bool prox_stat[SX9310_NUM_CHANNELS]; bool prox_stat[SX9310_NUM_CHANNELS];
bool trigger_enabled; bool trigger_enabled;
__be16 buffer[SX9310_NUM_CHANNELS + /* Ensure correct alignment of timestamp when present. */
4]; /* 64-bit data + 64-bit timestamp */ struct {
__be16 channels[SX9310_NUM_CHANNELS];
s64 ts __aligned(8);
} buffer;
/* Remember enabled channels and sample rate during suspend. */ /* Remember enabled channels and sample rate during suspend. */
unsigned int suspend_ctrl0; unsigned int suspend_ctrl0;
struct completion completion; struct completion completion;
...@@ -344,7 +347,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data, ...@@ -344,7 +347,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data,
if (ret < 0) if (ret < 0)
return ret; return ret;
return regmap_bulk_read(data->regmap, chan->address, val, 2); return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val));
} }
/* /*
...@@ -694,10 +697,10 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) ...@@ -694,10 +697,10 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private)
if (ret < 0) if (ret < 0)
goto out; goto out;
data->buffer[i++] = val; data->buffer.channels[i++] = val;
} }
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
pf->timestamp); pf->timestamp);
out: out:
......
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