Skip to content

Commit

Permalink
IIO: consumer: allow to set buffer sizes
Browse files Browse the repository at this point in the history
Add iio consumer API to set buffer size and watermark according
to sysfs API.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Arnaud Pouliquen authored and Mark Brown committed Jan 10, 2018
1 parent eca9498 commit 16cbca0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/iio/buffer/industrialio-buffer-cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
}
EXPORT_SYMBOL_GPL(iio_channel_get_all_cb);

int iio_channel_cb_set_buffer_watermark(struct iio_cb_buffer *cb_buff,
size_t watermark)
{
if (!watermark)
return -EINVAL;
cb_buff->buffer.watermark = watermark;

return 0;
}
EXPORT_SYMBOL_GPL(iio_channel_cb_set_buffer_watermark);

int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff)
{
return iio_update_buffers(cb_buff->indio_dev, &cb_buff->buffer,
Expand Down
11 changes: 11 additions & 0 deletions include/linux/iio/consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
int (*cb)(const void *data,
void *private),
void *private);
/**
* iio_channel_cb_set_buffer_watermark() - set the buffer watermark.
* @cb_buffer: The callback buffer from whom we want the channel
* information.
* @watermark: buffer watermark in bytes.
*
* This function allows to configure the buffer watermark.
*/
int iio_channel_cb_set_buffer_watermark(struct iio_cb_buffer *cb_buffer,
size_t watermark);

/**
* iio_channel_release_all_cb() - release and unregister the callback.
* @cb_buffer: The callback buffer that was allocated.
Expand Down

0 comments on commit 16cbca0

Please sign in to comment.