Skip to content

Commit f0566c0

Browse files
larsclausenjic23
authored andcommitted
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>
1 parent 0d0e538 commit f0566c0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/iio/industrialio-buffer.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ static void iio_free_scan_mask(struct iio_dev *indio_dev,
610610

611611
struct iio_device_config {
612612
unsigned int mode;
613+
unsigned int watermark;
613614
const unsigned long *scan_mask;
614615
unsigned int scan_bytes;
615616
bool scan_timestamp;
@@ -642,10 +643,14 @@ static int iio_verify_update(struct iio_dev *indio_dev,
642643
if (buffer == remove_buffer)
643644
continue;
644645
modes &= buffer->access->modes;
646+
config->watermark = min(config->watermark, buffer->watermark);
645647
}
646648

647-
if (insert_buffer)
649+
if (insert_buffer) {
648650
modes &= insert_buffer->access->modes;
651+
config->watermark = min(config->watermark,
652+
insert_buffer->watermark);
653+
}
649654

650655
/* Definitely possible for devices to support both of these. */
651656
if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
@@ -743,6 +748,10 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
743748
}
744749
}
745750

751+
if (indio_dev->info->hwfifo_set_watermark)
752+
indio_dev->info->hwfifo_set_watermark(indio_dev,
753+
config->watermark);
754+
746755
indio_dev->currentmode = config->mode;
747756

748757
if (indio_dev->setup_ops->postenable) {
@@ -974,9 +983,6 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
974983
}
975984

976985
buffer->watermark = val;
977-
978-
if (indio_dev->info->hwfifo_set_watermark)
979-
indio_dev->info->hwfifo_set_watermark(indio_dev, val);
980986
out:
981987
mutex_unlock(&indio_dev->mlock);
982988

0 commit comments

Comments
 (0)