From: Jonathan Cameron Date: Sat, 2 Aug 2025 16:44:31 +0000 (+0100) Subject: iio: light: st_uvis25: Use iio_push_to_buffers_with_ts() to allow source size runtime... X-Git-Tag: v6.18-rc1~74^2~7^2~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb8453db633071ae2b8fefd4be37d74e925d16f5;p=thirdparty%2Fkernel%2Fstable.git iio: light: st_uvis25: 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. Reviewed-by: Matti Vaittinen Reviewed-by: Andy Shevchenko Link: https://patch.msgid.link/20250802164436.515988-12-jic23@kernel.org Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/light/st_uvis25.h b/drivers/iio/light/st_uvis25.h index 1f93e3dc45c2b..78bc56aad1299 100644 --- a/drivers/iio/light/st_uvis25.h +++ b/drivers/iio/light/st_uvis25.h @@ -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; diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c index 124a8f9204a99..bcd729a9924ea 100644 --- a/drivers/iio/light/st_uvis25_core.c +++ b/drivers/iio/light/st_uvis25_core.c @@ -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);