staging: comedi: addi-data: remove io_addr array from card data
authorH Hartley Sweeten <hartleys@visionengravers.com>
Wed, 31 Oct 2012 23:55:54 +0000 (16:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Nov 2012 15:43:24 +0000 (08:43 -0700)
The io_addr array in the card data holds the PCI bar base addresses
returned by pci_resource_start(). Remove this array and just use
pci_resource_start() where needed in i_ADDI_Attach().

This also allows getting rid of i_pci_card_data() since it now
does nothing.

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/addi-data/addi_amcc_s5933.h
drivers/staging/comedi/drivers/addi-data/addi_common.c

index 0d10ec7288edda829dd91d3a0ef8d14937dbf0f3..27c3fbaea01dd758bfbb0b1b155ebc94de7951e7 100644 (file)
@@ -201,7 +201,6 @@ struct pcilst_struct {
        unsigned char pci_bus;
        unsigned char pci_slot;
        unsigned char pci_func;
-       resource_size_t io_addr[5];
        unsigned int irq;
 };
 
@@ -230,8 +229,6 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
 
 int pci_card_alloc(struct pcilst_struct *amcc, int master);
 int i_pci_card_free(struct pcilst_struct *amcc);
-int i_pci_card_data(struct pcilst_struct *amcc,
-                   resource_size_t *io_addr);
 
 /****************************************************************************/
 
@@ -240,7 +237,6 @@ void v_pci_card_list_init(unsigned short pci_vendor)
 {
        struct pci_dev *pcidev = NULL;
        struct pcilst_struct *amcc, *last;
-       int i;
        int i_Count = 0;
        amcc_devices = NULL;
        last = NULL;
@@ -265,12 +261,6 @@ void v_pci_card_list_init(unsigned short pci_vendor)
                                amcc->pci_bus = pcidev->bus->number;
                                amcc->pci_slot = PCI_SLOT(pcidev->devfn);
                                amcc->pci_func = PCI_FUNC(pcidev->devfn);
-                               /* Note: resources may be invalid if PCI device
-                                * not enabled, but they are corrected in
-                                * pci_card_alloc. */
-                               for (i = 0; i < 5; i++)
-                                       amcc->io_addr[i] =
-                                           pci_resource_start(pcidev, i);
                                amcc->irq = pcidev->irq;
 
                        }
@@ -345,8 +335,6 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id,
 /* mark card as used */
 int pci_card_alloc(struct pcilst_struct *amcc, int master)
 {
-       int i;
-
        if (!amcc)
                return -1;
 
@@ -354,9 +342,6 @@ int pci_card_alloc(struct pcilst_struct *amcc, int master)
                return 1;
        if (comedi_pci_enable(amcc->pcidev, "addi_amcc_s5933"))
                return -1;
-       /* Resources will be accurate now. */
-       for (i = 0; i < 5; i++)
-               amcc->io_addr[i] = pci_resource_start(amcc->pcidev, i);
        if (master)
                pci_set_master(amcc->pcidev);
        amcc->used = 1;
@@ -378,20 +363,6 @@ int i_pci_card_free(struct pcilst_struct *amcc)
        return 0;
 }
 
-/****************************************************************************/
-/* return all card information for driver */
-int i_pci_card_data(struct pcilst_struct *amcc,
-                   resource_size_t *io_addr)
-{
-       int i;
-
-       if (!amcc)
-               return -1;
-       for (i = 0; i < 5; i++)
-               io_addr[i] = amcc->io_addr[i];
-       return 0;
-}
-
 /****************************************************************************/
 /* select and alloc card */
 struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
index 8ebfb2b81b5a5bcedf5805ba2b458efea8adb975..b6130f8c40ae619575343018d3a375b04bbc6396 100644 (file)
@@ -91,7 +91,6 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
        struct comedi_subdevice *s;
        int ret, pages, i, n_subdevices;
        unsigned int dw_Dummy;
-       resource_size_t io_addr[5];
        resource_size_t iobase_a, iobase_main, iobase_addon, iobase_reserved;
        struct pcilst_struct *card = NULL;
        int i_Dma = 0;
@@ -120,15 +119,10 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        devpriv->allocated = 1;
 
-       if ((i_pci_card_data(card, &io_addr[0])) < 0) {
-               i_pci_card_free(card);
-               return -EIO;
-       }
-
-       iobase_a = io_addr[0];
-       iobase_main = io_addr[1];
-       iobase_addon = io_addr[2];
-       iobase_reserved = io_addr[3];
+       iobase_a = pci_resource_start(card->pcidev, 0);
+       iobase_main = pci_resource_start(card->pcidev, 1);
+       iobase_addon = pci_resource_start(card->pcidev, 2);
+       iobase_reserved = pci_resource_start(card->pcidev, 3);
 
        if ((this_board->pc_EepromChip == NULL)
                || (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
@@ -150,11 +144,11 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                devpriv->i_IobaseReserved = (int) iobase_reserved;
        } else {
                dev->board_name = this_board->pc_DriverName;
-               dev->iobase = (unsigned long)io_addr[2];
+               dev->iobase = pci_resource_start(card->pcidev, 2);
                devpriv->amcc = card;
-               devpriv->iobase = (int) io_addr[2];
-               devpriv->i_IobaseReserved = (int) io_addr[3];
-               devpriv->dw_AiBase = ioremap(io_addr[3],
+               devpriv->iobase = pci_resource_start(card->pcidev, 2);
+               devpriv->i_IobaseReserved = pci_resource_start(card->pcidev, 3);
+               devpriv->dw_AiBase = ioremap(pci_resource_start(card->pcidev, 3),
                                             this_board->i_IorangeBase3);
        }
 
@@ -196,7 +190,7 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                        dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
                        outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
                }
-               addi_eeprom_read_info(dev, io_addr[0]);
+               addi_eeprom_read_info(dev, pci_resource_start(card->pcidev, 0));
        }
 
        if (it->options[2] > 0) {
@@ -242,7 +236,7 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                i_ADDI_AttachPCI1710(dev);
 
                /*  save base address */
-               devpriv->s_BoardInfos.ui_Address = io_addr[2];
+               devpriv->s_BoardInfos.ui_Address = pci_resource_start(card->pcidev, 2);
 #endif
        } else {
                n_subdevices = 7;