summaryrefslogtreecommitdiff
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-10-13 19:10:24 +0300
committerJonathan Cameron <jic23@kernel.org>2015-10-25 16:41:23 +0300
commitf0566c0c405de543efb6fb8b8988cc7743d85ea6 (patch)
tree9db7d4f42bed5f64c68846377c438cd01097220e /drivers/iio/industrialio-buffer.c
parent0d0e53844797200aa026dfbdfe62f90ccff88300 (diff)
downloadlinux-f0566c0c405de543efb6fb8b8988cc7743d85ea6.tar.xz
iio: Set device watermark based on watermark of all attached buffers
Currently the watermark of the device is only set based on the watermark that is set for the user space buffer. This doesn't consider the watermarks set on any attached in-kernel buffers. Change this so that the watermark of the device should be the minimum of the watermarks over all attached buffers. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index d7e908acb480..7340922d367f 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -610,6 +610,7 @@ static void iio_free_scan_mask(struct iio_dev *indio_dev,
struct iio_device_config {
unsigned int mode;
+ unsigned int watermark;
const unsigned long *scan_mask;
unsigned int scan_bytes;
bool scan_timestamp;
@@ -642,10 +643,14 @@ static int iio_verify_update(struct iio_dev *indio_dev,
if (buffer == remove_buffer)
continue;
modes &= buffer->access->modes;
+ config->watermark = min(config->watermark, buffer->watermark);
}
- if (insert_buffer)
+ if (insert_buffer) {
modes &= insert_buffer->access->modes;
+ config->watermark = min(config->watermark,
+ insert_buffer->watermark);
+ }
/* Definitely possible for devices to support both of these. */
if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
@@ -743,6 +748,10 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
}
}
+ if (indio_dev->info->hwfifo_set_watermark)
+ indio_dev->info->hwfifo_set_watermark(indio_dev,
+ config->watermark);
+
indio_dev->currentmode = config->mode;
if (indio_dev->setup_ops->postenable) {
@@ -974,9 +983,6 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
}
buffer->watermark = val;
-
- if (indio_dev->info->hwfifo_set_watermark)
- indio_dev->info->hwfifo_set_watermark(indio_dev, val);
out:
mutex_unlock(&indio_dev->mlock);