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

staging: comedi: ni_at_ao: introduce atao_select_reg_group()

To clarify the code a bit, introduce a helper function to set/clear
the GRP2WR bit in the CFG1 register. This bit selects which group of
registers are used for the registers that share the same I/O addresses.
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 100515f8
...@@ -124,6 +124,17 @@ struct atao_private { ...@@ -124,6 +124,17 @@ struct atao_private {
unsigned char caldac[21]; unsigned char caldac[21];
}; };
static void atao_select_reg_group(struct comedi_device *dev, int group)
{
struct atao_private *devpriv = dev->private;
if (group)
devpriv->cfg1 |= ATAO_CFG1_GRP2WR;
else
devpriv->cfg1 &= ~ATAO_CFG1_GRP2WR;
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
}
static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
...@@ -134,15 +145,11 @@ static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -134,15 +145,11 @@ static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
bits = data[i] - 0x800; bits = data[i] - 0x800;
if (chan == 0) { if (chan == 0)
devpriv->cfg1 |= ATAO_CFG1_GRP2WR; atao_select_reg_group(dev, 1);
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
}
outw(bits, dev->iobase + ATAO_AO_REG(chan)); outw(bits, dev->iobase + ATAO_AO_REG(chan));
if (chan == 0) { if (chan == 0)
devpriv->cfg1 &= ~ATAO_CFG1_GRP2WR; atao_select_reg_group(dev, 0);
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
}
devpriv->ao_readback[chan] = data[i]; devpriv->ao_readback[chan] = data[i];
} }
...@@ -312,15 +319,11 @@ static void atao_reset(struct comedi_device *dev) ...@@ -312,15 +319,11 @@ static void atao_reset(struct comedi_device *dev)
inw(dev->iobase + ATAO_FIFO_CLEAR_REG); inw(dev->iobase + ATAO_FIFO_CLEAR_REG);
devpriv->cfg1 |= ATAO_CFG1_GRP2WR; atao_select_reg_group(dev, 1);
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
outw(0, dev->iobase + ATAO_2_INT1CLR_REG); outw(0, dev->iobase + ATAO_2_INT1CLR_REG);
outw(0, dev->iobase + ATAO_2_INT2CLR_REG); outw(0, dev->iobase + ATAO_2_INT2CLR_REG);
outw(0, dev->iobase + ATAO_2_DMATCCLR_REG); outw(0, dev->iobase + ATAO_2_DMATCCLR_REG);
atao_select_reg_group(dev, 0);
devpriv->cfg1 &= ~ATAO_CFG1_GRP2WR;
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
} }
static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
......
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