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

staging: comedi: ni_mio_common: absorb helpers into ni_freq_out_insn_config()

Absorb the helper functions that handle the INSN_CONFIG_SET_CLOCK_SRC and
INSN_CONFIG_GET_CLOCK_SRC comedi instructions.
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 e879c315
...@@ -3903,12 +3903,16 @@ static int ni_freq_out_insn_write(struct comedi_device *dev, ...@@ -3903,12 +3903,16 @@ static int ni_freq_out_insn_write(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int ni_set_freq_out_clock(struct comedi_device *dev, static int ni_freq_out_insn_config(struct comedi_device *dev,
unsigned int clock_source) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
switch (clock_source) { switch (data[0]) {
case INSN_CONFIG_SET_CLOCK_SRC:
switch (data[1]) {
case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC: case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC:
devpriv->clock_and_fout &= ~FOUT_Timebase_Select; devpriv->clock_and_fout &= ~FOUT_Timebase_Select;
break; break;
...@@ -3920,39 +3924,20 @@ static int ni_set_freq_out_clock(struct comedi_device *dev, ...@@ -3920,39 +3924,20 @@ static int ni_set_freq_out_clock(struct comedi_device *dev,
} }
devpriv->stc_writew(dev, devpriv->clock_and_fout, devpriv->stc_writew(dev, devpriv->clock_and_fout,
Clock_and_FOUT_Register); Clock_and_FOUT_Register);
return 3; break;
} case INSN_CONFIG_GET_CLOCK_SRC:
static void ni_get_freq_out_clock(struct comedi_device *dev,
unsigned int *clock_source,
unsigned int *clock_period_ns)
{
struct ni_private *devpriv = dev->private;
if (devpriv->clock_and_fout & FOUT_Timebase_Select) { if (devpriv->clock_and_fout & FOUT_Timebase_Select) {
*clock_source = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC; data[1] = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC;
*clock_period_ns = TIMEBASE_2_NS; data[2] = TIMEBASE_2_NS;
} else { } else {
*clock_source = NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC; data[1] = NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC;
*clock_period_ns = TIMEBASE_1_NS * 2; data[2] = TIMEBASE_1_NS * 2;
} }
}
static int ni_freq_out_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_SET_CLOCK_SRC:
return ni_set_freq_out_clock(dev, data[1]);
break; break;
case INSN_CONFIG_GET_CLOCK_SRC:
ni_get_freq_out_clock(dev, &data[1], &data[2]);
return 3;
default: default:
break;
}
return -EINVAL; return -EINVAL;
}
return insn->n;
} }
static int ni_8255_callback(int dir, int port, int data, unsigned long arg) static int ni_8255_callback(int dir, int port, int data, unsigned long arg)
......
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