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

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250802164436.515988-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/st_uvis25.h
drivers/iio/light/st_uvis25_core.c

index 1f93e3dc45c2b0d9693322dca6d682f73303f76d..78bc56aad1299f3feb659304a1341f3ea4839413 100644 (file)
@@ -27,11 +27,6 @@ struct st_uvis25_hw {
        struct iio_trigger *trig;
        bool enabled;
        int irq;
-       /* Ensure timestamp is naturally aligned */
-       struct {
-               u8 chan;
-               aligned_s64 ts;
-       } scan;
 };
 
 extern const struct dev_pm_ops st_uvis25_pm_ops;
index 124a8f9204a99c7ae2987bf89bc405326830fb2b..bcd729a9924ea8e059f88d9d758f13b4a22f6408 100644 (file)
@@ -234,15 +234,21 @@ static irqreturn_t st_uvis25_buffer_handler_thread(int irq, void *p)
        struct st_uvis25_hw *hw = iio_priv(iio_dev);
        unsigned int val;
        int err;
+       /* Ensure timestamp is naturally aligned */
+       struct {
+               u8 chan;
+               aligned_s64 ts;
+       } scan = { };
+
 
        err = regmap_read(hw->regmap, ST_UVIS25_REG_OUT_ADDR, &val);
        if (err < 0)
                goto out;
 
-       hw->scan.chan = val;
+       scan.chan = val;
 
-       iio_push_to_buffers_with_timestamp(iio_dev, &hw->scan,
-                                          iio_get_time_ns(iio_dev));
+       iio_push_to_buffers_with_ts(iio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(iio_dev));
 
 out:
        iio_trigger_notify_done(hw->trig);