Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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á <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-6-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
edeb67fb 6d06978f

+2 -16
+2 -16
drivers/iio/accel/sca3300.c
··· 58 58 SCA3300_SCAN_MAX 59 59 }; 60 60 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 - 70 61 #define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \ 71 62 .type = IIO_ACCEL, \ 72 63 .address = reg, \ ··· 184 193 * @spi: SPI device structure 185 194 * @lock: Data buffer lock 186 195 * @chip: Sensor chip specific information 187 - * @buffer: Triggered buffer: 188 - * -SCA3300: 4 channel 16-bit data + 64-bit timestamp 189 - * -SCL3300: 7 channel 16-bit data + 64-bit timestamp 190 196 * @txbuf: Transmit buffer 191 197 * @rxbuf: Receive buffer 192 198 */ ··· 191 203 struct spi_device *spi; 192 204 struct mutex lock; 193 205 const struct sca3300_chip_info *chip; 194 - u8 buffer[SCA3300_MAX_BUFFER_SIZE] __aligned(sizeof(s64)); 195 206 u8 txbuf[4] __aligned(IIO_DMA_MINALIGN); 196 207 u8 rxbuf[4]; 197 208 }; ··· 479 492 struct iio_dev *indio_dev = pf->indio_dev; 480 493 struct sca3300_data *data = iio_priv(indio_dev); 481 494 int bit, ret, val, i = 0; 482 - s16 *channels = (s16 *)data->buffer; 495 + IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX); 483 496 484 497 iio_for_each_active_channel(indio_dev, bit) { 485 498 ret = sca3300_read_reg(data, indio_dev->channels[bit].address, &val); ··· 492 505 channels[i++] = val; 493 506 } 494 507 495 - iio_push_to_buffers_with_ts(indio_dev, data->buffer, 496 - sizeof(data->buffer), 508 + iio_push_to_buffers_with_ts(indio_dev, channels, sizeof(channels), 497 509 iio_get_time_ns(indio_dev)); 498 510 out: 499 511 iio_trigger_notify_done(indio_dev->trig);