iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime...
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 13 Apr 2025 10:34:43 +0000 (11:34 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 May 2025 13:20:27 +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-21-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/magnetometer/af8133j.c
drivers/iio/magnetometer/ak8974.c
drivers/iio/magnetometer/ak8975.c
drivers/iio/magnetometer/als31300.c
drivers/iio/magnetometer/bmc150_magn.c
drivers/iio/magnetometer/hmc5843.h
drivers/iio/magnetometer/hmc5843_core.c
drivers/iio/magnetometer/mag3110.c
drivers/iio/magnetometer/rm3100-core.c
drivers/iio/magnetometer/yamaha-yas530.c

index c1fc339..192ba2d 100644 (file)
@@ -370,7 +370,8 @@ static irqreturn_t af8133j_trigger_handler(int irq, void *p)
        if (ret)
                goto out_done;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &sample, timestamp);
+       iio_push_to_buffers_with_ts(indio_dev, &sample, sizeof(sample),
+                                   timestamp);
 
 out_done:
        iio_trigger_notify_done(indio_dev->trig);
index 857c92b..403876a 100644 (file)
@@ -673,8 +673,8 @@ static void ak8974_fill_buffer(struct iio_dev *indio_dev)
                goto out_unlock;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &ak8974->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &ak8974->scan, sizeof(ak8974->scan),
+                                   iio_get_time_ns(indio_dev));
 
  out_unlock:
        mutex_unlock(&ak8974->lock);
index f839357..a1e92b2 100644 (file)
@@ -882,8 +882,8 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev)
        data->scan.channels[1] = clamp_t(s16, le16_to_cpu(fval[1]), -def->range, def->range);
        data->scan.channels[2] = clamp_t(s16, le16_to_cpu(fval[2]), -def->range, def->range);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   iio_get_time_ns(indio_dev));
 
        return;
 
index 85eb142..f72af82 100644 (file)
@@ -245,8 +245,7 @@ static irqreturn_t als31300_trigger_handler(int irq, void *p)
        scan.channels[0] = x;
        scan.channels[1] = y;
        scan.channels[2] = z;
-       iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-                                          pf->timestamp);
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), pf->timestamp);
 
 trigger_out:
        iio_trigger_notify_done(indio_dev->trig);
index 88bb673..f9c51ce 100644 (file)
@@ -678,8 +678,8 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
        if (ret < 0)
                goto err;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          pf->timestamp);
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   pf->timestamp);
 
 err:
        mutex_unlock(&data->mutex);
index ffd669b..7a3faf7 100644 (file)
@@ -34,7 +34,7 @@ enum hmc5843_ids {
  * @regmap:            hardware access register maps
  * @variant:           describe chip variants
  * @scan:              buffer to pack data for passing to
- *                     iio_push_to_buffers_with_timestamp()
+ *                     iio_push_to_buffers_with_ts()
  */
 struct hmc5843_data {
        struct device *dev;
index 2fc8431..fc16ebd 100644 (file)
@@ -452,8 +452,8 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
        if (ret < 0)
                goto done;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   iio_get_time_ns(indio_dev));
 
 done:
        iio_trigger_notify_done(indio_dev->trig);
index 92d4511..ff09250 100644 (file)
@@ -404,8 +404,8 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p)
                data->scan.temperature = ret;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-               iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   iio_get_time_ns(indio_dev));
 
 done:
        iio_trigger_notify_done(indio_dev->trig);
index e5162ee..2b28844 100644 (file)
@@ -515,8 +515,8 @@ static irqreturn_t rm3100_trigger_handler(int irq, void *p)
         * Always using the same buffer so that we wouldn't need to set the
         * paddings to 0 in case of leaking any data.
         */
-       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-                                          pf->timestamp);
+       iio_push_to_buffers_with_ts(indio_dev, data->buffer, sizeof(data->buffer),
+                                   pf->timestamp);
 done:
        iio_trigger_notify_done(indio_dev->trig);
 
index 46bc64e..3406071 100644 (file)
@@ -674,8 +674,8 @@ static void yas5xx_fill_buffer(struct iio_dev *indio_dev)
        yas5xx->scan.channels[1] = x;
        yas5xx->scan.channels[2] = y;
        yas5xx->scan.channels[3] = z;
-       iio_push_to_buffers_with_timestamp(indio_dev, &yas5xx->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &yas5xx->scan, sizeof(yas5xx->scan),
+                                   iio_get_time_ns(indio_dev));
 }
 
 static irqreturn_t yas5xx_handle_trigger(int irq, void *p)