]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iio: buffer-dmaengine: split requesting DMA channel from allocating buffer
authorDavid Lechner <dlechner@baylibre.com>
Fri, 7 Feb 2025 20:09:05 +0000 (14:09 -0600)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 10 Feb 2025 18:47:29 +0000 (18:47 +0000)
commit4fe7fd17fe66a5e243c1de7ff32c29fac7039b8d
treec6d4718ac752bf56a50eea07e937f9986a80d472
parenta570114db8ead2e0d90a63888b8e269878ab502f
iio: buffer-dmaengine: split requesting DMA channel from allocating buffer

Refactor the IIO dmaengine buffer code to split requesting the DMA
channel from allocating the buffer. We want to be able to add a new
function where the IIO device driver manages the DMA channel, so these
two actions need to be separate.

To do this, calling dma_request_chan() is moved from
iio_dmaengine_buffer_alloc() to iio_dmaengine_buffer_setup_ext(). A new
__iio_dmaengine_buffer_setup_ext() helper function is added to simplify
error unwinding and will also be used by a new function in a later
patch.

iio_dmaengine_buffer_free() now only frees the buffer and does not
release the DMA channel. A new iio_dmaengine_buffer_teardown() function
is added to unwind everything done in iio_dmaengine_buffer_setup_ext().
This keeps things more symmetrical with obvious pairs alloc/free and
setup/teardown.

Calling dma_get_slave_caps() in iio_dmaengine_buffer_alloc() is moved so
that we can avoid any gotos for error unwinding.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250207-dlech-mainline-spi-engine-offload-2-v8-8-e48a489be48c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/adi-axi-adc.c
drivers/iio/buffer/industrialio-buffer-dmaengine.c
drivers/iio/dac/adi-axi-dac.c
include/linux/iio/buffer-dmaengine.h