summaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorJonathan Cameron2011-10-26 18:27:45 +0200
committerGreg Kroah-Hartman2011-11-27 01:30:31 +0100
commit96e00f110fae862b61f3db9dc25fe8f0f43f77e9 (patch)
treed6639d183446fdc3a57be12e8cec196ef91e5329 /drivers/staging/iio/industrialio-buffer.c
parentstaging:iio:iio_utils.h: Add missing include (diff)
downloadkernel-qcow2-linux-96e00f110fae862b61f3db9dc25fe8f0f43f77e9.tar.gz
kernel-qcow2-linux-96e00f110fae862b61f3db9dc25fe8f0f43f77e9.tar.xz
kernel-qcow2-linux-96e00f110fae862b61f3db9dc25fe8f0f43f77e9.zip
staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present.
Logic bug meant the chrdev would fail to open if there was no buffer support in a driver or in the core. This meant the ioctl to get the event chrdev would fail and hence events were not available. V2: change error to -EINVAL to mark as unsuitable for reading rather than not there. Both are true depending on how you look at it. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/industrialio-buffer.c')
-rw-r--r--drivers/staging/iio/industrialio-buffer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c
index 9df0ce81dade..ecf1e2f6d2dc 100644
--- a/drivers/staging/iio/industrialio-buffer.c
+++ b/drivers/staging/iio/industrialio-buffer.c
@@ -43,7 +43,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
struct iio_dev *indio_dev = filp->private_data;
struct iio_buffer *rb = indio_dev->buffer;
- if (!rb->access->read_first_n)
+ if (!rb || !rb->access->read_first_n)
return -EINVAL;
return rb->access->read_first_n(rb, n, buf);
}
@@ -68,7 +68,7 @@ int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
{
struct iio_buffer *rb = indio_dev->buffer;
if (!rb)
- return -EINVAL;
+ return 0;
if (rb->access->mark_in_use)
rb->access->mark_in_use(rb);
return 0;
@@ -78,6 +78,8 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
{
struct iio_buffer *rb = indio_dev->buffer;
+ if (!rb)
+ return;
clear_bit(IIO_BUSY_BIT_POS, &rb->flags);
if (rb->access->unmark_in_use)
rb->access->unmark_in_use(rb);