[PATCH 06/10] iio: adc: ti-adc0832: use struct with aligned_s64 timestamp
David Lechner
dlechner at baylibre.com
Fri Apr 18 12:58:25 PDT 2025
Use a struct with aligned s64_timestamp instead of a padded array for
the buffer used for iio_push_to_buffers_with_ts(). This makes it easier
to see the correctness of the size and alignment of the buffer.
Signed-off-by: David Lechner <dlechner at baylibre.com>
---
drivers/iio/adc/ti-adc0832.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c
index cfcdafbe284b103a069857028886411bc72dea4f..f508f7113faa2610a2889f3c36c5a679fa72264d 100644
--- a/drivers/iio/adc/ti-adc0832.c
+++ b/drivers/iio/adc/ti-adc0832.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>
+#include <linux/types.h>
#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>
#include <linux/iio/buffer.h>
@@ -29,12 +30,10 @@ struct adc0832 {
struct regulator *reg;
struct mutex lock;
u8 mux_bits;
- /*
- * Max size needed: 16x 1 byte ADC data + 8 bytes timestamp
- * May be shorter if not all channels are enabled subject
- * to the timestamp remaining 8 byte aligned.
- */
- u8 data[24] __aligned(8);
+ struct {
+ u8 data[16];
+ aligned_s64 timestamp;
+ } buffer;
u8 tx_buf[2] __aligned(IIO_DMA_MINALIGN);
u8 rx_buf[2];
@@ -222,10 +221,10 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p)
goto out;
}
- adc->data[i] = ret;
+ adc->buffer.data[i] = ret;
i++;
}
- iio_push_to_buffers_with_ts(indio_dev, adc->data, sizeof(adc->data),
+ iio_push_to_buffers_with_ts(indio_dev, &adc->buffer, sizeof(adc->buffer),
iio_get_time_ns(indio_dev));
out:
mutex_unlock(&adc->lock);
--
2.43.0
More information about the linux-arm-kernel
mailing list