Linux IIO development
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH] staging:iio: core.  Allow for event chrdev obtaining ioctl if no buffer present.
Date: Fri, 21 Oct 2011 13:46:32 +0200	[thread overview]
Message-ID: <4EA15B98.5050506@metafoo.de> (raw)
In-Reply-To: <1319196865-22766-2-git-send-email-jic23@cam.ac.uk>

On 10/21/2011 01:34 PM, Jonathan Cameron wrote:
> 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.
> 
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---

> I've tested this on the tsl2563 driver and it all seems fine.
> Lars-Peter - could you hammer this a little to see if I have
> missed any corner cases?

This is basically what I had locally for testing my tool, so it should work.
One minor comment though.


>  drivers/staging/iio/iio_core.h            |    2 +-
>  drivers/staging/iio/industrialio-buffer.c |    6 +++++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h
> index 36159e0..ff27f13 100644
> --- a/drivers/staging/iio/iio_core.h
> +++ b/drivers/staging/iio/iio_core.h
> @@ -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)
>  {
> -	return -EINVAL;
> +	return 0;
>  }
>  
>  static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
> diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c
> index bac672d..1a71171 100644
> --- a/drivers/staging/iio/industrialio-buffer.c
> +++ b/drivers/staging/iio/industrialio-buffer.c
> @@ -42,6 +42,8 @@ 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)
> +		return -ENODEV;

I think -EINVAL would be a better return code here.
Quote from the read(3) manpage:
"EINVAL: fd is attached to an object which is unsuitable for reading;"

>  	if (!rb->access->read_first_n)
>  		return -EINVAL;
>  	return rb->access->read_first_n(rb, n, buf);
> @@ -67,7 +69,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;



  reply	other threads:[~2011-10-21 11:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 11:34 [PATCH] staging:iio: allow event usage when no buffer support present Jonathan Cameron
2011-10-21 11:34 ` [PATCH] staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present Jonathan Cameron
2011-10-21 11:46   ` Lars-Peter Clausen [this message]
2011-10-21 11:47     ` Jonathan Cameron
2011-10-21 11:52       ` [PATCH V2] staging:iio: allow event usage when no buffer support present Jonathan Cameron
2011-10-21 11:53         ` [PATCH] staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EA15B98.5050506@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox