summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-04-16 14:19:14 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-22 10:18:49 -0700
commit8c3ca59af3ec7326a1d6b07ed56edc5e729a36ab (patch)
tree83ce2e2238340c524266744e8c8c87722f10e959 /drivers
parentf71a28320d7bc7d8b712a10bc1553b06ec4c0487 (diff)
staging: comedi: das1800: factor out chanlist checking from (*do_cmdtest)
Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). 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')
-rw-r--r--drivers/staging/comedi/drivers/das1800.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index 8e975d6b06db..d581029146cb 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -757,6 +757,26 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
return micro_sec * 1000;
}
+static int das1800_ai_check_chanlist(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
+{
+ unsigned int unipolar0 = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
+ int i;
+
+ for (i = 1; i < cmd->chanlist_len; i++) {
+ unsigned int unipolar = CR_RANGE(cmd->chanlist[i]) & UNIPOLAR;
+
+ if (unipolar != unipolar0) {
+ dev_dbg(dev->class_dev,
+ "unipolar and bipolar ranges cannot be mixed in the chanlist\n");
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
/* test analog input cmd */
static int das1800_ai_do_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
@@ -766,8 +786,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
struct das1800_private *devpriv = dev->private;
int err = 0;
unsigned int tmp_arg;
- int i;
- int unipolar;
/* Step 1 : check if triggers are trivially valid */
@@ -873,18 +891,9 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
if (err)
return 4;
- /* make sure user is not trying to mix unipolar and bipolar ranges */
- if (cmd->chanlist) {
- unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
- for (i = 1; i < cmd->chanlist_len; i++) {
- if (unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR)) {
- comedi_error(dev,
- "unipolar and bipolar ranges cannot be mixed in the chanlist");
- err++;
- break;
- }
- }
- }
+ /* Step 5: check channel list if it exists */
+ if (cmd->chanlist && cmd->chanlist_len > 0)
+ err |= das1800_ai_check_chanlist(dev, s, cmd);
if (err)
return 5;