]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: 8255_pci: check BAR resource type directly
authorIan Abbott <abbotti@mev.co.uk>
Fri, 12 Apr 2013 12:57:54 +0000 (13:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Apr 2013 22:12:42 +0000 (15:12 -0700)
This driver handles one or more 8255 DIO subdevices mapped contiguously
at the start of a PCI BAR resource.  The resource may be a portio
resource or an mmio resource.  The driver currently checks the `is_mmio`
member of the matching element of `pci_8255_boards[]` to determine the
type of resource.  Rather than doing that, get the information straight
from the horse's mouth by checking the resource flags of the PCI BAR
and eliminate the `is_mmio` member.

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

index fff1c08a93fbd91798f074b73e992bbaa92819a5..de54ad3a64e6ff64f73cbfd2525d5b75932a0728 100644 (file)
@@ -80,7 +80,6 @@ enum pci_8255_boardid {
 struct pci_8255_boardinfo {
        const char *name;
        int dio_badr;
-       int is_mmio;
        int n_8255;
 };
 
@@ -123,43 +122,36 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = {
        [BOARD_NI_PCIDIO96] = {
                .name           = "ni_pci-dio-96",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 4,
        },
        [BOARD_NI_PCIDIO96B] = {
                .name           = "ni_pci-dio-96b",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 4,
        },
        [BOARD_NI_PXI6508] = {
                .name           = "ni_pxi-6508",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 4,
        },
        [BOARD_NI_PCI6503] = {
                .name           = "ni_pci-6503",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 1,
        },
        [BOARD_NI_PCI6503B] = {
                .name           = "ni_pci-6503b",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 1,
        },
        [BOARD_NI_PCI6503X] = {
                .name           = "ni_pci-6503x",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 1,
        },
        [BOARD_NI_PXI_6503] = {
                .name           = "ni_pxi-6503",
                .dio_badr       = 1,
-               .is_mmio        = 1,
                .n_8255         = 1,
        },
 };
@@ -187,6 +179,7 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
        const struct pci_8255_boardinfo *board = NULL;
        struct pci_8255_private *devpriv;
        struct comedi_subdevice *s;
+       bool is_mmio;
        int ret;
        int i;
 
@@ -206,7 +199,9 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
        if (ret)
                return ret;
 
-       if (board->is_mmio) {
+       is_mmio = (pci_resource_flags(pcidev, board->dio_badr) &
+                  IORESOURCE_MEM) != 0;
+       if (is_mmio) {
                devpriv->mmio_base = pci_ioremap_bar(pcidev, board->dio_badr);
                if (!devpriv->mmio_base)
                        return -ENOMEM;
@@ -227,7 +222,7 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
                unsigned long iobase;
 
                s = &dev->subdevices[i];
-               if (board->is_mmio) {
+               if (is_mmio) {
                        iobase = (unsigned long)(devpriv->mmio_base + (i * 4));
                        ret = subdev_8255_init(dev, s, pci_8255_mmio, iobase);
                } else {