]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging: comedi: rtd520: cleanup pci bar ioremap
authorH Hartley Sweeten <hartleys@visionengravers.com>
Mon, 29 Oct 2012 17:01:46 +0000 (10:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Oct 2012 17:44:37 +0000 (10:44 -0700)
Use the size returned by pci_resource_len() when ioremap'ing the
pci bars instead of assuming a size.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/rtd520.c

index fc0b1337a4715fb38af06d72ad1c1aba1e52e2e1..e33a233d42c151d5be21b6b0960c694b139eaa68 100644 (file)
@@ -147,18 +147,6 @@ Configuration options:
   Board specific stuff
 ======================================================================*/
 
-/*
-  The board has three memory windows: las0, las1, and lcfg (the PCI chip)
-  Las1 has the data and can be burst DMAed 32bits at a time.
-*/
-#define LCFG_PCIINDEX  0
-/* PCI region 1 is a 256 byte IO space mapping.  Use??? */
-#define LAS0_PCIINDEX  2       /* PCI memory resources */
-#define LAS1_PCIINDEX  3
-#define LCFG_PCISIZE   0x100
-#define LAS0_PCISIZE   0x200
-#define LAS1_PCISIZE   0x10
-
 #define RTD_CLOCK_RATE 8000000 /* 8Mhz onboard clock */
 #define RTD_CLOCK_BASE 125     /* clock period in ns */
 
@@ -1591,7 +1579,6 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        struct rtdPrivate *devpriv;
        struct pci_dev *pcidev;
        struct comedi_subdevice *s;
-       resource_size_t pci_base;
        int ret;
 #ifdef USE_DMA
        int index;
@@ -1626,13 +1613,12 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        }
        dev->iobase = 1;        /* the "detach" needs this */
 
-       /* Initialize the base addresses */
-       pci_base = pci_resource_start(pcidev, LAS0_PCIINDEX);
-       devpriv->las0 = ioremap_nocache(pci_base, LAS0_PCISIZE);
-       pci_base = pci_resource_start(pcidev, LAS1_PCIINDEX);
-       devpriv->las1 = ioremap_nocache(pci_base, LAS1_PCISIZE);
-       pci_base = pci_resource_start(pcidev, LCFG_PCIINDEX);
-       devpriv->lcfg = ioremap_nocache(pci_base, LCFG_PCISIZE);
+       devpriv->las0 = ioremap_nocache(pci_resource_start(pcidev, 2),
+                                       pci_resource_len(pcidev, 2));
+       devpriv->las1 = ioremap_nocache(pci_resource_start(pcidev, 3),
+                                       pci_resource_len(pcidev, 3));
+       devpriv->lcfg = ioremap_nocache(pci_resource_start(pcidev, 0),
+                                       pci_resource_len(pcidev, 0));
        if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg)
                return -ENOMEM;