staging: comedi: ni_tiocmd: tidy up ni_tio_input_cmd()
The cmd->start_src is validated in the (*do_cmdtest) before this function is called. All valid trigger sources are handled so the default BUG() case can never occure. For aesthetics, refactor the switch into if/else tests and remove the BUG(). For aesthetics, rename the local variable 'retval' to simply 'ret'. 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>
This commit is contained in:
parent
78c7a4a659
commit
4cf2f3a574
1 changed files with 10 additions and 20 deletions
|
@ -118,7 +118,7 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s)
|
||||||
unsigned cidx = counter->counter_index;
|
unsigned cidx = counter->counter_index;
|
||||||
struct comedi_async *async = s->async;
|
struct comedi_async *async = s->async;
|
||||||
struct comedi_cmd *cmd = &async->cmd;
|
struct comedi_cmd *cmd = &async->cmd;
|
||||||
int retval = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* write alloc the entire buffer */
|
/* write alloc the entire buffer */
|
||||||
comedi_buf_write_alloc(s, async->prealloc_bufsz);
|
comedi_buf_write_alloc(s, async->prealloc_bufsz);
|
||||||
|
@ -137,29 +137,19 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s)
|
||||||
}
|
}
|
||||||
ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), GI_SAVE_TRACE, 0);
|
ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), GI_SAVE_TRACE, 0);
|
||||||
ni_tio_configure_dma(counter, true, true);
|
ni_tio_configure_dma(counter, true, true);
|
||||||
switch (cmd->start_src) {
|
|
||||||
case TRIG_NOW:
|
if (cmd->start_src == TRIG_INT) {
|
||||||
async->inttrig = NULL;
|
|
||||||
mite_dma_arm(counter->mite_chan);
|
|
||||||
retval = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
|
|
||||||
break;
|
|
||||||
case TRIG_INT:
|
|
||||||
async->inttrig = &ni_tio_input_inttrig;
|
async->inttrig = &ni_tio_input_inttrig;
|
||||||
break;
|
} else { /* TRIG_NOW || TRIG_EXT || TRIG_OTHER */
|
||||||
case TRIG_EXT:
|
|
||||||
async->inttrig = NULL;
|
async->inttrig = NULL;
|
||||||
mite_dma_arm(counter->mite_chan);
|
mite_dma_arm(counter->mite_chan);
|
||||||
retval = ni_tio_arm(counter, 1, cmd->start_arg);
|
|
||||||
break;
|
if (cmd->start_src == TRIG_NOW)
|
||||||
case TRIG_OTHER:
|
ret = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
|
||||||
async->inttrig = NULL;
|
else if (cmd->start_src == TRIG_EXT)
|
||||||
mite_dma_arm(counter->mite_chan);
|
ret = ni_tio_arm(counter, 1, cmd->start_arg);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BUG();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return retval;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ni_tio_output_cmd(struct comedi_subdevice *s)
|
static int ni_tio_output_cmd(struct comedi_subdevice *s)
|
||||||
|
|
Loading…
Add table
Reference in a new issue