summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/adv_pci1723.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-21 14:22:33 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:40:00 -0800
commit348aeaa712e315b6ced688e4d7152136479b047d (patch)
tree8fd1cda929be121eadbc1ad51bc258f9e8961c44 /drivers/staging/comedi/drivers/adv_pci1723.c
parent0f35abd5edaea253ab73e77c26d3393f589f4ae1 (diff)
staging: comedi: adv_pci1723: tidy up DIO io_bits initialization
Tidy up the code that determines the initial io_bits (direction) of the digital I/O subdevice and 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/adv_pci1723.c')
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1723.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index 53f2b2158594..01e90d946860 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -144,6 +144,7 @@ static int pci1723_auto_attach(struct comedi_device *dev,
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct comedi_subdevice *s;
+ unsigned int val;
int ret;
int i;
@@ -195,22 +196,12 @@ static int pci1723_auto_attach(struct comedi_device *dev,
s->insn_config = pci1723_dio_insn_config;
s->insn_bits = pci1723_dio_insn_bits;
- /* read DIO config */
- switch (inw(dev->iobase + PCI1723_DIO_CTRL_REG) & 0x03) {
- case 0x00: /* low byte output, high byte output */
- s->io_bits = 0xFFFF;
- break;
- case 0x01: /* low byte input, high byte output */
- s->io_bits = 0xFF00;
- break;
- case 0x02: /* low byte output, high byte input */
- s->io_bits = 0x00FF;
- break;
- case 0x03: /* low byte input, high byte input */
- s->io_bits = 0x0000;
- break;
- }
- /* read DIO port state */
+ /* get initial DIO direction and state */
+ val = inw(dev->iobase + PCI1723_DIO_CTRL_REG);
+ if (!(val & PCI1723_DIO_CTRL_LDIO))
+ s->io_bits |= 0x00ff; /* low byte output */
+ if (!(val & PCI1723_DIO_CTRL_HDIO))
+ s->io_bits |= 0xff00; /* high byte output */
s->state = inw(dev->iobase + PCI1723_DIO_DATA_REG);
return 0;