Commit 66fea98e authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das1800: refactor Step 4 of das1800_ai_do_cmdtest()

Refactor this code to reduce the indent level and the > 80 char
lines.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 863e07c9
...@@ -731,7 +731,7 @@ static irqreturn_t das1800_interrupt(int irq, void *d) ...@@ -731,7 +731,7 @@ static irqreturn_t das1800_interrupt(int irq, void *d)
/* converts requested conversion timing to timing compatible with /* converts requested conversion timing to timing compatible with
* hardware, used only when card is in 'burst mode' * hardware, used only when card is in 'burst mode'
*/ */
static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) static unsigned int burst_convert_arg(unsigned int convert_arg, int flags)
{ {
unsigned int micro_sec; unsigned int micro_sec;
...@@ -740,7 +740,7 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) ...@@ -740,7 +740,7 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
convert_arg = 64000; convert_arg = 64000;
/* the conversion time must be an integral number of microseconds */ /* the conversion time must be an integral number of microseconds */
switch (round_mode) { switch (flags & TRIG_ROUND_MASK) {
case TRIG_ROUND_NEAREST: case TRIG_ROUND_NEAREST:
default: default:
micro_sec = (convert_arg + 500) / 1000; micro_sec = (convert_arg + 500) / 1000;
...@@ -785,7 +785,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, ...@@ -785,7 +785,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
const struct das1800_board *thisboard = comedi_board(dev); const struct das1800_board *thisboard = comedi_board(dev);
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
int err = 0; int err = 0;
unsigned int tmp_arg; unsigned int arg;
/* Step 1 : check if triggers are trivially valid */ /* Step 1 : check if triggers are trivially valid */
...@@ -843,50 +843,41 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, ...@@ -843,50 +843,41 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
/* step 4: fix up any arguments */ /* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) { if (cmd->scan_begin_src == TRIG_FOLLOW &&
/* if we are not in burst mode */ cmd->convert_src == TRIG_TIMER) {
if (cmd->scan_begin_src == TRIG_FOLLOW) { /* we are not in burst mode */
tmp_arg = cmd->convert_arg; arg = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1, &devpriv->divisor1,
&devpriv->divisor2, &devpriv->divisor2,
&cmd->convert_arg, &cmd->convert_arg, cmd->flags);
cmd->flags); if (arg != cmd->convert_arg)
if (tmp_arg != cmd->convert_arg)
err++; err++;
} } else if (cmd->convert_src == TRIG_TIMER) {
/* if we are in burst mode */ /* we are in burst mode */
else { arg = cmd->convert_arg;
/* check that convert_arg is compatible */ cmd->convert_arg = burst_convert_arg(cmd->convert_arg,
tmp_arg = cmd->convert_arg; cmd->flags);
cmd->convert_arg = if (arg != cmd->convert_arg)
burst_convert_arg(cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
if (tmp_arg != cmd->convert_arg)
err++; err++;
if (cmd->scan_begin_src == TRIG_TIMER) { if (cmd->scan_begin_src == TRIG_TIMER) {
/* if scans are timed faster than conversion rate allows */ arg = cmd->convert_arg * cmd->chanlist_len;
if (cmd->convert_arg * cmd->chanlist_len > if (arg > cmd->scan_begin_arg) {
cmd->scan_begin_arg) { cmd->scan_begin_arg = arg;
cmd->scan_begin_arg =
cmd->convert_arg *
cmd->chanlist_len;
err++; err++;
} }
tmp_arg = cmd->scan_begin_arg;
/* calculate counter values that give desired timing */ arg = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1, &devpriv->divisor1,
&devpriv->divisor2, &devpriv->divisor2,
&cmd->scan_begin_arg, &cmd->scan_begin_arg,
cmd->flags); cmd->flags);
if (tmp_arg != cmd->scan_begin_arg) if (arg != cmd->scan_begin_arg)
err++; err++;
} }
} }
}
if (err) if (err)
return 4; return 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment