iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime...
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 13 Apr 2025 10:34:37 +0000 (11:34 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 May 2025 13:20:26 +0000 (14:20 +0100)
This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/temperature/hid-sensor-temperature.c
drivers/iio/temperature/maxim_thermocouple.c
drivers/iio/temperature/tmp006.c

index 09f470bb084169be769b9fe30c2df1effddb5ce3..9f628a8e5cfbe9f1509e5c27d230e390842b5cfe 100644 (file)
@@ -131,8 +131,9 @@ static int temperature_proc_event(struct hid_sensor_hub_device *hsdev,
        struct temperature_state *temp_st = iio_priv(indio_dev);
 
        if (atomic_read(&temp_st->common_attributes.data_ready))
-               iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan,
-                                                  iio_get_time_ns(indio_dev));
+               iio_push_to_buffers_with_ts(indio_dev, &temp_st->scan,
+                                           sizeof(temp_st->scan),
+                                           iio_get_time_ns(indio_dev));
 
        return 0;
 }
index 0bbbadeed940d24ed1a99bdb49e0d8213b3ece3c..94cc7d261123286bbcbcef91bbc1422b7aa9b2ad 100644 (file)
@@ -168,8 +168,9 @@ static irqreturn_t maxim_thermocouple_trigger_handler(int irq, void *private)
 
        ret = spi_read(data->spi, data->buffer, data->chip->read_size);
        if (!ret) {
-               iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-                                                  iio_get_time_ns(indio_dev));
+               iio_push_to_buffers_with_ts(indio_dev, data->buffer,
+                                           sizeof(data->buffer),
+                                           iio_get_time_ns(indio_dev));
        }
 
        iio_trigger_notify_done(indio_dev->trig);
index b5c94b7492f5d5fd59b7c4d6a8b7b8b1e68dbc03..29bff9d8859d017e1b59536c531f732a2d749631 100644 (file)
@@ -269,8 +269,8 @@ static irqreturn_t tmp006_trigger_handler(int irq, void *p)
                goto err;
        scan.channels[1] = ret;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(indio_dev));
 err:
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;