aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/industrialio-buffer.c10
-rw-r--r--include/linux/iio/buffer.h3
2 files changed, 12 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 7f9152c3c4d3..4dcc3a0f9930 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -37,6 +37,14 @@ static bool iio_buffer_is_active(struct iio_buffer *buf)
37 return !list_empty(&buf->buffer_list); 37 return !list_empty(&buf->buffer_list);
38} 38}
39 39
40static bool iio_buffer_data_available(struct iio_buffer *buf)
41{
42 if (buf->access->data_available)
43 return buf->access->data_available(buf);
44
45 return buf->stufftoread;
46}
47
40/** 48/**
41 * iio_buffer_read_first_n_outer() - chrdev read for buffer access 49 * iio_buffer_read_first_n_outer() - chrdev read for buffer access
42 * 50 *
@@ -70,7 +78,7 @@ unsigned int iio_buffer_poll(struct file *filp,
70 return -ENODEV; 78 return -ENODEV;
71 79
72 poll_wait(filp, &rb->pollq, wait); 80 poll_wait(filp, &rb->pollq, wait);
73 if (rb->stufftoread) 81 if (iio_buffer_data_available(rb))
74 return POLLIN | POLLRDNORM; 82 return POLLIN | POLLRDNORM;
75 /* need a way of knowing if there may be enough data... */ 83 /* need a way of knowing if there may be enough data... */
76 return 0; 84 return 0;
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 15607b45221a..519392763393 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -21,6 +21,8 @@ struct iio_buffer;
21 * struct iio_buffer_access_funcs - access functions for buffers. 21 * struct iio_buffer_access_funcs - access functions for buffers.
22 * @store_to: actually store stuff to the buffer 22 * @store_to: actually store stuff to the buffer
23 * @read_first_n: try to get a specified number of bytes (must exist) 23 * @read_first_n: try to get a specified number of bytes (must exist)
24 * @data_available: indicates whether data for reading from the buffer is
25 * available.
24 * @request_update: if a parameter change has been marked, update underlying 26 * @request_update: if a parameter change has been marked, update underlying
25 * storage. 27 * storage.
26 * @get_bytes_per_datum:get current bytes per datum 28 * @get_bytes_per_datum:get current bytes per datum
@@ -43,6 +45,7 @@ struct iio_buffer_access_funcs {
43 int (*read_first_n)(struct iio_buffer *buffer, 45 int (*read_first_n)(struct iio_buffer *buffer,
44 size_t n, 46 size_t n,
45 char __user *buf); 47 char __user *buf);
48 bool (*data_available)(struct iio_buffer *buffer);
46 49
47 int (*request_update)(struct iio_buffer *buffer); 50 int (*request_update)(struct iio_buffer *buffer);
48 51