Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: buffer-dmaengine: export buffer alloc and free functions

Export iio_dmaengine_buffer_free() and iio_dmaengine_buffer_alloc().
This is in preparation of introducing IIO backends support. This will
allow us to allocate a buffer and control it's lifetime from a device
different from the one holding the DMA firmware properties. Effectively,
in this case the struct device holding the firmware information about
the DMA channels is not the same as iio_dev->dev.parent (typical case).

While at it, namespace the buffer-dmaengine exports and update the
current user of these buffers.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240210-iio-backend-v11-4-f5242a5fb42a@analog.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
9c446288 4b0b159a

+9 -3
+1
drivers/iio/adc/adi-axi-adc.c
··· 447 447 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); 448 448 MODULE_DESCRIPTION("Analog Devices Generic AXI ADC IP core driver"); 449 449 MODULE_LICENSE("GPL v2"); 450 + MODULE_IMPORT_NS(IIO_DMAENGINE_BUFFER);
+5 -3
drivers/iio/buffer/industrialio-buffer-dmaengine.c
··· 159 159 * Once done using the buffer iio_dmaengine_buffer_free() should be used to 160 160 * release it. 161 161 */ 162 - static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, 162 + struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, 163 163 const char *channel) 164 164 { 165 165 struct dmaengine_buffer *dmaengine_buffer; ··· 210 210 kfree(dmaengine_buffer); 211 211 return ERR_PTR(ret); 212 212 } 213 + EXPORT_SYMBOL_NS_GPL(iio_dmaengine_buffer_alloc, IIO_DMAENGINE_BUFFER); 213 214 214 215 /** 215 216 * iio_dmaengine_buffer_free() - Free dmaengine buffer ··· 218 217 * 219 218 * Frees a buffer previously allocated with iio_dmaengine_buffer_alloc(). 220 219 */ 221 - static void iio_dmaengine_buffer_free(struct iio_buffer *buffer) 220 + void iio_dmaengine_buffer_free(struct iio_buffer *buffer) 222 221 { 223 222 struct dmaengine_buffer *dmaengine_buffer = 224 223 iio_buffer_to_dmaengine_buffer(buffer); ··· 228 227 229 228 iio_buffer_put(buffer); 230 229 } 230 + EXPORT_SYMBOL_NS_GPL(iio_dmaengine_buffer_free, IIO_DMAENGINE_BUFFER); 231 231 232 232 static void __devm_iio_dmaengine_buffer_free(void *buffer) 233 233 { ··· 289 287 290 288 return iio_device_attach_buffer(indio_dev, buffer); 291 289 } 292 - EXPORT_SYMBOL_GPL(devm_iio_dmaengine_buffer_setup); 290 + EXPORT_SYMBOL_NS_GPL(devm_iio_dmaengine_buffer_setup, IIO_DMAENGINE_BUFFER); 293 291 294 292 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 295 293 MODULE_DESCRIPTION("DMA buffer for the IIO framework");
+3
include/linux/iio/buffer-dmaengine.h
··· 10 10 struct iio_dev; 11 11 struct device; 12 12 13 + struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, 14 + const char *channel); 15 + void iio_dmaengine_buffer_free(struct iio_buffer *buffer); 13 16 int devm_iio_dmaengine_buffer_setup(struct device *dev, 14 17 struct iio_dev *indio_dev, 15 18 const char *channel);