Skip to content

Commit 293b824

Browse files
Jonathan Camerongregkh
authored andcommitted
iio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
[ Upstream commit 3d47251 ] 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: 6c25539 ("iio: Add Intersil isl29125 digital color light sensor driver") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501170121.512209-18-jic23@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f960139 commit 293b824

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/iio/light/isl29125.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
struct isl29125_data {
5252
struct i2c_client *client;
5353
u8 conf1;
54-
u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */
54+
/* Ensure timestamp is naturally aligned */
55+
struct {
56+
u16 chans[3];
57+
s64 timestamp __aligned(8);
58+
} scan;
5559
};
5660

5761
#define ISL29125_CHANNEL(_color, _si) { \
@@ -184,10 +188,10 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
184188
if (ret < 0)
185189
goto done;
186190

187-
data->buffer[j++] = ret;
191+
data->scan.chans[j++] = ret;
188192
}
189193

190-
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
194+
iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
191195
iio_get_time_ns(indio_dev));
192196

193197
done:

0 commit comments

Comments
 (0)