mirror of https://gitee.com/openkylin/linux.git
staging: comedi: adv_pci1723: tidy up pci1723_dio_insn_config()
For aesthetics, tidy this function up and use the register defines to remove the magic numbers. 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
c8a14b924c
commit
0f35abd5ed
|
@ -103,33 +103,24 @@ static int pci1723_ao_insn_write(struct comedi_device *dev,
|
||||||
return insn->n;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
digital i/o config/query
|
|
||||||
*/
|
|
||||||
static int pci1723_dio_insn_config(struct comedi_device *dev,
|
static int pci1723_dio_insn_config(struct comedi_device *dev,
|
||||||
struct comedi_subdevice *s,
|
struct comedi_subdevice *s,
|
||||||
struct comedi_insn *insn, unsigned int *data)
|
struct comedi_insn *insn,
|
||||||
|
unsigned int *data)
|
||||||
{
|
{
|
||||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||||
unsigned int mask;
|
unsigned int mask = (chan < 8) ? 0x00ff : 0xff00;
|
||||||
unsigned short mode;
|
unsigned short mode = 0x0000; /* assume output */
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (chan < 8)
|
|
||||||
mask = 0x00ff;
|
|
||||||
else
|
|
||||||
mask = 0xff00;
|
|
||||||
|
|
||||||
ret = comedi_dio_insn_config(dev, s, insn, data, mask);
|
ret = comedi_dio_insn_config(dev, s, insn, data, mask);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* update hardware DIO mode */
|
|
||||||
mode = 0x0000; /* assume output */
|
|
||||||
if (!(s->io_bits & 0x00ff))
|
if (!(s->io_bits & 0x00ff))
|
||||||
mode |= 0x0001; /* low byte input */
|
mode |= PCI1723_DIO_CTRL_LDIO; /* low byte input */
|
||||||
if (!(s->io_bits & 0xff00))
|
if (!(s->io_bits & 0xff00))
|
||||||
mode |= 0x0002; /* high byte input */
|
mode |= PCI1723_DIO_CTRL_HDIO; /* high byte input */
|
||||||
outw(mode, dev->iobase + PCI1723_DIO_CTRL_REG);
|
outw(mode, dev->iobase + PCI1723_DIO_CTRL_REG);
|
||||||
|
|
||||||
return insn->n;
|
return insn->n;
|
||||||
|
|
Loading…
Reference in New Issue