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>
This commit is contained in:
parent
1546d6718d
commit
c02cd5c19c
|
@ -1214,6 +1214,7 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
|
|||
ret = devm_iio_triggered_buffer_setup_ext(dev,
|
||||
indio_dev, NULL,
|
||||
adxl372_trigger_handler,
|
||||
IIO_BUFFER_DIRECTION_IN,
|
||||
&adxl372_buffer_ops,
|
||||
adxl372_fifo_attributes);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -1734,6 +1734,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
|
|||
ret = iio_triggered_buffer_setup_ext(indio_dev,
|
||||
&iio_pollfunc_store_time,
|
||||
bmc150_accel_trigger_handler,
|
||||
IIO_BUFFER_DIRECTION_IN,
|
||||
&bmc150_accel_buffer_ops,
|
||||
fifo_attrs);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -1894,8 +1894,8 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev,
|
|||
fifo_attrs = NULL;
|
||||
|
||||
ret = devm_iio_triggered_buffer_setup_ext(&indio->dev, indio,
|
||||
&iio_pollfunc_store_time,
|
||||
&at91_adc_trigger_handler, &at91_buffer_setup_ops, fifo_attrs);
|
||||
&iio_pollfunc_store_time, &at91_adc_trigger_handler,
|
||||
IIO_BUFFER_DIRECTION_IN, &at91_buffer_setup_ops, fifo_attrs);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "couldn't initialize the buffer.\n");
|
||||
return ret;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* @indio_dev: IIO device structure
|
||||
* @h: Function which will be used as pollfunc top half
|
||||
* @thread: Function which will be used as pollfunc bottom half
|
||||
* @direction: Direction of the data stream (in/out).
|
||||
* @setup_ops: Buffer setup functions to use for this device.
|
||||
* If NULL the default setup functions for triggered
|
||||
* buffers will be used.
|
||||
|
@ -38,6 +39,7 @@
|
|||
int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
|
||||
irqreturn_t (*h)(int irq, void *p),
|
||||
irqreturn_t (*thread)(int irq, void *p),
|
||||
enum iio_buffer_direction direction,
|
||||
const struct iio_buffer_setup_ops *setup_ops,
|
||||
const struct attribute **buffer_attrs)
|
||||
{
|
||||
|
@ -68,6 +70,7 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
|
|||
/* Flag that polled ring buffering is possible */
|
||||
indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
|
||||
|
||||
buffer->direction = direction;
|
||||
buffer->attrs = buffer_attrs;
|
||||
|
||||
ret = iio_device_attach_buffer(indio_dev, buffer);
|
||||
|
@ -105,13 +108,14 @@ int devm_iio_triggered_buffer_setup_ext(struct device *dev,
|
|||
struct iio_dev *indio_dev,
|
||||
irqreturn_t (*h)(int irq, void *p),
|
||||
irqreturn_t (*thread)(int irq, void *p),
|
||||
enum iio_buffer_direction direction,
|
||||
const struct iio_buffer_setup_ops *ops,
|
||||
const struct attribute **buffer_attrs)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops,
|
||||
buffer_attrs);
|
||||
ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, direction,
|
||||
ops, buffer_attrs);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -241,8 +241,9 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
|
|||
fifo_attrs = NULL;
|
||||
|
||||
ret = iio_triggered_buffer_setup_ext(indio_dev,
|
||||
&iio_pollfunc_store_time,
|
||||
NULL, NULL, fifo_attrs);
|
||||
&iio_pollfunc_store_time, NULL,
|
||||
IIO_BUFFER_DIRECTION_IN,
|
||||
NULL, fifo_attrs);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "Triggered Buffer Setup Failed\n");
|
||||
return ret;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#ifndef _LINUX_IIO_TRIGGERED_BUFFER_H_
|
||||
#define _LINUX_IIO_TRIGGERED_BUFFER_H_
|
||||
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
struct attribute;
|
||||
|
@ -11,21 +12,27 @@ struct iio_buffer_setup_ops;
|
|||
int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
|
||||
irqreturn_t (*h)(int irq, void *p),
|
||||
irqreturn_t (*thread)(int irq, void *p),
|
||||
enum iio_buffer_direction direction,
|
||||
const struct iio_buffer_setup_ops *setup_ops,
|
||||
const struct attribute **buffer_attrs);
|
||||
void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev);
|
||||
|
||||
#define iio_triggered_buffer_setup(indio_dev, h, thread, setup_ops) \
|
||||
iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), (setup_ops), NULL)
|
||||
iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), \
|
||||
IIO_BUFFER_DIRECTION_IN, (setup_ops), \
|
||||
NULL)
|
||||
|
||||
int devm_iio_triggered_buffer_setup_ext(struct device *dev,
|
||||
struct iio_dev *indio_dev,
|
||||
irqreturn_t (*h)(int irq, void *p),
|
||||
irqreturn_t (*thread)(int irq, void *p),
|
||||
enum iio_buffer_direction direction,
|
||||
const struct iio_buffer_setup_ops *ops,
|
||||
const struct attribute **buffer_attrs);
|
||||
|
||||
#define devm_iio_triggered_buffer_setup(dev, indio_dev, h, thread, setup_ops) \
|
||||
devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), (setup_ops), NULL)
|
||||
devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), \
|
||||
IIO_BUFFER_DIRECTION_IN, \
|
||||
(setup_ops), NULL)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue