Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
f0566c0c 0d0e5384

+10 -4
+10 -4
drivers/iio/industrialio-buffer.c
··· 610 610 611 611 struct iio_device_config { 612 612 unsigned int mode; 613 + unsigned int watermark; 613 614 const unsigned long *scan_mask; 614 615 unsigned int scan_bytes; 615 616 bool scan_timestamp; ··· 643 642 if (buffer == remove_buffer) 644 643 continue; 645 644 modes &= buffer->access->modes; 645 + config->watermark = min(config->watermark, buffer->watermark); 646 646 } 647 647 648 - if (insert_buffer) 648 + if (insert_buffer) { 649 649 modes &= insert_buffer->access->modes; 650 + config->watermark = min(config->watermark, 651 + insert_buffer->watermark); 652 + } 650 653 651 654 /* Definitely possible for devices to support both of these. */ 652 655 if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { ··· 747 742 goto err_run_postdisable; 748 743 } 749 744 } 745 + 746 + if (indio_dev->info->hwfifo_set_watermark) 747 + indio_dev->info->hwfifo_set_watermark(indio_dev, 748 + config->watermark); 750 749 751 750 indio_dev->currentmode = config->mode; 752 751 ··· 983 974 } 984 975 985 976 buffer->watermark = val; 986 - 987 - if (indio_dev->info->hwfifo_set_watermark) 988 - indio_dev->info->hwfifo_set_watermark(indio_dev, val); 989 977 out: 990 978 mutex_unlock(&indio_dev->mlock); 991 979