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: amplifiers: ada4250: use DMA-safe memory for regmap_bulk_read()

Use DMA-safe memory instead of stack-allocated memory for the call to
regmap_bulk_read() in the ada4250_init() function as this could be used
directly by a SPI controller.

Also remove unnecessary use of get_unaligned_le16() and explicitly
include linux/types.h e.g. for __le16 while we are fixing this up.

Note this is DMA issue does not appear to be an actual bug due to
internals of the regmap SPI implementation. However, for IIO we are
following guidance that we should not make that assumption.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250418-iio-amplifiers-ada4250-simplify-data-buffer-in-init-v1-1-7e7bd6dad423@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
c5858465 b99dbe3a

+5 -5
+5 -5
drivers/iio/amplifiers/ada4250.c
··· 13 13 #include <linux/regmap.h> 14 14 #include <linux/regulator/consumer.h> 15 15 #include <linux/spi/spi.h> 16 - 17 - #include <linux/unaligned.h> 16 + #include <linux/types.h> 18 17 19 18 /* ADA4250 Register Map */ 20 19 #define ADA4250_REG_GAIN_MUX 0x00 ··· 62 63 u8 gain; 63 64 int offset_uv; 64 65 bool refbuf_en; 66 + __le16 reg_val_16 __aligned(IIO_DMA_MINALIGN); 65 67 }; 66 68 67 69 /* ADA4250 Current Bias Source Settings: Disabled, Bandgap Reference, AVDD */ ··· 301 301 { 302 302 int ret; 303 303 u16 chip_id; 304 - u8 data[2] __aligned(8) = {}; 305 304 struct spi_device *spi = st->spi; 306 305 307 306 st->refbuf_en = device_property_read_bool(&spi->dev, "adi,refbuf-enable"); ··· 325 326 if (ret) 326 327 return ret; 327 328 328 - ret = regmap_bulk_read(st->regmap, ADA4250_REG_CHIP_ID, data, 2); 329 + ret = regmap_bulk_read(st->regmap, ADA4250_REG_CHIP_ID, &st->reg_val_16, 330 + sizeof(st->reg_val_16)); 329 331 if (ret) 330 332 return ret; 331 333 332 - chip_id = get_unaligned_le16(data); 334 + chip_id = le16_to_cpu(st->reg_val_16); 333 335 334 336 if (chip_id != ADA4250_CHIP_ID) { 335 337 dev_err(&spi->dev, "Invalid chip ID.\n");