mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 23:33:01 -04:00
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>
This commit is contained in:
committed by
Jonathan Cameron
parent
93583174a3
commit
15c82338b3
@@ -106,8 +106,6 @@
|
||||
|
||||
/* Max number of voltage input channels. */
|
||||
#define AD4695_MAX_CHANNELS 16
|
||||
/* Max size of 1 raw sample in bytes. */
|
||||
#define AD4695_MAX_CHANNEL_SIZE 2
|
||||
|
||||
enum ad4695_in_pair {
|
||||
AD4695_IN_PAIR_REFGND,
|
||||
@@ -162,8 +160,8 @@ struct ad4695_state {
|
||||
struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3];
|
||||
struct spi_message buf_read_msg;
|
||||
/* Raw conversion data received. */
|
||||
u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE,
|
||||
sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN);
|
||||
u16 buf[ALIGN((AD4695_MAX_CHANNELS + 1) * sizeof(u16),
|
||||
sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN);
|
||||
u16 raw_data;
|
||||
/* Commands to send for single conversion. */
|
||||
u16 cnv_cmd;
|
||||
@@ -660,9 +658,8 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
|
||||
iio_for_each_active_channel(indio_dev, bit) {
|
||||
xfer = &st->buf_read_xfer[num_xfer];
|
||||
xfer->bits_per_word = 16;
|
||||
xfer->rx_buf = &st->buf[rx_buf_offset];
|
||||
xfer->rx_buf = &st->buf[rx_buf_offset++];
|
||||
xfer->len = 2;
|
||||
rx_buf_offset += xfer->len;
|
||||
|
||||
if (bit == temp_chan_bit) {
|
||||
temp_en = 1;
|
||||
|
||||
Reference in New Issue
Block a user