summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorLars-Peter Clausen2013-10-04 13:07:00 +0200
committerJonathan Cameron2013-10-12 13:05:36 +0200
commitd2f0a48f36aea38e0a5c4b439d5d9c96aecabad9 (patch)
tree2bc65afab0101f23f9e31e44500b858444c6d100 /drivers/iio/industrialio-buffer.c
parentiio: Return -ENODEV for file operations if the device has been unregistered (diff)
downloadkernel-qcow2-linux-d2f0a48f36aea38e0a5c4b439d5d9c96aecabad9.tar.gz
kernel-qcow2-linux-d2f0a48f36aea38e0a5c4b439d5d9c96aecabad9.tar.xz
kernel-qcow2-linux-d2f0a48f36aea38e0a5c4b439d5d9c96aecabad9.zip
iio: Wakeup poll and blocking reads when the device is unregistered
Once the device has been unregistered there won't be any new data no matter how long a userspace application waits, so we might as well wake them up and let them know. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 6c7a9c509399..5a46c57a038b 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -20,6 +20,7 @@
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/poll.h>
+#include <linux/sched.h>
#include <linux/iio/iio.h>
#include "iio_core.h"
@@ -75,6 +76,21 @@ unsigned int iio_buffer_poll(struct file *filp,
return 0;
}
+/**
+ * iio_buffer_wakeup_poll - Wakes up the buffer waitqueue
+ * @indio_dev: The IIO device
+ *
+ * Wakes up the event waitqueue used for poll(). Should usually
+ * be called when the device is unregistered.
+ */
+void iio_buffer_wakeup_poll(struct iio_dev *indio_dev)
+{
+ if (!indio_dev->buffer)
+ return;
+
+ wake_up(&indio_dev->buffer->pollq);
+}
+
void iio_buffer_init(struct iio_buffer *buffer)
{
INIT_LIST_HEAD(&buffer->demux_list);