regmap: spi: Don't use spi_write_then_read() Currently SPI reads are implemented using spi_write_then_read(). This is a convenience API which as well as constructing a SPI message from parameters basically the same as for a bytestream read operation also bounces things into a memory buffer to allow callers to use stack or other non-DMAable memory. Since regmap should already be ensuring that everything can be DMAed further up the stack this copy is redundant so switch to using the underlying spi_sync() API with the buffers provided by the core directly. Signed-off-by: Mark Brown <broonie@kernel.org>
diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c index 14b1d88..6a3dbc2 100644 --- a/drivers/base/regmap/regmap-spi.c +++ b/drivers/base/regmap/regmap-spi.c
@@ -94,8 +94,15 @@ static int regmap_spi_read(void *context, { struct device *dev = context; struct spi_device *spi = to_spi_device(dev); + struct spi_message m; + struct spi_transfer t[2] = { { .tx_buf = reg, .len = reg_size, }, + { .rx_buf = val, .len = val_size, }, }; - return spi_write_then_read(spi, reg, reg_size, val, val_size); + spi_message_init(&m); + spi_message_add_tail(&t[0], &m); + spi_message_add_tail(&t[1], &m); + + return spi_sync(spi, &m); } static const struct regmap_bus regmap_spi = {