aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_buf.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2015-10-09 12:26:49 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-13 10:28:40 -0700
commit432fbde739583140c7ee937910786a9d740804c9 (patch)
tree3486cf6f9785491067956b219ff1a33dc32344d4 /drivers/staging/comedi/comedi_buf.c
parentstaging: comedi: rename comedi_buf_write_n_available (diff)
downloadlinux-dev-432fbde739583140c7ee937910786a9d740804c9.tar.xz
linux-dev-432fbde739583140c7ee937910786a9d740804c9.zip
staging: comedi: add new comedi_buf_write_n_available()
Add a new function `comedi_buf_write_n_available()` to return the amount of buffer space available for writing, including space already allocated by `comedi_buf_write_alloc()` plus any unallocated space available. This is currently just for internal use by the comedi core, so is not exported. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_buf.c')
-rw-r--r--drivers/staging/comedi/comedi_buf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c
index 4837559ac6b8..90c28016c6c1 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -253,6 +253,14 @@ static unsigned int comedi_buf_write_n_unalloc(struct comedi_subdevice *s)
return free_end - async->buf_write_alloc_count;
}
+unsigned int comedi_buf_write_n_available(struct comedi_subdevice *s)
+{
+ struct comedi_async *async = s->async;
+ unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
+
+ return free_end - async->buf_write_count;
+}
+
/**
* comedi_buf_write_alloc() - Reserve buffer space for writing
* @s: COMEDI subdevice.