From 0cf842088d4bc42ae1e9169a4283826ebaef4ed7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 9 Jan 2013 13:31:16 -0700 Subject: [PATCH] --- yaml --- r: 354030 b: refs/heads/master c: 3abfa1066b9e98df434868eda9ba91d7012d45c6 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/staging/comedi/comedi_buf.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index e3b4e0c2ad89..e23ca1f1aaef 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 034cbd17922a8b6c64b227360314167c15c1f031 +refs/heads/master: 3abfa1066b9e98df434868eda9ba91d7012d45c6 diff --git a/trunk/drivers/staging/comedi/comedi_buf.c b/trunk/drivers/staging/comedi/comedi_buf.c index 971f7394a1f0..70d29016f8c0 100644 --- a/trunk/drivers/staging/comedi/comedi_buf.c +++ b/trunk/drivers/staging/comedi/comedi_buf.c @@ -312,14 +312,19 @@ EXPORT_SYMBOL(comedi_buf_read_alloc); /* transfers control of a chunk from reader to free buffer space */ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) { - /* barrier insures data has been read out of - * buffer before read count is incremented */ + unsigned int allocated; + + /* + * ensure data has been read out of buffer before + * the async read count is incremented + */ smp_mb(); - if ((int)(async->buf_read_count + nbytes - - async->buf_read_alloc_count) > 0) { + + allocated = comedi_buf_read_n_allocated(async); + if (nbytes > allocated) { dev_info(async->subdevice->device->class_dev, "attempted to read-free more bytes than have been read-allocated.\n"); - nbytes = async->buf_read_alloc_count - async->buf_read_count; + nbytes = allocated; } async->buf_read_count += nbytes; async->buf_read_ptr += nbytes;