IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument.
Subsystems (34)
Jonathan Cameron
maintainerv3 cover IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument.
From: Jonathan Cameron <[email protected]>
v3:
- Take the dummy driver back to doing a kzalloc()
- Various white space changes.
- Tag collection
v2:
- Add some fixes via aligned_s64 (thanks David)
- Improve naming of new parameter and mark the error check unlikely (thanks Nuno)
When using the IIO buffers, the length of each scan element is always known to the IIO core (used for sizing kfifo elements etc) and depends on which channels are enabled. Devices often use fixed size structures or arrays.
The core code previously had no way to check that the driver had provided a large enough buffer, potentially leading to errors or to non sanitized data being presented to user space. In particular the iio_push_to_buffers_with_timestamp() helper has the non obvious requirement for a larger buffer when timestamps are enabled than that containing the rest of the channels (under the control of the driver). This has lead to bugs in the past and this series aims to make that impossible in the future by passing the size of the storage into a new variant of the helper iio_push_to_buffers_with_ts() and performing a runtime check.
Once all drivers are converted, the expectation is the _with_timestamp() version without this check will be removed.
The patches in this series use this helper for a large number of simple cases and fix a few minor issues found during the conversion. This does not cover all drivers in each category, leaving more complex cases for future series. Some of the remaining cases need substantial refactoring, others look to have bugs that need more careful consideration than the cases in this series.
All comments welcome. I haven't attempted to cc all the relevant driver maintainers as that is a long list!
Jonathan Cameron (20):
iio: adc: ad7266: Fix potential timestamp alignment issue.
iio: adc: ad7768-1: Fix insufficient alignment of timestamp.
iio: adc: dln2: Use aligned_s64 for timestamp
iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64
iio: introduced iio_push_to_buffers_with_ts() that takes a
data_total_len argument.
iio: dummy: Use a fixed structure to build up scan to push to buffers.
iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size
of storage
iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to
provide length sanity check.
iio: adc: Use iio_push_to_buffers_with_ts() to provide length for
runtime checks.
iio: accel: Use iio_push_to_buffers_with_ts() to provide length for
runtime checks.
iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length
for runtime checks.
iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for
runtime checks.
iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer.
iio: temperature: Use iio_push_to_buffers_with_ts() to provide length
for runtime checks.
iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for
runtime checks.
iio: proximity: irsd200: Use a struct for scan and
iio_push_to_buffers_with_ts()
iio: proximity: Use iio_push_to_buffers_with_ts() to provide length
for runtime checks.
iio: pressure: zpa2326: Use aligned_s64 for the timestamp
iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for
runtime checks.
iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length
for runtime checks.
drivers/iio/accel/adxl355_core.c | 6 ++--- drivers/iio/accel/bma180.c | 2 +- drivers/iio/accel/bma220_spi.c | 4 +-- drivers/iio/accel/bma400_core.c | 5 ++-- drivers/iio/accel/fxls8962af-core.c | 4 +-- drivers/iio/accel/hid-sensor-accel-3d.c | 2 +- drivers/iio/accel/kxcjk-1013.c | 4 +-- drivers/iio/accel/kxsd9.c | 5 ++-- drivers/iio/accel/mma7455_core.c | 5 ++-- drivers/iio/accel/mma8452.c | 5 ++-- drivers/iio/accel/msa311.c | 4 +-- drivers/iio/accel/mxc4005.c | 4 +-- drivers/iio/accel/sca3300.c | 5 ++-- drivers/iio/accel/stk8312.c | 4 +-- drivers/iio/accel/stk8ba50.c | 4 +-- drivers/iio/adc/ad4000.c | 3 ++- drivers/iio/adc/ad4030.c | 4 +-- drivers/iio/adc/ad4695.c | 3 ++- drivers/iio/adc/ad7266.c | 9 +++---- drivers/iio/adc/ad7298.c | 4 +-- drivers/iio/adc/ad7380.c | 4 +-- drivers/iio/adc/ad7476.c | 4 +-- drivers/iio/adc/ad7606.c | 4 +-- drivers/iio/adc/ad7768-1.c | 7 ++--- drivers/iio/adc/ad7779.c | 3 ++- drivers/iio/adc/ad7923.c | 4 +-- drivers/iio/adc/dln2-adc.c | 6 ++--- drivers/iio/adc/ina2xx-adc.c | 2 +- drivers/iio/adc/max1118.c | 4 +-- drivers/iio/adc/max11410.c | 4 +-- drivers/iio/adc/max1363.c | 4 +-- drivers/iio/adc/mcp3911.c | 4 +-- drivers/iio/adc/mxs-lradc-adc.c | 3 ++- drivers/iio/adc/pac1921.c | 3 ++- drivers/iio/adc/rockchip_saradc.c | 3 ++- drivers/iio/adc/rtq6056.c | 3 ++- drivers/iio/adc/stm32-adc.c | 4 +-- drivers/iio/adc/ti-adc081c.c | 4 +-- drivers/iio/adc/ti-adc0832.c | 4 +-- drivers/iio/adc/ti-adc084s021.c | 4 +-- drivers/iio/adc/ti-adc12138.c | 4 +-- drivers/iio/adc/ti-ads1015.c | 4 +-- drivers/iio/adc/ti-ads1119.c | 4 +-- drivers/iio/adc/ti-ads124s08.c | 4 +-- drivers/iio/adc/ti-ads131e08.c | 4 +-- drivers/iio/adc/ti-ads8688.c | 4 +-- drivers/iio/adc/ti-lmp92064.c | 4 +-- drivers/iio/adc/ti-tlc4541.c | 4 +-- drivers/iio/adc/ti-tsc2046.c | 5 ++-- drivers/iio/adc/vf610_adc.c | 6 ++--- drivers/iio/chemical/atlas-sensor.c | 5 ++-- drivers/iio/chemical/bme680_core.c | 4 +-- drivers/iio/chemical/ccs811.c | 4 +-- drivers/iio/chemical/ens160_core.c | 4 +-- drivers/iio/chemical/pms7003.c | 4 +-- drivers/iio/chemical/scd30_core.c | 3 ++- drivers/iio/chemical/scd4x.c | 3 ++- drivers/iio/chemical/sps30.c | 4 +-- drivers/iio/dummy/iio_simple_dummy_buffer.c | 27 +++++++++++++------ drivers/iio/magnetometer/af8133j.c | 3 ++- drivers/iio/magnetometer/ak8974.c | 4 +-- drivers/iio/magnetometer/ak8975.c | 4 +-- drivers/iio/magnetometer/als31300.c | 3 +-- drivers/iio/magnetometer/bmc150_magn.c | 4 +-- drivers/iio/magnetometer/hmc5843.h | 2 +- drivers/iio/magnetometer/hmc5843_core.c | 4 +-- drivers/iio/magnetometer/mag3110.c | 4 +-- drivers/iio/magnetometer/rm3100-core.c | 4 +-- drivers/iio/magnetometer/yamaha-yas530.c | 4 +-- drivers/iio/pressure/bmp280-core.c | 25 ++++++++++------- drivers/iio/pressure/hid-sensor-press.c | 5 ++-- drivers/iio/pressure/hsc030pa.c | 4 +-- drivers/iio/pressure/mpl3115.c | 4 +-- drivers/iio/pressure/rohm-bm1390.c | 3 ++- drivers/iio/pressure/zpa2326.c | 6 ++--- drivers/iio/proximity/as3935.c | 4 +-- drivers/iio/proximity/hx9023s.c | 4 +-- drivers/iio/proximity/irsd200.c | 12 ++++++--- drivers/iio/proximity/mb1232.c | 4 +-- .../iio/proximity/pulsedlight-lidar-lite-v2.c | 5 ++-- drivers/iio/proximity/srf08.c | 4 +-- drivers/iio/proximity/sx_common.c | 4 +-- drivers/iio/proximity/vl53l0x-i2c.c | 4 +-- drivers/iio/resolver/ad2s1210.c | 3 ++- .../iio/temperature/hid-sensor-temperature.c | 5 ++-- drivers/iio/temperature/maxim_thermocouple.c | 7 ++--- drivers/iio/temperature/tmp006.c | 4 +-- include/linux/iio/buffer.h | 12 +++++++++ 88 files changed, 236 insertions(+), 184 deletions(-)
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 1/20 iio: adc: ad7266: Fix potential timestamp alignment issue.
From: Jonathan Cameron <[email protected]>
On architectures where an s64 is only 32-bit aligned insufficient padding would be left between the earlier elements and the timestamp. Use aligned_s64 to enforce the correct placement and ensure the storage is large enough.
---
v3: Improved commit message (Andy)
--- drivers/iio/adc/ad7266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7266.c +1 -1
@@ -45,7 +45,7 @@ struct ad7266_state {*/ struct {__be16 sample[2 ]; -s64 timestamp; +aligned_s64 timestamp; } data__aligned(IIO_DMA_MINALIGN) ; };
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 2/20 iio: adc: ad7768-1: Fix insufficient alignment of timestamp.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
On architectures where an s64 is not 64-bit aligned, this may result insufficient alignment of the timestamp and the structure being too small. Use aligned_s64 to force the alignment.
---
v3: 64-bit in commit message (Andy)
--- drivers/iio/adc/ad7768-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7768-1.c +1 -1
@@ -172,7 +172,7 @@ struct ad7768_state {union {struct {__be32 chan; -s64 timestamp; +aligned_s64 timestamp; } scan;__be32 d32;u8 d8[2 ];
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 3/20 iio: adc: dln2: Use aligned_s64 for timestamp
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Here the lack of marking allows the overall structure to not be sufficiently aligned resulting in misplacement of the timestamp in iio_push_to_buffers_with_timestamp(). Use aligned_s64 to force the alignment on all architectures.
--- drivers/iio/adc/dln2-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/dln2-adc.c +1 -1
@@ -466,7 +466,7 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p)struct iio_dev *indio_dev = pf->indio_dev;struct {__le16 values[DLN2_ADC_MAX_CHANNELS ]; -int64_t timestamp_space; +aligned_s64 timestamp_space; } data;struct dln2_adc_get_all_vals dev_data;struct dln2_adc *dln2 =iio_priv (indio_dev);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 4/20 iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
The IIO ABI requires 64-bit aligned timestamps. In this case insufficient padding would have been added on architectures where an s64 is only 32-bit aligned. Use aligned_s64 to enforce the correct alignment.
--- drivers/iio/accel/adxl355_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adxl355_core.c +1 -1
@@ -231,7 +231,7 @@ struct adxl355_data {u8 transf_buf[3 ];struct {u8 buf[14 ]; -s64 ts; +aligned_s64 ts; } buffer; }__aligned(IIO_DMA_MINALIGN) ; };
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 5/20 iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Check that data_total_len argument against iio_dev->scan_bytes.
The size needs to be at least as big as the scan. It can be larger, which is typical if only part of fixed sized storage is used due to a subset of channels being enabled.
---
v3:
- Use an s64 instead of int64_t for the new function (Andy)
v2:
- Rename size to data_total_len to make it clear that it is about data but also that it isn't simply the length to be used.
- Added an unlikely marking.
--- include/linux/iio/buffer.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/iio/buffer.h +12 -0
@@ -45,6 +45,18 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,return iio_push_to_buffers (indio_dev, data); } +static inline int iio_push_to_buffers_with_ts (struct iio_dev *indio_dev, +void *data,size_t data_total_len, +s64 timestamp) +{ +if (unlikely (data_total_len < indio_dev->scan_bytes)) { +dev_err (&indio_dev->dev,"Undersized storage pushed to buffer\n" ); +return -ENOSPC ; + } + +return iio_push_to_buffers_with_timestamp (indio_dev, data, timestamp); +} +int iio_push_to_buffers_with_ts_unaligned (struct iio_dev *indio_dev,const void *data,size_t data_sz,int64_t timestamp);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 6/20 iio: dummy: Use a fixed structure to build up scan to push to buffers.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
It has long been discouraged for drivers to make use of iio_dev->scan_bytes directly as that is an implementation detail of the core. As such our example driver should definitely not be doing so.
In order to illustrate the more complex case, where a DMA safe buffer is needed, continue to kzalloc() the storage (but with a structure definition to provide an explicit data layout). Also add comments on when a DMA safe buffer is necessary and the two common ways of obtaining one.
Whilst we have a mixture of signed and unsigned channels, the unsigned channels have ranges that can be stored in a signed value - hence use signed storage for all channels, simplifying the structure definition.
---
v3: Go back to kzalloc but with a structure definition. (Andy)
v2: Add a comment about stack buffers not being DMA safe.
--- drivers/iio/dummy/iio_simple_dummy_buffer.c | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/iio/dummy/iio_simple_dummy_buffer.c +18 -7
@@ -31,6 +31,11 @@ static const s16 fakedata[] = { [DUMMY_INDEX_ACCELX] = 344, }; +struct dummy_scan { +s16 data[ARRAY_SIZE (fakedata)]; +aligned_s64 timestamp; +}; +/** * iio_simple_dummy_trigger_h() - the trigger handler function * @irq: the interrupt number
@@ -45,11 +50,18 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) {struct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev; +struct dummy_scan *scan;int i =0 , j; -u16 *data; - data =kzalloc (indio_dev->scan_bytes,GFP_KERNEL ); -if (!data) +/* +* Note that some buses such as SPI require DMA safe buffers which +* cannot be on the stack. Two easy ways to do this: +* - Local kzalloc (as done here) +* - A buffer at the end of the structure accessed via iio_priv() +* that is marked __aligned(IIO_DMA_MINALIGN). +*/ + scan =kzalloc (sizeof (*scan),GFP_KERNEL ); +if (!scan) goto done;/*
@@ -69,13 +81,12 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)* constant table fakedata. */ iio_for_each_active_channel (indio_dev, j) - data[i++] = fakedata[j]; + scan->data[i++] = fakedata[j]; -iio_push_to_buffers_with_timestamp (indio_dev, data, +iio_push_to_buffers_with_timestamp (indio_dev, scan,iio_get_time_ns (indio_dev)); -kfree (data); - +kfree (scan); done:/* * Tell the core we are done with this trigger and ready for the
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 7/20 iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Provide the storage size so that the helper can sanity check that it is large enough for the configured channels.
---
v3: Updates due to change in previous patch.
--- drivers/iio/dummy/iio_simple_dummy_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/dummy/iio_simple_dummy_buffer.c +2 -2
@@ -83,8 +83,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)iio_for_each_active_channel (indio_dev, j) scan->data[i++] = fakedata[j]; -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));kfree (scan); done:
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 8/20 iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
By providing the size of the buffer used, runtime checks can be performed to ensure not overrun.
Also change the pushed data pointer to be that of the structure that also contains the timestamp. Not an actual bug but semantically incorrect to push the channel data when we want the storage with the timestamp as well.
---
v3: Line wrap tweak (Andy)
--- drivers/iio/adc/ti-ads131e08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ti-ads131e08.c +2 -2
@@ -664,8 +664,8 @@ static irqreturn_t ads131e08_trigger_handler(int irq, void *private) i++; } -iio_push_to_buffers_with_timestamp (indio_dev, st->tmp_buf.data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->tmp_buf,sizeof (st->tmp_buf), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 9/20 iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
---
v3:
- White space tweaks (Andy)
v2:
- ad4030, use &st->rx_data rather than st->rx_data.raw. Given that is the largest element of the union it isn't a bug, but the available space is more obvious if we use the whole union.
--- drivers/iio/adc/ad4000.c | 3 ++- drivers/iio/adc/ad4030.c | 4 ++-- drivers/iio/adc/ad4695.c | 3 ++- drivers/iio/adc/ad7266.c | 7 +++---- drivers/iio/adc/ad7298.c | 4 ++-- drivers/iio/adc/ad7380.c | 4 ++-- drivers/iio/adc/ad7476.c | 4 ++-- drivers/iio/adc/ad7606.c | 4 ++-- drivers/iio/adc/ad7768-1.c | 5 +++-- drivers/iio/adc/ad7779.c | 3 ++- drivers/iio/adc/ad7923.c | 4 ++-- drivers/iio/adc/dln2-adc.c | 4 ++-- drivers/iio/adc/ina2xx-adc.c | 2 +- drivers/iio/adc/max1118.c | 4 ++-- drivers/iio/adc/max11410.c | 4 ++-- drivers/iio/adc/max1363.c | 4 ++-- drivers/iio/adc/mcp3911.c | 4 ++-- drivers/iio/adc/mxs-lradc-adc.c | 3 ++- drivers/iio/adc/pac1921.c | 3 ++- drivers/iio/adc/rockchip_saradc.c | 3 ++- drivers/iio/adc/rtq6056.c | 3 ++- drivers/iio/adc/stm32-adc.c | 4 ++-- drivers/iio/adc/ti-adc081c.c | 4 ++-- drivers/iio/adc/ti-adc0832.c | 4 ++-- drivers/iio/adc/ti-adc084s021.c | 4 ++-- drivers/iio/adc/ti-adc12138.c | 4 ++-- drivers/iio/adc/ti-ads1015.c | 4 ++-- drivers/iio/adc/ti-ads1119.c | 4 ++-- drivers/iio/adc/ti-ads124s08.c | 4 ++-- drivers/iio/adc/ti-ads8688.c | 4 ++-- drivers/iio/adc/ti-lmp92064.c | 4 ++-- drivers/iio/adc/ti-tlc4541.c | 4 ++-- drivers/iio/adc/ti-tsc2046.c | 5 +++-- drivers/iio/adc/vf610_adc.c | 6 +++--- 34 files changed, 71 insertions(+), 63 deletions(-)
drivers/iio/adc/ad4000.c +2 -1
@@ -793,7 +793,8 @@ static irqreturn_t ad4000_trigger_handler(int irq, void *p)if (ret <0 ) goto err_out; -iio_push_to_buffers_with_timestamp (indio_dev, &st->scan, pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &st->scan,sizeof (st->scan), + pf->timestamp); err_out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad4030.c +2 -2
@@ -707,8 +707,8 @@ static irqreturn_t ad4030_trigger_handler(int irq, void *p)if (ret) goto out; -iio_push_to_buffers_with_timestamp (indio_dev, st->rx_data.raw, - pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &st->rx_data,sizeof (st->rx_data), + pf->timestamp); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad4695.c +2 -1
@@ -801,7 +801,8 @@ static irqreturn_t ad4695_trigger_handler(int irq, void *p)if (ret) goto out; -iio_push_to_buffers_with_timestamp (indio_dev, st->buf, pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, st->buf,sizeof (st->buf), + pf->timestamp); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7266.c +3 -4
@@ -86,10 +86,9 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)int ret; ret =spi_read (st->spi, st->data.sample,4 ); -if (ret ==0 ) { -iio_push_to_buffers_with_timestamp (indio_dev, &st->data, - pf->timestamp); - } +if (ret ==0 ) +iio_push_to_buffers_with_ts (indio_dev, &st->data,sizeof (st->data), + pf->timestamp);iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7298.c +2 -2
@@ -155,8 +155,8 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)if (b_sent) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, st->rx_buf, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, st->rx_buf,sizeof (st->rx_buf), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7380.c +2 -2
@@ -1361,8 +1361,8 @@ static irqreturn_t ad7380_trigger_handler(int irq, void *p)if (ret) goto out; -iio_push_to_buffers_with_timestamp (indio_dev, &st->scan_data, - pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &st->scan_data,sizeof (st->scan_data), + pf->timestamp); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7476.c +2 -2
@@ -99,8 +99,8 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)if (b_sent <0 ) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, st->data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, st->data,sizeof (st->data), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7606.c +2 -2
@@ -605,8 +605,8 @@ static irqreturn_t ad7606_trigger_handler(int irq, void *p)if (ret) goto error_ret; -iio_push_to_buffers_with_timestamp (indio_dev, &st->data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->data,sizeof (st->data), +iio_get_time_ns (indio_dev)); error_ret:iio_trigger_notify_done (indio_dev->trig);/* The rising edge of the CONVST signal starts a new conversion. */
drivers/iio/adc/ad7768-1.c +3 -2
@@ -533,8 +533,9 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)if (ret <0 ) goto out; -iio_push_to_buffers_with_timestamp (indio_dev, &st->data.scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->data.scan, +sizeof (st->data.scan), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7779.c +2 -1
@@ -595,7 +595,8 @@ static irqreturn_t ad7779_trigger_handler(int irq, void *p) goto exit_handler; } -iio_push_to_buffers_with_timestamp (indio_dev, &st->data, pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &st->data,sizeof (st->data), + pf->timestamp); exit_handler:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ad7923.c +2 -2
@@ -207,8 +207,8 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)if (b_sent) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, st->rx_buf, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, st->rx_buf,sizeof (st->rx_buf), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/dln2-adc.c +2 -2
@@ -488,8 +488,8 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p) (void *)dev_data.values + t->from, t->length); } -iio_push_to_buffers_with_timestamp (indio_dev, &data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &data,sizeof (data), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ina2xx-adc.c +1 -1
@@ -766,7 +766,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev) chip->scan.chan[i++] = val; } -iio_push_to_buffers_with_timestamp (indio_dev, &chip->scan, time); +iio_push_to_buffers_with_ts (indio_dev, &chip->scan,sizeof (chip->scan), time);return 0 ; };
drivers/iio/adc/max1118.c +2 -2
@@ -188,8 +188,8 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p) adc->scan.channels[i] = ret; i++; } -iio_push_to_buffers_with_timestamp (indio_dev, &adc->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &adc->scan,sizeof (adc->scan), +iio_get_time_ns (indio_dev)); out:mutex_unlock (&adc->lock);
drivers/iio/adc/max11410.c +2 -2
@@ -632,8 +632,8 @@ static irqreturn_t max11410_trigger_handler(int irq, void *p) goto out; } -iio_push_to_buffers_with_timestamp (indio_dev, &st->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->scan,sizeof (st->scan), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/max1363.c +2 -2
@@ -1498,8 +1498,8 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)if (b_sent <0 ) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, &st->data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->data,sizeof (st->data), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/mcp3911.c +2 -2
@@ -516,8 +516,8 @@ static irqreturn_t mcp3911_trigger_handler(int irq, void *p) adc->scan.channels[i] =get_unaligned_be24 (&adc->rx_buf[scan_chan->channel *3 ]); i++; } -iio_push_to_buffers_with_timestamp (indio_dev, &adc->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &adc->scan,sizeof (adc->scan), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/mxs-lradc-adc.c +2 -1
@@ -425,7 +425,8 @@ static irqreturn_t mxs_lradc_adc_trigger_handler(int irq, void *p) j++; } -iio_push_to_buffers_with_timestamp (iio, adc->buffer, pf->timestamp); +iio_push_to_buffers_with_ts (iio, adc->buffer,sizeof (adc->buffer), + pf->timestamp);iio_trigger_notify_done (iio->trig);
drivers/iio/adc/pac1921.c +2 -1
@@ -1044,7 +1044,8 @@ static irqreturn_t pac1921_trigger_handler(int irq, void *p) priv->scan.chan[ch++] = val; } -iio_push_to_buffers_with_timestamp (idev, &priv->scan, pf->timestamp); +iio_push_to_buffers_with_ts (idev, &priv->scan,sizeof (priv->scan), + pf->timestamp); done:iio_trigger_notify_done (idev->trig);
drivers/iio/adc/rockchip_saradc.c +2 -1
@@ -425,7 +425,8 @@ static irqreturn_t rockchip_saradc_trigger_handler(int irq, void *p) j++; } -iio_push_to_buffers_with_timestamp (i_dev, &data,iio_get_time_ns (i_dev)); +iio_push_to_buffers_with_ts (i_dev, &data,sizeof (data), +iio_get_time_ns (i_dev)); out:mutex_unlock (&info->lock);
drivers/iio/adc/rtq6056.c +2 -1
@@ -666,7 +666,8 @@ static irqreturn_t rtq6056_buffer_trigger_handler(int irq, void *p) data.vals[i++] = raw; } -iio_push_to_buffers_with_timestamp (indio_dev, &data,iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &data,sizeof (data), +iio_get_time_ns (indio_dev)); out:pm_runtime_mark_last_busy (dev);
drivers/iio/adc/stm32-adc.c +2 -2
@@ -1858,8 +1858,8 @@ static irqreturn_t stm32_adc_trigger_handler(int irq, void *p)/* reset buffer index */ adc->bufi =0 ; -iio_push_to_buffers_with_timestamp (indio_dev, adc->buffer, - pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, adc->buffer,sizeof (adc->buffer), + pf->timestamp);iio_trigger_notify_done (indio_dev->trig);/* re-enable eoc irq */
drivers/iio/adc/ti-adc081c.c +2 -2
@@ -140,8 +140,8 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p)if (ret <0 ) goto out; data->scan.channel = 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)); out:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
drivers/iio/adc/ti-adc0832.c +2 -2
@@ -225,8 +225,8 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p) adc->data[i] = ret; i++; } -iio_push_to_buffers_with_timestamp (indio_dev, adc->data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, adc->data,sizeof (adc->data), +iio_get_time_ns (indio_dev)); out:mutex_unlock (&adc->lock);
drivers/iio/adc/ti-adc084s021.c +2 -2
@@ -151,8 +151,8 @@ static irqreturn_t adc084s021_buffer_trigger_handler(int irq, void *pollfunc)if (adc084s021_adc_conversion (adc, adc->scan.channels) <0 )dev_err (&adc->spi->dev,"Failed to read data\n" ); -iio_push_to_buffers_with_timestamp (indio_dev, &adc->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &adc->scan,sizeof (adc->scan), +iio_get_time_ns (indio_dev));mutex_unlock (&adc->lock);iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ti-adc12138.c +2 -2
@@ -376,8 +376,8 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) } } -iio_push_to_buffers_with_timestamp (indio_dev, adc->data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, adc->data,sizeof (adc->data), +iio_get_time_ns (indio_dev)); out:mutex_unlock (&adc->lock);
drivers/iio/adc/ti-ads1015.c +2 -2
@@ -467,8 +467,8 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) scan.chan = res;mutex_unlock (&data->lock); -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);
drivers/iio/adc/ti-ads1119.c +2 -2
@@ -534,8 +534,8 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private) scan.sample = 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)); done:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
drivers/iio/adc/ti-ads124s08.c +2 -2
@@ -297,8 +297,8 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) j++; } -iio_push_to_buffers_with_timestamp (indio_dev, priv->buffer, - pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, priv->buffer,sizeof (priv->buffer), + pf->timestamp);iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ti-ads8688.c +2 -2
@@ -389,8 +389,8 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p) j++; } -iio_push_to_buffers_with_timestamp (indio_dev, buffer, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, buffer,sizeof (buffer), +iio_get_time_ns (indio_dev));iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ti-lmp92064.c +2 -2
@@ -209,8 +209,8 @@ static irqreturn_t lmp92064_trigger_handler(int irq, void *p)if (ret) goto err; -iio_push_to_buffers_with_timestamp (indio_dev, &data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &data,sizeof (data), +iio_get_time_ns (indio_dev)); err:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ti-tlc4541.c +2 -2
@@ -99,8 +99,8 @@ static irqreturn_t tlc4541_trigger_handler(int irq, void *p)if (ret <0 ) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, st->rx_buf, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, st->rx_buf,sizeof (st->rx_buf), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/adc/ti-tsc2046.c +3 -2
@@ -418,8 +418,9 @@ static int tsc2046_adc_scan(struct iio_dev *indio_dev)for (group =0 ; group < priv->groups; group++) priv->scan_buf.data[group] =tsc2046_adc_get_val (priv, group); - ret =iio_push_to_buffers_with_timestamp (indio_dev, &priv->scan_buf, -iio_get_time_ns (indio_dev)); + ret =iio_push_to_buffers_with_ts (indio_dev, &priv->scan_buf, +sizeof (priv->scan_buf), +iio_get_time_ns (indio_dev));/* If the consumer is kfifo, we may get a EBUSY here - ignore it. */ if (ret <0 && ret != -EBUSY ) { dev_err_ratelimited(dev, "Failed to push scan buffer %pe\n",
drivers/iio/adc/vf610_adc.c +3 -3
@@ -592,9 +592,9 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id) info->value =vf610_adc_read_data (info);if (iio_buffer_enabled (indio_dev)) { info->scan.chan = info->value; -iio_push_to_buffers_with_timestamp (indio_dev, - &info->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &info->scan, +sizeof (info->scan), +iio_get_time_ns (indio_dev));iio_trigger_notify_done (indio_dev->trig); }else complete (&info->completion);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 10/20 iio: accel: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
---
v3: White space tweaks (Andy)
--- drivers/iio/accel/adxl355_core.c | 4 ++-- drivers/iio/accel/bma180.c | 2 +- drivers/iio/accel/bma220_spi.c | 4 ++-- drivers/iio/accel/bma400_core.c | 5 +++-- drivers/iio/accel/fxls8962af-core.c | 4 ++-- drivers/iio/accel/kxcjk-1013.c | 4 ++-- drivers/iio/accel/kxsd9.c | 5 ++--- drivers/iio/accel/mma7455_core.c | 5 +++-- drivers/iio/accel/mma8452.c | 5 +++-- drivers/iio/accel/msa311.c | 4 ++-- drivers/iio/accel/mxc4005.c | 4 ++-- drivers/iio/accel/sca3300.c | 5 +++-- drivers/iio/accel/stk8312.c | 4 ++-- drivers/iio/accel/stk8ba50.c | 4 ++-- 14 files changed, 31 insertions(+), 28 deletions(-)
drivers/iio/accel/adxl355_core.c +2 -2
@@ -666,8 +666,8 @@ static irqreturn_t adxl355_trigger_handler(int irq, void *p)if (ret) goto out_unlock_notify; -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); out_unlock_notify:mutex_unlock (&data->lock);
drivers/iio/accel/bma180.c +1 -1
@@ -887,7 +887,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)mutex_unlock (&data->mutex); -iio_push_to_buffers_with_timestamp (indio_dev, &data->scan, time_ns); +iio_push_to_buffers_with_ts (indio_dev, &data->scan,sizeof (data->scan), time_ns); err:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/bma220_spi.c +2 -2
@@ -103,8 +103,8 @@ static irqreturn_t bma220_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->lock);iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/bma400_core.c +3 -2
@@ -1591,8 +1591,9 @@ static irqreturn_t bma400_trigger_handler(int irq, void *p) data->buffer.temperature = temp; } -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));mutex_unlock (&data->mutex);iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/fxls8962af-core.c +2 -2
@@ -983,8 +983,8 @@ static int fxls8962af_fifo_flush(struct iio_dev *indio_dev) sizeof(data->scan.channels[0])); } -iio_push_to_buffers_with_timestamp (indio_dev, &data->scan, - tstamp); +iio_push_to_buffers_with_ts (indio_dev, &data->scan, +sizeof (data->scan), tstamp); tstamp += sample_period; }
drivers/iio/accel/kxcjk-1013.c +2 -2
@@ -1253,8 +1253,8 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)if (ret <0 ) goto err; -iio_push_to_buffers_with_timestamp (indio_dev, &data->scan, - data->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &data->scan,sizeof (data->scan), + data->timestamp); err:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/kxsd9.c +2 -3
@@ -229,9 +229,8 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p) goto out; } -iio_push_to_buffers_with_timestamp (indio_dev, - &hw_values, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &hw_values,sizeof (hw_values), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/mma7455_core.c +3 -2
@@ -103,8 +103,9 @@ static irqreturn_t mma7455_trigger_handler(int irq, void *p)if (ret) goto done; -iio_push_to_buffers_with_timestamp (indio_dev, &mma7455->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &mma7455->scan, +sizeof (mma7455->scan), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/mma8452.c +3 -2
@@ -1103,8 +1103,9 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p)if (ret <0 ) goto done; -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)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/msa311.c +2 -2
@@ -919,8 +919,8 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p)mutex_unlock (&msa311->lock); -iio_push_to_buffers_with_timestamp (indio_dev, &buf, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &buf,sizeof (buf), +iio_get_time_ns (indio_dev)); notify_done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/mxc4005.c +2 -2
@@ -335,8 +335,8 @@ static irqreturn_t mxc4005_trigger_handler(int irq, void *private)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:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/sca3300.c +3 -2
@@ -505,8 +505,9 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p) channels[i++] = val; } -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)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/stk8312.c +2 -2
@@ -460,8 +460,8 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) }mutex_unlock (&data->lock); -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:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/accel/stk8ba50.c +2 -2
@@ -340,8 +340,8 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) data->scan.chans[i++] = ret; } } -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->lock);iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 11/20 iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. For this case, the length being provided is already passed into the caller function so reuse that.
--- drivers/iio/accel/hid-sensor-accel-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/hid-sensor-accel-3d.c +1 -1
@@ -228,7 +228,7 @@ static void hid_sensor_push_data(struct iio_dev *indio_dev, void *data, int len, int64_t timestamp) {dev_dbg (&indio_dev->dev,"hid_sensor_push_data\n" ); -iio_push_to_buffers_with_timestamp (indio_dev, data, timestamp); +iio_push_to_buffers_with_ts (indio_dev, data, len, timestamp); }/* Callback handler to send event after all samples are received and captured */
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 12/20 iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/chemical/atlas-sensor.c | 5 +++-- drivers/iio/chemical/bme680_core.c | 4 ++-- drivers/iio/chemical/ccs811.c | 4 ++-- drivers/iio/chemical/ens160_core.c | 4 ++-- drivers/iio/chemical/pms7003.c | 4 ++-- drivers/iio/chemical/scd30_core.c | 3 ++- drivers/iio/chemical/scd4x.c | 3 ++- drivers/iio/chemical/sps30.c | 4 ++-- 8 files changed, 17 insertions(+), 14 deletions(-)
drivers/iio/chemical/atlas-sensor.c +3 -2
@@ -458,8 +458,9 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private) &data->buffer, sizeof(__be32) * channels);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);
drivers/iio/chemical/bme680_core.c +2 -2
@@ -1120,8 +1120,8 @@ static irqreturn_t bme680_trigger_handler(int irq, void *p) gas_range =FIELD_GET (BME680_GAS_RANGE_MASK , gas_regs_val); data->scan.chan[3 ] =bme680_compensate_gas (data, adc_gas_res, gas_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)); out:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
drivers/iio/chemical/ccs811.c +2 -2
@@ -343,8 +343,8 @@ static irqreturn_t ccs811_trigger_handler(int irq, void *p) goto err; } -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)); err:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/chemical/ens160_core.c +2 -2
@@ -267,8 +267,8 @@ static irqreturn_t ens160_trigger_handler(int irq, void *p)if (ret) 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:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/chemical/pms7003.c +2 -2
@@ -126,8 +126,8 @@ static irqreturn_t pms7003_trigger_handler(int irq, void *p)pms7003_get_pm (frame->data +PMS7003_PM10_OFFSET );mutex_unlock (&state->lock); -iio_push_to_buffers_with_timestamp (indio_dev, &state->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &state->scan,sizeof (state->scan), +iio_get_time_ns (indio_dev)); err:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/chemical/scd30_core.c +2 -1
@@ -601,7 +601,8 @@ static irqreturn_t scd30_trigger_handler(int irq, void *p)if (ret) goto out; -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)); out:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
drivers/iio/chemical/scd4x.c +2 -1
@@ -675,7 +675,8 @@ static irqreturn_t scd4x_trigger_handler(int irq, void *p)if (ret) goto out; -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)); out:iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
drivers/iio/chemical/sps30.c +2 -2
@@ -117,8 +117,8 @@ static irqreturn_t sps30_trigger_handler(int irq, void *p)if (ret) goto err; -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);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 13/20 iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
The trick of using __aligned(IIO_DMA_MINALIGN) ensures that there is no overlap between buffers used for DMA and those used for driver state storage that are before the marking. It doesn't ensure anything above state variables found after the marking. Hence move this particular bit of state earlier in the structure.
--- drivers/iio/temperature/maxim_thermocouple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/maxim_thermocouple.c +1 -1
@@ -120,9 +120,9 @@ static const struct maxim_thermocouple_chip maxim_thermocouple_chips[] = {struct maxim_thermocouple_data {struct spi_device *spi;const struct maxim_thermocouple_chip *chip; +char tc_type;u8 buffer[16 ]__aligned(IIO_DMA_MINALIGN) ; -char tc_type; }; static int maxim_thermocouple_read(struct maxim_thermocouple_data *data,
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 14/20 iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/temperature/hid-sensor-temperature.c | 5 +++-- drivers/iio/temperature/maxim_thermocouple.c | 5 +++-- drivers/iio/temperature/tmp006.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/iio/temperature/hid-sensor-temperature.c +3 -2
@@ -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 ; }
drivers/iio/temperature/maxim_thermocouple.c +3 -2
@@ -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);
drivers/iio/temperature/tmp006.c +2 -2
@@ -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 ;
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 15/20 iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/resolver/ad2s1210.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/resolver/ad2s1210.c +2 -1
@@ -1340,7 +1340,8 @@ static irqreturn_t ad2s1210_trigger_handler(int irq, void *p) }ad2s1210_push_events (indio_dev, st->sample.fault, pf->timestamp); -iio_push_to_buffers_with_timestamp (indio_dev, &st->scan, pf->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &st->scan,sizeof (st->scan), + pf->timestamp); error_ret:iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 16/20 iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
The driver previously used an array of two s64, then type cast the pointer to write an s16 to the start. The code is made more readable using a structure. At the same time switch to the new iio_push_to_buffers_with_ts() helper to enable runtime checking of the size of the source buffer.
Note that this approach uses a structure with holes, so use memset() to ensure those do not contain old kernel data as this data is passed to userspace.
--- drivers/iio/proximity/irsd200.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/iio/proximity/irsd200.c +8 -4
@@ -760,15 +760,19 @@ static irqreturn_t irsd200_trigger_handler(int irq, void *pollf) {struct iio_dev *indio_dev = ((struct iio_poll_func *)pollf)->indio_dev;struct irsd200_data *data =iio_priv (indio_dev); -s64 buf[2 ] = {}; +struct { +s16 channel; +aligned_s64 ts; + } scan;int ret; - ret =irsd200_read_data (data, (s16 *)buf); +memset (&scan,0 ,sizeof (scan)); + ret =irsd200_read_data (data, &scan.channel);if (ret) goto end; -iio_push_to_buffers_with_timestamp (indio_dev, buf, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &scan,sizeof (scan), +iio_get_time_ns (indio_dev)); end:iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 17/20 iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/proximity/as3935.c | 4 ++-- drivers/iio/proximity/hx9023s.c | 4 ++-- drivers/iio/proximity/mb1232.c | 4 ++-- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 5 +++-- drivers/iio/proximity/srf08.c | 4 ++-- drivers/iio/proximity/sx_common.c | 4 ++-- drivers/iio/proximity/vl53l0x-i2c.c | 4 ++-- 7 files changed, 15 insertions(+), 14 deletions(-)
drivers/iio/proximity/as3935.c +2 -2
@@ -231,8 +231,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) goto err_read; st->scan.chan = val &AS3935_DATA_MASK ; -iio_push_to_buffers_with_timestamp (indio_dev, &st->scan, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, &st->scan,sizeof (st->scan), +iio_get_time_ns (indio_dev)); err_read:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/proximity/hx9023s.c +2 -2
@@ -953,8 +953,8 @@ static irqreturn_t hx9023s_trigger_handler(int irq, void *private) data->buffer.channels[i++] =cpu_to_le16 (data->ch_data[index].diff); } -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); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/proximity/mb1232.c +2 -2
@@ -125,8 +125,8 @@ static irqreturn_t mb1232_trigger_handler(int irq, void *p)if (data->scan.distance <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:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +3 -2
@@ -238,8 +238,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) ret =lidar_get_measurement (data, &data->scan.chan);if (!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)); }else if (ret != -EINVAL ) {dev_err (&data->client->dev,"cannot read LIDAR measurement" ); }
drivers/iio/proximity/srf08.c +2 -2
@@ -191,8 +191,8 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p)mutex_lock (&data->lock); data->scan.chan = sensor_data; -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);mutex_unlock (&data->lock); err:
drivers/iio/proximity/sx_common.c +2 -2
@@ -379,8 +379,8 @@ static irqreturn_t sx_common_trigger_handler(int irq, void *private) data->buffer.channels[i++] = val; } -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); out:mutex_unlock (&data->mutex);
drivers/iio/proximity/vl53l0x-i2c.c +2 -2
@@ -94,8 +94,8 @@ static irqreturn_t vl53l0x_trigger_handler(int irq, void *priv)return -EREMOTEIO ; data->scan.chan =get_unaligned_be16 (&buffer[10 ]); -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));iio_trigger_notify_done (indio_dev->trig);vl53l0x_clear_irq (data);
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 18/20 iio: pressure: zpa2326: Use aligned_s64 for the timestamp
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
On x86_32 s64 fields are only 32-bit aligned. Hence force the alignment of the field and padding in the structure by using aligned_s64 instead.
--- drivers/iio/pressure/zpa2326.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/zpa2326.c +1 -1
@@ -582,7 +582,7 @@ static int zpa2326_fill_sample_buffer(struct iio_dev *indio_dev,struct {u32 pressure;u16 temperature; -u64 timestamp; +aligned_s64 timestamp; } sample;int err;
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 19/20 iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/pressure/bmp280-core.c | 25 +++++++++++++++---------- drivers/iio/pressure/hid-sensor-press.c | 5 +++-- drivers/iio/pressure/hsc030pa.c | 4 ++-- drivers/iio/pressure/mpl3115.c | 4 ++-- drivers/iio/pressure/rohm-bm1390.c | 3 ++- drivers/iio/pressure/zpa2326.c | 4 ++-- 6 files changed, 26 insertions(+), 19 deletions(-)
drivers/iio/pressure/bmp280-core.c +15 -10
@@ -1142,8 +1142,9 @@ static irqreturn_t bmp280_trigger_handler(int irq, void *p) chans[0 ] = comp_press; chans[1 ] = comp_temp; -iio_push_to_buffers_with_timestamp (indio_dev, data->sensor_data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, data->sensor_data, +sizeof (data->sensor_data), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
@@ -1273,8 +1274,9 @@ static irqreturn_t bme280_trigger_handler(int irq, void *p) chans[1 ] = comp_temp; chans[2 ] = comp_humidity; -iio_push_to_buffers_with_timestamp (indio_dev, data->sensor_data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, data->sensor_data, +sizeof (data->sensor_data), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
@@ -1936,8 +1938,9 @@ static irqreturn_t bmp380_trigger_handler(int irq, void *p) chans[0 ] = comp_press; chans[1 ] = comp_temp; -iio_push_to_buffers_with_timestamp (indio_dev, data->sensor_data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, data->sensor_data, +sizeof (data->sensor_data), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
@@ -2630,8 +2633,9 @@ static irqreturn_t bmp580_trigger_handler(int irq, void *p)/* Temperature calculations */ memcpy (&data->sensor_data[offset], &data->buf[0 ],3 ); -iio_push_to_buffers_with_timestamp (indio_dev, data->sensor_data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, data->sensor_data, +sizeof (data->sensor_data), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
@@ -2969,8 +2973,9 @@ static irqreturn_t bmp180_trigger_handler(int irq, void *p) chans[0 ] = comp_press; chans[1 ] = comp_temp; -iio_push_to_buffers_with_timestamp (indio_dev, data->sensor_data, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, data->sensor_data, +sizeof (data->sensor_data), +iio_get_time_ns (indio_dev)); out:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/pressure/hid-sensor-press.c +3 -2
@@ -176,8 +176,9 @@ static int press_proc_event(struct hid_sensor_hub_device *hsdev,if (!press_state->timestamp) press_state->timestamp =iio_get_time_ns (indio_dev); -iio_push_to_buffers_with_timestamp ( - indio_dev, &press_state->scan, press_state->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &press_state->scan, +sizeof (press_state->scan), + press_state->timestamp); }return 0 ;
drivers/iio/pressure/hsc030pa.c +2 -2
@@ -314,8 +314,8 @@ static irqreturn_t hsc_trigger_handler(int irq, void *private)memcpy (&data->scan.chan[0 ], &data->buffer[0 ],2 );memcpy (&data->scan.chan[1 ], &data->buffer[2 ],2 ); -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)); error:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/pressure/mpl3115.c +2 -2
@@ -191,8 +191,8 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) }mutex_unlock (&data->lock); -iio_push_to_buffers_with_timestamp (indio_dev, buffer, -iio_get_time_ns (indio_dev)); +iio_push_to_buffers_with_ts (indio_dev, buffer,sizeof (buffer), +iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/pressure/rohm-bm1390.c +2 -1
@@ -652,7 +652,8 @@ static irqreturn_t bm1390_trigger_handler(int irq, void *p) } } -iio_push_to_buffers_with_timestamp (idev, &data->buf, data->timestamp); +iio_push_to_buffers_with_ts (idev, &data->buf,sizeof (data->buf), + data->timestamp);iio_trigger_notify_done (idev->trig);return IRQ_HANDLED ;
drivers/iio/pressure/zpa2326.c +2 -2
@@ -618,8 +618,8 @@ static int zpa2326_fill_sample_buffer(struct iio_dev *indio_dev,*/ zpa2326_dbg (indio_dev,"filling raw samples buffer" ); -iio_push_to_buffers_with_timestamp (indio_dev, &sample, - private->timestamp); +iio_push_to_buffers_with_ts (indio_dev, &sample,sizeof (sample), + private->timestamp);return 0 ; }
Signature · 1 line
2.49.0
Jonathan Cameron
maintainerPATCH v3 20/20 iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/magnetometer/af8133j.c | 3 ++- drivers/iio/magnetometer/ak8974.c | 4 ++-- drivers/iio/magnetometer/ak8975.c | 4 ++-- drivers/iio/magnetometer/als31300.c | 3 +-- drivers/iio/magnetometer/bmc150_magn.c | 4 ++-- drivers/iio/magnetometer/hmc5843.h | 2 +- drivers/iio/magnetometer/hmc5843_core.c | 4 ++-- drivers/iio/magnetometer/mag3110.c | 4 ++-- drivers/iio/magnetometer/rm3100-core.c | 4 ++-- drivers/iio/magnetometer/yamaha-yas530.c | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-)
drivers/iio/magnetometer/af8133j.c +2 -1
@@ -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);
drivers/iio/magnetometer/ak8974.c +2 -2
@@ -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);
drivers/iio/magnetometer/ak8975.c +2 -2
@@ -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 ;
drivers/iio/magnetometer/als31300.c +1 -2
@@ -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);
drivers/iio/magnetometer/bmc150_magn.c +2 -2
@@ -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);
drivers/iio/magnetometer/hmc5843.h +1 -1
@@ -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;
drivers/iio/magnetometer/hmc5843_core.c +2 -2
@@ -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);
drivers/iio/magnetometer/mag3110.c +2 -2
@@ -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);
drivers/iio/magnetometer/rm3100-core.c +2 -2
@@ -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);
drivers/iio/magnetometer/yamaha-yas530.c +2 -2
@@ -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)
Signature · 1 line
2.49.0
Quoted 10 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
v3:
- Take the dummy driver back to doing akzalloc()
- Various white space changes.
- Tag collection
v2:
- Add some fixes viaaligned_s64(thanks David)
- Improve naming of new parameter and mark the error check unlikely (thanks Nuno)
Quoted 4 lines
When using the IIO buffers, the length of each scan element is always known to the IIO core (used for sizing kfifo elements etc) and depends on which channels are enabled. Devices often use fixed size structures or arrays.
Jonathan Cameron
maintainerQuoted 11 lines · On Wed, 16 Apr 2025 18:48:07 -0500 David Lechner <[email protected]> wrote:
Quoted 10 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
v3:
- Take the dummy driver back to doing akzalloc()
- Various white space changes.
- Tag collection
v2:
- Add some fixes viaaligned_s64(thanks David)
- Improve naming of new parameter and mark the error check unlikely (thanks Nuno)
Quoted 6 lines
Quoted 4 lines
When using the IIO buffers, the length of each scan element is always known to the IIO core (used for sizing kfifo elements etc) and depends on which channels are enabled. Devices often use fixed size structures or arrays.
Reviewed-by David Lechner <[email protected]>
Applied and pushed out as testing. Thanks,.