From d2f0a48f36aea38e0a5c4b439d5d9c96aecabad9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 4 Oct 2013 12:07:00 +0100 Subject: 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 Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/iio/industrialio-buffer.c') diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 6c7a9c5..5a46c57 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #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); -- cgit v1.1