]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ip2main.c: add missing pci_enable_device()
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Tue, 24 Aug 2004 04:21:08 +0000 (21:21 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 24 Aug 2004 04:21:08 +0000 (21:21 -0700)
I don't have this hardware, so this has been compiled but not tested.

Add pci_enable_device()/pci_disable_device In the past, drivers often worked
without this, but it is now required in order to route PCI interrupts
correctly.  In addition, this driver incorrectly used the IRQ value from PCI
config space rather than the one in the struct pci_dev.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/ip2/ip2types.h
drivers/char/ip2main.c

index 8d2b3799941a2b979838b10498a54cd4f2c9ae1f..9d67b260b2f629f8b2457da81e1c1d88e2159360 100644 (file)
@@ -49,6 +49,9 @@ typedef struct
        short irq[IP2_MAX_BOARDS]; 
        unsigned short addr[IP2_MAX_BOARDS];
        int type[IP2_MAX_BOARDS];
+#ifdef CONFIG_PCI
+       struct pci_dev *pci_dev[IP2_MAX_BOARDS];
+#endif
 } ip2config_t;
 
 #endif
index ac97e617a10783f5a6b3b8f01474b56d59fc56fa..fa3ca6eb5d53772b0a0487e2dcf648368e781e74 100644 (file)
@@ -440,6 +440,12 @@ cleanup_module(void)
        // free memory
        for (i = 0; i < IP2_MAX_BOARDS; i++) {
                void *pB;
+#ifdef CONFIG_PCI
+               if (ip2config.type[i] == PCI && ip2config.pci_dev[i]) {
+                       pci_disable_device(ip2config.pci_dev[i]);
+                       ip2config.pci_dev[i] = NULL;
+               }
+#endif
                if ((pB = i2BoardPtrTable[i]) != 0 ) {
                        kfree ( pB );
                        i2BoardPtrTable[i] = NULL;
@@ -594,9 +600,14 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                                          PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
                                if (pci_dev_i != NULL) {
                                        unsigned int addr;
-                                       unsigned char pci_irq;
 
+                                       if (pci_enable_device(pci_dev_i)) {
+                                               printk( KERN_ERR "IP2: can't enable PCI device at %s\n",
+                                                       pci_name(pci_dev_i));
+                                               break;
+                                       }
                                        ip2config.type[i] = PCI;
+                                       ip2config.pci_dev[i] = pci_dev_i;
                                        status =
                                        pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr);
                                        if ( addr & 1 ) {
@@ -604,8 +615,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                        } else {
                                                printk( KERN_ERR "IP2: PCI I/O address error\n");
                                        }
-                                       status =
-                                       pci_read_config_byte(pci_dev_i, PCI_INTERRUPT_LINE, &pci_irq);
 
 //             If the PCI BIOS assigned it, lets try and use it.  If we
 //             can't acquire it or it screws up, deal with it then.
@@ -614,7 +623,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
 //                                             printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq);
 //                                             pci_irq = 0;
 //                                     }
-                                       ip2config.irq[i] = pci_irq;
+                                       ip2config.irq[i] = pci_dev_i->irq;
                                } else {        // ann error
                                        ip2config.addr[i] = 0;
                                        if (status == PCIBIOS_DEVICE_NOT_FOUND) {