Skip to content

Commit b440655

Browse files
larsclausenjic23
authored andcommitted
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>
1 parent 4a60535 commit b440655

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
998998
iio_buffer_show_enable, iio_buffer_store_enable);
999999
static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
10001000
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);
10011003

10021004
static struct attribute *iio_buffer_attrs[] = {
10031005
&dev_attr_length.attr,
@@ -1040,6 +1042,9 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
10401042
if (!buffer->access->set_length)
10411043
attr[0] = &dev_attr_length_ro.attr;
10421044

1045+
if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK)
1046+
attr[2] = &dev_attr_watermark_ro.attr;
1047+
10431048
if (buffer->attrs)
10441049
memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
10451050
sizeof(struct attribute *) * attrcount);

‎include/linux/iio/buffer.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
struct iio_buffer;
1919

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+
2026
/**
2127
* struct iio_buffer_access_funcs - access functions for buffers.
2228
* @store_to: actually store stuff to the buffer
@@ -30,6 +36,7 @@ struct iio_buffer;
3036
* @release: called when the last reference to the buffer is dropped,
3137
* should free all resources allocated by the buffer.
3238
* @modes: Supported operating modes by this buffer type
39+
* @flags: A bitmask combination of INDIO_BUFFER_FLAG_*
3340
*
3441
* The purpose of this structure is to make the buffer element
3542
* modular as event for a given driver, different usecases may require
@@ -54,6 +61,7 @@ struct iio_buffer_access_funcs {
5461
void (*release)(struct iio_buffer *buffer);
5562

5663
unsigned int modes;
64+
unsigned int flags;
5765
};
5866

5967
/**

0 commit comments

Comments
 (0)