Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1338325
| From | Ian Abbott <abbotti@mev.co.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/8] staging: comedi: COMEDI_BUFINFO: return error if no active command |
| Date | 2016-02-19 17:20 +0100 |
| Message-ID | <r3VWH-7Ih-41@gated-at.bofh.it> (permalink) |
| References | <r3VWG-7Ih-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer and/or get the current buffer position. If no asynchronous
command is active (started via the file object that issued this ioctl),
this information is meaningless. Change it to return an error
(`-EINVAL`) in this case. Prior to this change, if a command was
started via a different file object, the ioctl returned `-EACCES`, but
now it will return `-EINVAL`, which is consistent with the current
behavior of the "read" and "write" file operation handlers.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
drivers/staging/comedi/comedi_fops.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index b7c9270..a9fabf7 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1123,24 +1123,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
async = s->async;
- if (!async) {
- dev_dbg(dev->class_dev,
- "subdevice does not have async capability\n");
- bi.buf_write_ptr = 0;
- bi.buf_read_ptr = 0;
- bi.buf_write_count = 0;
- bi.buf_read_count = 0;
- bi.bytes_read = 0;
- bi.bytes_written = 0;
- goto copyback;
- }
- if (!s->busy) {
- bi.bytes_read = 0;
- bi.bytes_written = 0;
- goto copyback_position;
- }
- if (s->busy != file)
- return -EACCES;
+ if (!async || s->busy != file)
+ return -EINVAL;
if (!(async->cmd.flags & CMDF_WRITE)) {
/* command was set up in "read" direction */
@@ -1165,7 +1149,6 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
bi.bytes_read = 0;
}
-copyback_position:
bi.buf_write_count = async->buf_write_count;
bi.buf_write_ptr = async->buf_write_ptr;
bi.buf_read_count = async->buf_read_count;
@@ -1174,7 +1157,6 @@ copyback_position:
if (become_nonbusy)
do_become_nonbusy(dev, s);
-copyback:
if (copy_to_user(arg, &bi, sizeof(bi)))
return -EFAULT;
--
2.7.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
staging: comedi: COMEDI_BUFINFO: some behavioural changes Ian Abbott <abbotti@mev.co.uk> - 2016-02-19 17:20 +0100 [PATCH 2/8] staging: comedi: COMEDI_BUFINFO: force bytes_read or bytes_written to 0 Ian Abbott <abbotti@mev.co.uk> - 2016-02-19 17:20 +0100 [PATCH 5/8] staging: comedi: COMEDI_BUFINFO: return error if no active command Ian Abbott <abbotti@mev.co.uk> - 2016-02-19 17:20 +0100 [PATCH 8/8] staging: comedi: COMEDI_BUFINFO: terminate "write" command when stopped Ian Abbott <abbotti@mev.co.uk> - 2016-02-19 17:20 +0100 [PATCH 7/8] staging: comedi: COMEDI_BUFINFO: return -EPIPE for abnormal read Ian Abbott <abbotti@mev.co.uk> - 2016-02-19 17:20 +0100
csiph-web