diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-06-20 10:58:28 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-06-26 20:00:44 -0400 |
commit | f4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e (patch) | |
tree | 615d870861548b465c1ae279c94f89407305647f /drivers/staging/comedi/comedidev.h | |
parent | 5fc391853ea2a9070ae4161e21783e64c1b79f6c (diff) |
staging: comedi: introduce comedi_buf_n_bytes_ready()
Introduce an inline helper to return the number of bytes that are
ready to read from the comedi_async buffer. Use the helper in the
comedi drivers that currently do the calculation as part of the
(*poll) operation.
Also, use the helper in comedi_fops where the calculation is used as
part of the subdevice going nonbusy.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedidev.h')
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 71851bdd4273..83fd1553ff93 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -400,6 +400,11 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) */ int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); +static inline unsigned int comedi_buf_n_bytes_ready(struct comedi_subdevice *s) +{ + return s->async->buf_write_count - s->async->buf_read_count; +} + unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); |