Commit 96e00f11 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

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: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bc9f35db
...@@ -49,7 +49,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -49,7 +49,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
static inline int iio_chrdev_buffer_open(struct iio_dev *indio_dev) static inline int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
{ {
return -EINVAL; return 0;
} }
static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev) static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
......
...@@ -43,7 +43,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -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_dev *indio_dev = filp->private_data;
struct iio_buffer *rb = indio_dev->buffer; struct iio_buffer *rb = indio_dev->buffer;
if (!rb->access->read_first_n) if (!rb || !rb->access->read_first_n)
return -EINVAL; return -EINVAL;
return rb->access->read_first_n(rb, n, buf); return rb->access->read_first_n(rb, n, buf);
} }
...@@ -68,7 +68,7 @@ int iio_chrdev_buffer_open(struct iio_dev *indio_dev) ...@@ -68,7 +68,7 @@ int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
{ {
struct iio_buffer *rb = indio_dev->buffer; struct iio_buffer *rb = indio_dev->buffer;
if (!rb) if (!rb)
return -EINVAL; return 0;
if (rb->access->mark_in_use) if (rb->access->mark_in_use)
rb->access->mark_in_use(rb); rb->access->mark_in_use(rb);
return 0; return 0;
...@@ -78,6 +78,8 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev) ...@@ -78,6 +78,8 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
{ {
struct iio_buffer *rb = indio_dev->buffer; struct iio_buffer *rb = indio_dev->buffer;
if (!rb)
return;
clear_bit(IIO_BUSY_BIT_POS, &rb->flags); clear_bit(IIO_BUSY_BIT_POS, &rb->flags);
if (rb->access->unmark_in_use) if (rb->access->unmark_in_use)
rb->access->unmark_in_use(rb); rb->access->unmark_in_use(rb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment