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: adc: ad4695: use u16 for buffer elements

Change the type of the buffer elements to u16 since we currently only
support 16-bit word size. The code was originally written to also allow
for 32-bit word size when oversampling is enabled, but so far,
oversampling is only implemented when using SPI offload and therefore
doesn't use this buffer.

AD4695_MAX_CHANNEL_SIZE macro is dropped since it no longer adds any
value.

AD4695_MAX_CHANNELS + 2 is changed to AD4695_MAX_CHANNELS + 1 because
previously we were overallocating. AD4695_MAX_CHANNELS is the number of
of voltage channels and + 1 is for the temperature channel.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Link: https://patch.msgid.link/20250428-iio-introduce-iio_declare_buffer_with_ts-v4-2-6f7f6126f1cb@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
15c82338 93583174

+3 -6
+3 -6
drivers/iio/adc/ad4695.c
··· 106 106 107 107 /* Max number of voltage input channels. */ 108 108 #define AD4695_MAX_CHANNELS 16 109 - /* Max size of 1 raw sample in bytes. */ 110 - #define AD4695_MAX_CHANNEL_SIZE 2 111 109 112 110 enum ad4695_in_pair { 113 111 AD4695_IN_PAIR_REFGND, ··· 160 162 struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3]; 161 163 struct spi_message buf_read_msg; 162 164 /* Raw conversion data received. */ 163 - u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE, 164 - sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN); 165 + u16 buf[ALIGN((AD4695_MAX_CHANNELS + 1) * sizeof(u16), 166 + sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN); 165 167 u16 raw_data; 166 168 /* Commands to send for single conversion. */ 167 169 u16 cnv_cmd; ··· 658 660 iio_for_each_active_channel(indio_dev, bit) { 659 661 xfer = &st->buf_read_xfer[num_xfer]; 660 662 xfer->bits_per_word = 16; 661 - xfer->rx_buf = &st->buf[rx_buf_offset]; 663 + xfer->rx_buf = &st->buf[rx_buf_offset++]; 662 664 xfer->len = 2; 663 - rx_buf_offset += xfer->len; 664 665 665 666 if (bit == temp_chan_bit) { 666 667 temp_en = 1;