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

iio: triggered-buffer: extend support to configure output buffers

Now that output (kfifo) buffers are supported, we need to extend the
{devm_}iio_triggered_buffer_setup_ext() parameter list to take a direction
parameter.

This allows us to attach an output triggered buffer to a DAC device.
Unfortunately it's a bit difficult to add another macro to avoid changing 5
drivers where {devm_}iio_triggered_buffer_setup_ext() is used.
Well, it's doable, but may not be worth the trouble vs just updating all
these 5 drivers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Mihail Chindris <mihail.chindris@analog.com>
Link: https://lore.kernel.org/r/20211007080035.2531-4-mihail.chindris@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
c02cd5c1 1546d671

+22 -8
+1
drivers/iio/accel/adxl372.c
··· 1214 1214 ret = devm_iio_triggered_buffer_setup_ext(dev, 1215 1215 indio_dev, NULL, 1216 1216 adxl372_trigger_handler, 1217 + IIO_BUFFER_DIRECTION_IN, 1217 1218 &adxl372_buffer_ops, 1218 1219 adxl372_fifo_attributes); 1219 1220 if (ret < 0)
+1
drivers/iio/accel/bmc150-accel-core.c
··· 1734 1734 ret = iio_triggered_buffer_setup_ext(indio_dev, 1735 1735 &iio_pollfunc_store_time, 1736 1736 bmc150_accel_trigger_handler, 1737 + IIO_BUFFER_DIRECTION_IN, 1737 1738 &bmc150_accel_buffer_ops, 1738 1739 fifo_attrs); 1739 1740 if (ret < 0) {
+2 -2
drivers/iio/adc/at91-sama5d2_adc.c
··· 1894 1894 fifo_attrs = NULL; 1895 1895 1896 1896 ret = devm_iio_triggered_buffer_setup_ext(&indio->dev, indio, 1897 - &iio_pollfunc_store_time, 1898 - &at91_adc_trigger_handler, &at91_buffer_setup_ops, fifo_attrs); 1897 + &iio_pollfunc_store_time, &at91_adc_trigger_handler, 1898 + IIO_BUFFER_DIRECTION_IN, &at91_buffer_setup_ops, fifo_attrs); 1899 1899 if (ret < 0) { 1900 1900 dev_err(dev, "couldn't initialize the buffer.\n"); 1901 1901 return ret;
+6 -2
drivers/iio/buffer/industrialio-triggered-buffer.c
··· 19 19 * @indio_dev: IIO device structure 20 20 * @h: Function which will be used as pollfunc top half 21 21 * @thread: Function which will be used as pollfunc bottom half 22 + * @direction: Direction of the data stream (in/out). 22 23 * @setup_ops: Buffer setup functions to use for this device. 23 24 * If NULL the default setup functions for triggered 24 25 * buffers will be used. ··· 39 38 int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev, 40 39 irqreturn_t (*h)(int irq, void *p), 41 40 irqreturn_t (*thread)(int irq, void *p), 41 + enum iio_buffer_direction direction, 42 42 const struct iio_buffer_setup_ops *setup_ops, 43 43 const struct attribute **buffer_attrs) 44 44 { ··· 70 68 /* Flag that polled ring buffering is possible */ 71 69 indio_dev->modes |= INDIO_BUFFER_TRIGGERED; 72 70 71 + buffer->direction = direction; 73 72 buffer->attrs = buffer_attrs; 74 73 75 74 ret = iio_device_attach_buffer(indio_dev, buffer); ··· 108 105 struct iio_dev *indio_dev, 109 106 irqreturn_t (*h)(int irq, void *p), 110 107 irqreturn_t (*thread)(int irq, void *p), 108 + enum iio_buffer_direction direction, 111 109 const struct iio_buffer_setup_ops *ops, 112 110 const struct attribute **buffer_attrs) 113 111 { 114 112 int ret; 115 113 116 - ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops, 117 - buffer_attrs); 114 + ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, direction, 115 + ops, buffer_attrs); 118 116 if (ret) 119 117 return ret; 120 118
+3 -2
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
··· 241 241 fifo_attrs = NULL; 242 242 243 243 ret = iio_triggered_buffer_setup_ext(indio_dev, 244 - &iio_pollfunc_store_time, 245 - NULL, NULL, fifo_attrs); 244 + &iio_pollfunc_store_time, NULL, 245 + IIO_BUFFER_DIRECTION_IN, 246 + NULL, fifo_attrs); 246 247 if (ret) { 247 248 dev_err(&indio_dev->dev, "Triggered Buffer Setup Failed\n"); 248 249 return ret;
+9 -2
include/linux/iio/triggered_buffer.h
··· 2 2 #ifndef _LINUX_IIO_TRIGGERED_BUFFER_H_ 3 3 #define _LINUX_IIO_TRIGGERED_BUFFER_H_ 4 4 5 + #include <linux/iio/buffer.h> 5 6 #include <linux/interrupt.h> 6 7 7 8 struct attribute; ··· 12 11 int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev, 13 12 irqreturn_t (*h)(int irq, void *p), 14 13 irqreturn_t (*thread)(int irq, void *p), 14 + enum iio_buffer_direction direction, 15 15 const struct iio_buffer_setup_ops *setup_ops, 16 16 const struct attribute **buffer_attrs); 17 17 void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev); 18 18 19 19 #define iio_triggered_buffer_setup(indio_dev, h, thread, setup_ops) \ 20 - iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), (setup_ops), NULL) 20 + iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), \ 21 + IIO_BUFFER_DIRECTION_IN, (setup_ops), \ 22 + NULL) 21 23 22 24 int devm_iio_triggered_buffer_setup_ext(struct device *dev, 23 25 struct iio_dev *indio_dev, 24 26 irqreturn_t (*h)(int irq, void *p), 25 27 irqreturn_t (*thread)(int irq, void *p), 28 + enum iio_buffer_direction direction, 26 29 const struct iio_buffer_setup_ops *ops, 27 30 const struct attribute **buffer_attrs); 28 31 29 32 #define devm_iio_triggered_buffer_setup(dev, indio_dev, h, thread, setup_ops) \ 30 - devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), (setup_ops), NULL) 33 + devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), \ 34 + IIO_BUFFER_DIRECTION_IN, \ 35 + (setup_ops), NULL) 31 36 32 37 #endif