mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
iio: light: adjd_s311: Use iio_push_to_buffers_with_ts() to allow source size runtime check
Also move the structure used as the source to the stack as it is only 16 bytes and not the target of an DMA or similar. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250802164436.515988-9-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
@@ -54,10 +54,6 @@
|
||||
|
||||
struct adjd_s311_data {
|
||||
struct i2c_client *client;
|
||||
struct {
|
||||
s16 chans[4];
|
||||
aligned_s64 ts;
|
||||
} scan;
|
||||
};
|
||||
|
||||
enum adjd_s311_channel_idx {
|
||||
@@ -120,6 +116,10 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
s64 time_ns = iio_get_time_ns(indio_dev);
|
||||
int i, j = 0;
|
||||
struct {
|
||||
s16 chans[4];
|
||||
aligned_s64 ts;
|
||||
} scan = { };
|
||||
|
||||
int ret = adjd_s311_req_data(indio_dev);
|
||||
if (ret < 0)
|
||||
@@ -131,10 +131,10 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
data->scan.chans[j++] = ret & ADJD_S311_DATA_MASK;
|
||||
scan.chans[j++] = ret & ADJD_S311_DATA_MASK;
|
||||
}
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns);
|
||||
iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), time_ns);
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
Reference in New Issue
Block a user