diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-08-12 22:41:16 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-08-16 23:23:25 +0400 |
commit | 49fca95c403c01d2a91119fa64b86d4291324d17 (patch) | |
tree | ecbfafc329db4580c5e513c4ea4a589bf2da8191 /drivers | |
parent | 3a94180cf224cf0c3136c09b3cde69561ba94bda (diff) | |
download | linux-49fca95c403c01d2a91119fa64b86d4291324d17.tar.xz |
staging: comedi: cb_pcimdas: refactor iobase addresses
This driver uses three iobase addresses, found in PCI bars 2, 3, and 4.
Currently, the address in PCI bar 2 is saved in the comedi_device as
the 'iobase', the PCI bar 3 address is saved in the private data as
'BADR3' and the one in PCI bar 4 is just passed to subdev_8255_init()
as the 'iobase' parameter.
Flip the saving of the PCI bar 2 and 4 base addresses. Save the address
from PCI bar 2 in the private data as the 'daqio' and the address from
PCI bar 4 in the comedi_device as the 'iobase'.
This will help with some cleanup of the 8255 module.
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')
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcimdas.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index ccb9c72bc0c3..d049a7f27239 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -77,6 +77,7 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. */ struct cb_pcimdas_private { /* base addresses */ + unsigned long daqio; unsigned long BADR3; /* Used for AO readback */ @@ -143,7 +144,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, /* convert n samples */ for (n = 0; n < insn->n; n++) { /* trigger conversion */ - outw(0, dev->iobase + 0); + outw(0, devpriv->daqio + 0); /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, cb_pcimdas_ai_eoc, 0); @@ -151,7 +152,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, return ret; /* read data */ - data[n] = inw(dev->iobase + 0); + data[n] = inw(devpriv->daqio + 0); } /* return the number of samples read/written */ @@ -171,10 +172,10 @@ static int cb_pcimdas_ao_winsn(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { switch (chan) { case 0: - outw(data[i] & 0x0FFF, dev->iobase + DAC0_OFFSET); + outw(data[i] & 0x0FFF, devpriv->daqio + DAC0_OFFSET); break; case 1: - outw(data[i] & 0x0FFF, dev->iobase + DAC1_OFFSET); + outw(data[i] & 0x0FFF, devpriv->daqio + DAC1_OFFSET); break; default: return -1; @@ -208,7 +209,6 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct cb_pcimdas_private *devpriv; struct comedi_subdevice *s; - unsigned long iobase_8255; int ret; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); @@ -219,9 +219,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, if (ret) return ret; - dev->iobase = pci_resource_start(pcidev, 2); + devpriv->daqio = pci_resource_start(pcidev, 2); devpriv->BADR3 = pci_resource_start(pcidev, 3); - iobase_8255 = pci_resource_start(pcidev, 4); + dev->iobase = pci_resource_start(pcidev, 4); ret = comedi_alloc_subdevices(dev, 3); if (ret) @@ -252,7 +252,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* digital i/o subdevice */ - ret = subdev_8255_init(dev, s, NULL, iobase_8255); + ret = subdev_8255_init(dev, s, NULL, dev->iobase); if (ret) return ret; |