Lines Matching +full:iio +full:- +full:consumer
1 // SPDX-License-Identifier: GPL-2.0
4 * Author: Lars-Peter Clausen <lars@metafoo.de>
12 #include <linux/iio/iio.h>
13 #include <linux/iio/consumer.h>
14 #include <linux/iio/hw-consumer.h>
15 #include <linux/iio/buffer_impl.h>
18 * struct iio_hw_consumer - IIO hw consumer block
20 * @channels: IIO provider channels.
58 list_for_each_entry(buf, &hwc->buffers, head) { in iio_hw_consumer_get_buffer()
59 if (buf->indio_dev == indio_dev) in iio_hw_consumer_get_buffer()
67 buf->buffer.access = &iio_hw_buf_access; in iio_hw_consumer_get_buffer()
68 buf->indio_dev = indio_dev; in iio_hw_consumer_get_buffer()
69 buf->buffer.scan_mask = buf->scan_mask; in iio_hw_consumer_get_buffer()
71 iio_buffer_init(&buf->buffer); in iio_hw_consumer_get_buffer()
72 list_add_tail(&buf->head, &hwc->buffers); in iio_hw_consumer_get_buffer()
78 * iio_hw_consumer_alloc() - Allocate IIO hardware consumer
79 * @dev: Pointer to consumer device.
92 return ERR_PTR(-ENOMEM); in iio_hw_consumer_alloc()
94 INIT_LIST_HEAD(&hwc->buffers); in iio_hw_consumer_alloc()
96 hwc->channels = iio_channel_get_all(dev); in iio_hw_consumer_alloc()
97 if (IS_ERR(hwc->channels)) { in iio_hw_consumer_alloc()
98 ret = PTR_ERR(hwc->channels); in iio_hw_consumer_alloc()
102 chan = &hwc->channels[0]; in iio_hw_consumer_alloc()
103 while (chan->indio_dev) { in iio_hw_consumer_alloc()
104 buf = iio_hw_consumer_get_buffer(hwc, chan->indio_dev); in iio_hw_consumer_alloc()
106 ret = -ENOMEM; in iio_hw_consumer_alloc()
109 set_bit(chan->channel->scan_index, buf->buffer.scan_mask); in iio_hw_consumer_alloc()
116 list_for_each_entry(buf, &hwc->buffers, head) in iio_hw_consumer_alloc()
117 iio_buffer_put(&buf->buffer); in iio_hw_consumer_alloc()
118 iio_channel_release_all(hwc->channels); in iio_hw_consumer_alloc()
126 * iio_hw_consumer_free() - Free IIO hardware consumer
127 * @hwc: hw consumer to free.
133 iio_channel_release_all(hwc->channels); in iio_hw_consumer_free()
134 list_for_each_entry_safe(buf, n, &hwc->buffers, head) in iio_hw_consumer_free()
135 iio_buffer_put(&buf->buffer); in iio_hw_consumer_free()
146 * devm_iio_hw_consumer_alloc - Resource-managed iio_hw_consumer_alloc()
147 * @dev: Pointer to consumer device.
173 * iio_hw_consumer_enable() - Enable IIO hardware consumer
183 list_for_each_entry(buf, &hwc->buffers, head) { in iio_hw_consumer_enable()
184 ret = iio_update_buffers(buf->indio_dev, &buf->buffer, NULL); in iio_hw_consumer_enable()
192 list_for_each_entry_continue_reverse(buf, &hwc->buffers, head) in iio_hw_consumer_enable()
193 iio_update_buffers(buf->indio_dev, NULL, &buf->buffer); in iio_hw_consumer_enable()
199 * iio_hw_consumer_disable() - Disable IIO hardware consumer
206 list_for_each_entry(buf, &hwc->buffers, head) in iio_hw_consumer_disable()
207 iio_update_buffers(buf->indio_dev, NULL, &buf->buffer); in iio_hw_consumer_disable()
211 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
212 MODULE_DESCRIPTION("Hardware consumer buffer the IIO framework");