]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: light: vl6180: Use iio_push_to_buffers_with_ts() to allow source size runtime...
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 2 Aug 2025 16:44:35 +0000 (17:44 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 16 Aug 2025 14:59:34 +0000 (15:59 +0100)
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>
drivers/iio/light/vl6180.c

index 38706424089c9dfce04f4da960509b4bf54dc301..c1314b144367f1ae4ebf156961560041fccd0c5c 100644 (file)
@@ -96,11 +96,6 @@ struct vl6180_data {
        unsigned int als_it_ms;
        unsigned int als_meas_rate;
        unsigned int range_meas_rate;
-
-       struct {
-               u16 chan[2];
-               aligned_s64 timestamp;
-       } scan;
 };
 
 enum { VL6180_ALS, VL6180_RANGE, VL6180_PROX };
@@ -545,6 +540,11 @@ static irqreturn_t vl6180_trigger_handler(int irq, void *priv)
        struct vl6180_data *data = iio_priv(indio_dev);
        s64 time_ns = iio_get_time_ns(indio_dev);
        int ret, bit, i = 0;
+       struct {
+               u16 chan[2];
+               aligned_s64 timestamp;
+       } scan = { };
+
 
        iio_for_each_active_channel(indio_dev, bit) {
                if (vl6180_chan_regs_table[bit].word)
@@ -560,10 +560,10 @@ static irqreturn_t vl6180_trigger_handler(int irq, void *priv)
                        return IRQ_HANDLED;
                }
 
-               data->scan.chan[i++] = ret;
+               scan.chan[i++] = ret;
        }
 
-       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);
        iio_trigger_notify_done(indio_dev->trig);
 
        /* Clear the interrupt flag after data read */