Skip to content

Commit edeb67f

Browse files
dlechjic23
authored andcommitted
iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS
Use IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Reviewed-by: Nuno Sá <[email protected]> Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-6-4aee1b9f1b89@baylibre.com Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 6d06978 commit edeb67f

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

drivers/iio/accel/sca3300.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ enum sca3300_scan_indexes {
5858
SCA3300_SCAN_MAX
5959
};
6060

61-
/*
62-
* Buffer size max case:
63-
* Three accel channels, two bytes per channel.
64-
* Temperature channel, two bytes.
65-
* Three incli channels, two bytes per channel.
66-
* Timestamp channel, eight bytes.
67-
*/
68-
#define SCA3300_MAX_BUFFER_SIZE (ALIGN(sizeof(s16) * SCA3300_SCAN_MAX, sizeof(s64)) + sizeof(s64))
69-
7061
#define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \
7162
.type = IIO_ACCEL, \
7263
.address = reg, \
@@ -193,17 +184,13 @@ struct sca3300_chip_info {
193184
* @spi: SPI device structure
194185
* @lock: Data buffer lock
195186
* @chip: Sensor chip specific information
196-
* @buffer: Triggered buffer:
197-
* -SCA3300: 4 channel 16-bit data + 64-bit timestamp
198-
* -SCL3300: 7 channel 16-bit data + 64-bit timestamp
199187
* @txbuf: Transmit buffer
200188
* @rxbuf: Receive buffer
201189
*/
202190
struct sca3300_data {
203191
struct spi_device *spi;
204192
struct mutex lock;
205193
const struct sca3300_chip_info *chip;
206-
u8 buffer[SCA3300_MAX_BUFFER_SIZE] __aligned(sizeof(s64));
207194
u8 txbuf[4] __aligned(IIO_DMA_MINALIGN);
208195
u8 rxbuf[4];
209196
};
@@ -492,7 +479,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p)
492479
struct iio_dev *indio_dev = pf->indio_dev;
493480
struct sca3300_data *data = iio_priv(indio_dev);
494481
int bit, ret, val, i = 0;
495-
s16 *channels = (s16 *)data->buffer;
482+
IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX);
496483

497484
iio_for_each_active_channel(indio_dev, bit) {
498485
ret = sca3300_read_reg(data, indio_dev->channels[bit].address, &val);
@@ -505,8 +492,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p)
505492
channels[i++] = val;
506493
}
507494

508-
iio_push_to_buffers_with_ts(indio_dev, data->buffer,
509-
sizeof(data->buffer),
495+
iio_push_to_buffers_with_ts(indio_dev, channels, sizeof(channels),
510496
iio_get_time_ns(indio_dev));
511497
out:
512498
iio_trigger_notify_done(indio_dev->trig);

0 commit comments

Comments
 (0)