[PATCH 04/10] iio: adc: mxs-lradc-adc: use struct with aligned_s64 timestamp
David Lechner
dlechner at baylibre.com
Fri Apr 18 12:58:23 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/mxs-lradc-adc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index 92baf3f5f5601b863c694eb03b6d8f287e4fe6ab..73e42f0ebcaeaaa437ba5c64ecdd7759a1191e6c 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -116,7 +116,10 @@ struct mxs_lradc_adc {
void __iomem *base;
/* Maximum of 8 channels + 8 byte ts */
- u32 buffer[10] __aligned(8);
+ struct {
+ u32 data[8];
+ aligned_u64 ts;
+ } buffer;
struct iio_trigger *trig;
struct completion completion;
spinlock_t lock;
@@ -418,14 +421,14 @@ static irqreturn_t mxs_lradc_adc_trigger_handler(int irq, void *p)
unsigned int i, j = 0;
for_each_set_bit(i, iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS) {
- adc->buffer[j] = readl(adc->base + LRADC_CH(j));
+ adc->buffer.data[j] = readl(adc->base + LRADC_CH(j));
writel(chan_value, adc->base + LRADC_CH(j));
- adc->buffer[j] &= LRADC_CH_VALUE_MASK;
- adc->buffer[j] /= LRADC_DELAY_TIMER_LOOP;
+ adc->buffer.data[j] &= LRADC_CH_VALUE_MASK;
+ adc->buffer.data[j] /= LRADC_DELAY_TIMER_LOOP;
j++;
}
- iio_push_to_buffers_with_ts(iio, adc->buffer, sizeof(adc->buffer),
+ iio_push_to_buffers_with_ts(iio, &adc->buffer, sizeof(adc->buffer),
pf->timestamp);
iio_trigger_notify_done(iio->trig);
--
2.43.0
More information about the linux-arm-kernel
mailing list