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

index e8b767680133207362fc2e1133e364be71bfdedd..039d45af3a7f3de64d7a6f71f16cccfcba177fd0 100644 (file)
 struct max44000_data {
        struct mutex lock;
        struct regmap *regmap;
-       /* Ensure naturally aligned timestamp */
-       struct {
-               u16 channels[2];
-               aligned_s64 ts;
-       } scan;
 };
 
 /* Default scale is set to the minimum of 0.03125 or 1 / (1 << 5) lux */
@@ -496,24 +491,29 @@ static irqreturn_t max44000_trigger_handler(int irq, void *p)
        int index = 0;
        unsigned int regval;
        int ret;
+       struct {
+               u16 channels[2];
+               aligned_s64 ts;
+       } scan = { };
+
 
        mutex_lock(&data->lock);
        if (test_bit(MAX44000_SCAN_INDEX_ALS, indio_dev->active_scan_mask)) {
                ret = max44000_read_alsval(data);
                if (ret < 0)
                        goto out_unlock;
-               data->scan.channels[index++] = ret;
+               scan.channels[index++] = ret;
        }
        if (test_bit(MAX44000_SCAN_INDEX_PRX, indio_dev->active_scan_mask)) {
                ret = regmap_read(data->regmap, MAX44000_REG_PRX_DATA, &regval);
                if (ret < 0)
                        goto out_unlock;
-               data->scan.channels[index] = regval;
+               scan.channels[index] = regval;
        }
        mutex_unlock(&data->lock);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(indio_dev));
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;