From: H Hartley Sweeten Date: Tue, 12 Aug 2014 18:41:16 +0000 (-0700) Subject: staging: comedi: cb_pcimdas: refactor iobase addresses X-Git-Tag: v5.15~17125^2~1222 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49fca95c403c01d2a91119fa64b86d4291324d17;p=platform%2Fkernel%2Flinux-starfive.git 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index ccb9c72..d049a7f 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;