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

iio: Add support for indicating fixed watermarks

For buffers which have a fixed wake-up watermark the watermark attribute
should be read-only. Add a new FIXED_WATERMARK flag to the
struct iio_buffer_access_funcs, which can be set by a buffer
implementation.

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
b440655b 4a605357

+13
+5
drivers/iio/industrialio-buffer.c
··· 998 998 iio_buffer_show_enable, iio_buffer_store_enable); 999 999 static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR, 1000 1000 iio_buffer_show_watermark, iio_buffer_store_watermark); 1001 + static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark, 1002 + S_IRUGO, iio_buffer_show_watermark, NULL); 1001 1003 1002 1004 static struct attribute *iio_buffer_attrs[] = { 1003 1005 &dev_attr_length.attr, ··· 1041 1039 memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs)); 1042 1040 if (!buffer->access->set_length) 1043 1041 attr[0] = &dev_attr_length_ro.attr; 1042 + 1043 + if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK) 1044 + attr[2] = &dev_attr_watermark_ro.attr; 1044 1045 1045 1046 if (buffer->attrs) 1046 1047 memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
+8
include/linux/iio/buffer.h
··· 18 18 struct iio_buffer; 19 19 20 20 /** 21 + * INDIO_BUFFER_FLAG_FIXED_WATERMARK - Watermark level of the buffer can not be 22 + * configured. It has a fixed value which will be buffer specific. 23 + */ 24 + #define INDIO_BUFFER_FLAG_FIXED_WATERMARK BIT(0) 25 + 26 + /** 21 27 * struct iio_buffer_access_funcs - access functions for buffers. 22 28 * @store_to: actually store stuff to the buffer 23 29 * @read_first_n: try to get a specified number of bytes (must exist) ··· 36 30 * @release: called when the last reference to the buffer is dropped, 37 31 * should free all resources allocated by the buffer. 38 32 * @modes: Supported operating modes by this buffer type 33 + * @flags: A bitmask combination of INDIO_BUFFER_FLAG_* 39 34 * 40 35 * The purpose of this structure is to make the buffer element 41 36 * modular as event for a given driver, different usecases may require ··· 61 54 void (*release)(struct iio_buffer *buffer); 62 55 63 56 unsigned int modes; 57 + unsigned int flags; 64 58 }; 65 59 66 60 /**