Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: light: vl6180: Use iio_push_to_buffers_with_ts() to allow source size runtime check

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.

Cc: Abhash Jha <abhashkumarjha123@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250802164436.515988-16-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+7 -7
+7 -7
drivers/iio/light/vl6180.c
··· 96 96 unsigned int als_it_ms; 97 97 unsigned int als_meas_rate; 98 98 unsigned int range_meas_rate; 99 - 100 - struct { 101 - u16 chan[2]; 102 - aligned_s64 timestamp; 103 - } scan; 104 99 }; 105 100 106 101 enum { VL6180_ALS, VL6180_RANGE, VL6180_PROX }; ··· 540 545 struct vl6180_data *data = iio_priv(indio_dev); 541 546 s64 time_ns = iio_get_time_ns(indio_dev); 542 547 int ret, bit, i = 0; 548 + struct { 549 + u16 chan[2]; 550 + aligned_s64 timestamp; 551 + } scan = { }; 552 + 543 553 544 554 iio_for_each_active_channel(indio_dev, bit) { 545 555 if (vl6180_chan_regs_table[bit].word) ··· 560 560 return IRQ_HANDLED; 561 561 } 562 562 563 - data->scan.chan[i++] = ret; 563 + scan.chan[i++] = ret; 564 564 } 565 565 566 - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns); 566 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), time_ns); 567 567 iio_trigger_notify_done(indio_dev->trig); 568 568 569 569 /* Clear the interrupt flag after data read */