From edb85d557d62c4cc1e8305c015653437f03756a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 9 Jan 2013 13:30:22 -0700 Subject: [PATCH] --- yaml --- r: 354028 b: refs/heads/master c: 43f9137df461f6365f76b46f404fd6775eab7d51 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/staging/comedi/comedi_buf.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 596bafcc65d9..09714463c749 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d21af4cbfb7fccbccedc1d9e143a14aee6b1c9ad +refs/heads/master: 43f9137df461f6365f76b46f404fd6775eab7d51 diff --git a/trunk/drivers/staging/comedi/comedi_buf.c b/trunk/drivers/staging/comedi/comedi_buf.c index fd2a92e29fb0..06dd544ec2c5 100644 --- a/trunk/drivers/staging/comedi/comedi_buf.c +++ b/trunk/drivers/staging/comedi/comedi_buf.c @@ -273,14 +273,17 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *async) { unsigned num_bytes; - if (async == NULL) + if (!async) return 0; + num_bytes = async->munge_count - async->buf_read_count; - /* barrier insures the read of munge_count in this - query occurs before any following reads of the buffer which - might be based on the return value from this query. + + /* + * ensure the async buffer 'counts' are read before we + * attempt to read data from the buffer */ smp_rmb(); + return num_bytes; } EXPORT_SYMBOL(comedi_buf_read_n_available);