diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2012-12-19 15:44:24 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-07 14:25:49 -0800 |
commit | 9682e28c49f85d4a3c5d2cab401d03ae266f6dde (patch) | |
tree | 9cc6d6ec3e34f0d25930cc91dd02b4fa0b47ea47 /drivers/staging | |
parent | c098c21a9d32f1cd828f23e617cb55909c75e7e2 (diff) | |
download | kernel_goldelico_gta04-9682e28c49f85d4a3c5d2cab401d03ae266f6dde.zip kernel_goldelico_gta04-9682e28c49f85d4a3c5d2cab401d03ae266f6dde.tar.gz kernel_goldelico_gta04-9682e28c49f85d4a3c5d2cab401d03ae266f6dde.tar.bz2 |
staging: comedi: comedi_fops: introduce comedi_is_subdevice_idle()
Introduce, and use, a helper to check the subdevice runflags to see if
it is not in error and not running.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index eb96217..33f5187 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -389,6 +389,13 @@ static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s) return (runflags & SRF_ERROR) ? true : false; } +static bool comedi_is_subdevice_idle(struct comedi_subdevice *s) +{ + unsigned runflags = comedi_get_subdevice_runflags(s); + + return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true; +} + /* This function restores a subdevice to an idle state. */ @@ -834,9 +841,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read); comedi_buf_read_free(async, bi.bytes_read); - if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR | - SRF_RUNNING)) - && async->buf_write_count == async->buf_read_count) { + if (comedi_is_subdevice_idle(s) && + async->buf_write_count == async->buf_read_count) { do_become_nonbusy(dev, s); } } @@ -2061,7 +2067,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, buf += n; break; /* makes device work like a pipe */ } - if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR | SRF_RUNNING)) && + if (comedi_is_subdevice_idle(s) && async->buf_read_count - async->buf_write_count == 0) { do_become_nonbusy(dev, s); } |