All of lore.kernel.org
 help / color / mirror / Atom feed
* KFiFo Poll support
@ 2012-08-27 17:24 Pandruvada, Srinivas
  2012-08-27 17:51 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Pandruvada, Srinivas @ 2012-08-27 17:24 UTC (permalink / raw)
  To: Jonathan Cameron (jic23@kernel.org); +Cc: linux-iio@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 2081 bytes --]

Hi Jonathan,

You have circulated a patch to support polling on KFifo, but that was never merged.

I have used in my tree with your authorship:

commit ae09253bf19a607ea0614051ba0bdb04d5f23689
Author: Jonathan Cameron <jic23@kernel.org>
Date:   Fri Jun 8 13:08:53 2012 -0700

    KFiFO : Poll support

    Implements poll system call support on IIO Kfifo buffers.

    Change-Id: I6739382b7b81951e5b4498fc04356b3652941058
    Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>

diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 6bf9d05..e8033a4 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -6,6 +6,7 @@
#include <linux/kfifo.h>
#include <linux/mutex.h>
#include <linux/iio/kfifo_buf.h>
+#include <linux/sched.h>
 struct iio_kfifo {
               struct iio_buffer buffer;
@@ -35,6 +36,7 @@ static int iio_request_update_kfifo(struct iio_buffer *r)
               kfifo_free(&buf->kf);
               ret = __iio_allocate_kfifo(buf, buf->buffer.bytes_per_datum,
                                                                  buf->buffer.length);
+             r->stufftoread = false;
error_ret:
               return ret;
}
@@ -97,6 +99,8 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
               ret = kfifo_in(&kf->kf, data, r->bytes_per_datum);
               if (ret != r->bytes_per_datum)
                               return -EBUSY;
+             r->stufftoread = true;
+             wake_up_interruptible(&r->pollq);
               return 0;
}
@@ -111,6 +115,11 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
                n = rounddown(n, r->bytes_per_datum);
               ret = kfifo_to_user(&kf->kf, buf, n, &copied);
+             if (kfifo_is_empty(&kf->kf))
+                             r->stufftoread = false;
+             /* verify it is still empty to avoid race */
+             if (!kfifo_is_empty(&kf->kf))
+                             r->stufftoread = true;
                return copied;
}

Thanks,
Srinivas

[-- Attachment #2: Type: text/html, Size: 7980 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: KFiFo Poll support
  2012-08-27 17:24 KFiFo Poll support Pandruvada, Srinivas
@ 2012-08-27 17:51 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2012-08-27 17:51 UTC (permalink / raw)
  To: Pandruvada, Srinivas; +Cc: linux-iio@vger.kernel.org

As this just conviently came up,

I've merged a 3 patch variant of the original series this was in.
Patch 1 was broken in to two as I was originally naughty and handled
some unrelated error cases whilst I was doing the conversion to
fixed record size use of kfifo.

Partly this sat in my queue for a long time because of a lack
of explicit feedback. Lars-Peter was kind enough to give it a
test, but wasn't really interested in the support so didn't
hammer it.

I may be the maintainer but I'd still like people to review
my patches!

(speaking of which... the push buffer stuff is still out there
and hopefully I'll get a chance to do another rebase of that
sometime in the next few days!)

Anyhow, the kfifo improvements will be in my togreg branch
shortly on kernel.org.
> 
>  
> 
> You have circulated a patch to support polling on KFifo, but that was never merged.
> 
>  
> 
> I have used in my tree with your authorship:
> 
>  
> 
> commit ae09253bf19a607ea0614051ba0bdb04d5f23689
> 
> Author: Jonathan Cameron <jic23@kernel.org>
> 
> Date:   Fri Jun 8 13:08:53 2012 -0700
> 
>  
> 
>     KFiFO : Poll support
> 
>    
> 
>     Implements poll system call support on IIO Kfifo buffers.
> 
>    
> 
>     Change-Id: I6739382b7b81951e5b4498fc04356b3652941058
> 
>     Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
> 
>  
> 
> diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
> 
> index 6bf9d05..e8033a4 100644
> 
> --- a/drivers/iio/kfifo_buf.c
> 
> +++ b/drivers/iio/kfifo_buf.c
> 
> @@ -6,6 +6,7 @@
> 
> #include <linux/kfifo.h>
> 
> #include <linux/mutex.h>
> 
> #include <linux/iio/kfifo_buf.h>
> 
> +#include <linux/sched.h>
> 
>  struct iio_kfifo {
> 
>                struct iio_buffer buffer;
> 
> @@ -35,6 +36,7 @@ static int iio_request_update_kfifo(struct iio_buffer *r)
> 
>                kfifo_free(&buf->kf);
> 
>                ret = __iio_allocate_kfifo(buf, buf->buffer.bytes_per_datum,
> 
>                                                                   buf->buffer.length);
> 
> +             r->stufftoread = false;
> 
> error_ret:
> 
>                return ret;
> 
> }
> 
> @@ -97,6 +99,8 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
> 
>                ret = kfifo_in(&kf->kf, data, r->bytes_per_datum);
> 
>                if (ret != r->bytes_per_datum)
> 
>                                return -EBUSY;
> 
> +             r->stufftoread = true;
> 
> +             wake_up_interruptible(&r->pollq);
> 
>                return 0;
> 
> }
> 
> @@ -111,6 +115,11 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
> 
>                 n = rounddown(n, r->bytes_per_datum);
> 
>                ret = kfifo_to_user(&kf->kf, buf, n, &copied);
> 
> +             if (kfifo_is_empty(&kf->kf))
> 
> +                             r->stufftoread = false;
> 
> +             /* verify it is still empty to avoid race */
> 
> +             if (!kfifo_is_empty(&kf->kf))
> 
> +                             r->stufftoread = true;
> 
>                 return copied;
> 
> }
> 
>  
> 
> Thanks,
> 
> Srinivas
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-27 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-27 17:24 KFiFo Poll support Pandruvada, Srinivas
2012-08-27 17:51 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.