summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-07-17 12:27:31 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-17 18:00:43 -0700
commit2042088cd67d0064d18c52c13c69af2499907bb1 (patch)
tree51e3488f99a3b4ed3480ea798f2e5890344633df
parentc72f57377c4168a1aed68b4250a109a2505bdd62 (diff)
staging: comedi: ni_labpc: tidy up labpc_ai_scan_mode()
This function checks the cmd->chanlist to determine the scan mode used to sample the analog inputs. All possible modes are checked so the final pr_err() and return 0 can never be reached. Tidy up the function a bit and remove the unreachable code. 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>
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 6fb405eb0933..8b41813ebf65 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -531,24 +531,26 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd,
static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
{
+ unsigned int chan0;
+ unsigned int chan1;
+
if (cmd->chanlist_len == 1)
return MODE_SINGLE_CHAN;
- /* chanlist may be NULL during cmdtest. */
+ /* chanlist may be NULL during cmdtest */
if (cmd->chanlist == NULL)
return MODE_MULT_CHAN_UP;
- if (CR_CHAN(cmd->chanlist[0]) == CR_CHAN(cmd->chanlist[1]))
- return MODE_SINGLE_CHAN_INTERVAL;
+ chan0 = CR_CHAN(cmd->chanlist[0]);
+ chan1 = CR_CHAN(cmd->chanlist[1]);
- if (CR_CHAN(cmd->chanlist[0]) < CR_CHAN(cmd->chanlist[1]))
+ if (chan0 < chan1)
return MODE_MULT_CHAN_UP;
- if (CR_CHAN(cmd->chanlist[0]) > CR_CHAN(cmd->chanlist[1]))
+ if (chan0 > chan1)
return MODE_MULT_CHAN_DOWN;
- pr_err("ni_labpc: bug! cannot determine AI scan mode\n");
- return 0;
+ return MODE_SINGLE_CHAN_INTERVAL;
}
static int labpc_ai_check_chanlist(struct comedi_device *dev,