Skip to content

Commit abcbdec

Browse files
authored
Merge pull request #26 from mfornero/for-xcomm-zynq
iio: buffer: Expose data available
2 parents 25cbd32 + 69137ca commit abcbdec

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Documentation/ABI/testing/sysfs-bus-iio

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,16 @@ Description:
13901390
the available samples after the timeout expires and thus have a
13911391
maximum delay guarantee.
13921392

1393+
What: /sys/bus/iio/devices/iio:deviceX/buffer/data_available
1394+
KernelVersion: 4.16
1395+
Contact: linux-iio@vger.kernel.org
1396+
Description:
1397+
A read-only value indicating the bytes of data available in the
1398+
buffer. In the case of an output buffer, this indicates the
1399+
amount of empty space available to write data to. In the case of
1400+
an input buffer, this indicates the amount of data available for
1401+
reading.
1402+
13931403
What: /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_enabled
13941404
KernelVersion: 4.2
13951405
Contact: linux-iio@vger.kernel.org

drivers/iio/industrialio-buffer.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,18 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
11211121
return ret ? ret : len;
11221122
}
11231123

1124+
static ssize_t iio_dma_show_data_available(struct device *dev,
1125+
struct device_attribute *attr,
1126+
char *buf)
1127+
{
1128+
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1129+
size_t bytes;
1130+
1131+
bytes = iio_buffer_data_available(indio_dev->buffer);
1132+
1133+
return sprintf(buf, "%zu\n", bytes);
1134+
}
1135+
11241136
static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
11251137
iio_buffer_write_length);
11261138
static struct device_attribute dev_attr_length_ro = __ATTR(length,
@@ -1131,11 +1143,14 @@ static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
11311143
iio_buffer_show_watermark, iio_buffer_store_watermark);
11321144
static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
11331145
S_IRUGO, iio_buffer_show_watermark, NULL);
1146+
static DEVICE_ATTR(data_available, S_IRUGO,
1147+
iio_dma_show_data_available, NULL);
11341148

11351149
static struct attribute *iio_buffer_attrs[] = {
11361150
&dev_attr_length.attr,
11371151
&dev_attr_enable.attr,
11381152
&dev_attr_watermark.attr,
1153+
&dev_attr_data_available.attr,
11391154
};
11401155

11411156
int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)

0 commit comments

Comments
 (0)