summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2014-10-30 13:42:26 +0100
committerGreg Kroah-Hartman2014-11-04 01:28:46 +0100
commit5d070cf25c4ecefaaa845ee7c1c3719c90f1c370 (patch)
treedc66d486b02a0bfc44cf286ece8b7a98f7368f93 /drivers/staging/comedi/comedi_fops.c
parentstaging: dgap: re-arrange functions for removing forward declarations (diff)
downloadkernel-qcow2-linux-5d070cf25c4ecefaaa845ee7c1c3719c90f1c370.tar.gz
kernel-qcow2-linux-5d070cf25c4ecefaaa845ee7c1c3719c90f1c370.tar.xz
kernel-qcow2-linux-5d070cf25c4ecefaaa845ee7c1c3719c90f1c370.zip
staging: comedi: maybe force CMDF_WRITE command flag
Most comedi subdevices that support asynchronous commands only support data transfer in either the "read" or "write" direction, as indicated by the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags, although a few support both directions on the same subdevice (though not simultaneously). The `struct comedi_cmd` structure passed via ioctl call to set up the command contains a `CMDF_WRITE` flag that can be used to choose the direction if the subdevice supports both directions, but the flag is optional if the subdevice only supports data transfer in one direction. If the subdevice only supports asynchronous data transfer in a sing direction, set the `CMDF_WRITE` flag to the correct state so that Comedi can make use of it later. In the case of the `COMEDI_CMDTEST` ioctl, the updated flag will be written back to the `struct comedi_cmd` in user-space. In the case of the `COMEDI_CMD` ioctl, the flag only gets written back if an error is detected while testing the command, or if the `CMDF_BOGUS` command flag is set. Since `__comedi_get_user_cmd()` is called for both ioctls, that's a good place to set the flag. 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_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index c1fe9e0e46d1..b489d9481a69 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1451,6 +1451,21 @@ static int __comedi_get_user_cmd(struct comedi_device *dev,
return -EINVAL;
}
+ /*
+ * Set the CMDF_WRITE flag to the correct state if the subdevice
+ * supports only "read" commands or only "write" commands.
+ */
+ switch (s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) {
+ case SDF_CMD_READ:
+ cmd->flags &= ~CMDF_WRITE;
+ break;
+ case SDF_CMD_WRITE:
+ cmd->flags |= CMDF_WRITE;
+ break;
+ default:
+ break;
+ }
+
return 0;
}