Merge branch 'topic/pcm-drain-nonblock' into for-linus
[pandora-kernel.git] / drivers / net / pcnet32.c
index 2836815..23e1a07 100644 (file)
@@ -1611,8 +1611,11 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
                if (pcnet32_dwio_read_csr(ioaddr, 0) == 4
                    && pcnet32_dwio_check(ioaddr)) {
                        a = &pcnet32_dwio;
-               } else
+               } else {
+                       if (pcnet32_debug & NETIF_MSG_PROBE)
+                               printk(KERN_ERR PFX "No access methods\n");
                        goto err_release_region;
+               }
        }
 
        chip_version =
@@ -1719,7 +1722,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
                ret = -ENOMEM;
                goto err_release_region;
        }
-       SET_NETDEV_DEV(dev, &pdev->dev);
+
+       if (pdev)
+               SET_NETDEV_DEV(dev, &pdev->dev);
 
        if (pcnet32_debug & NETIF_MSG_PROBE)
                printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr);
@@ -1818,7 +1823,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
 
        spin_lock_init(&lp->lock);
 
-       SET_NETDEV_DEV(dev, &pdev->dev);
        lp->name = chipname;
        lp->shared_irq = shared;
        lp->tx_ring_size = TX_RING_SIZE;        /* default tx ring size */
@@ -1835,7 +1839,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
        lp->chip_version = chip_version;
        lp->msg_enable = pcnet32_debug;
        if ((cards_found >= MAX_UNITS)
-           || (options[cards_found] > sizeof(options_mapping)))
+           || (options[cards_found] >= sizeof(options_mapping)))
                lp->options = PCNET32_PORT_ASEL;
        else
                lp->options = options_mapping[options[cards_found]];
@@ -1852,12 +1856,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
            ((cards_found >= MAX_UNITS) || full_duplex[cards_found]))
                lp->options |= PCNET32_PORT_FD;
 
-       if (!a) {
-               if (pcnet32_debug & NETIF_MSG_PROBE)
-                       printk(KERN_ERR PFX "No access methods\n");
-               ret = -ENODEV;
-               goto err_free_consistent;
-       }
        lp->a = *a;
 
        /* prior to register_netdev, dev->name is not yet correct */
@@ -1973,14 +1971,13 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
 
        return 0;
 
-      err_free_ring:
+err_free_ring:
        pcnet32_free_ring(dev);
-      err_free_consistent:
        pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block),
                            lp->init_block, lp->init_dma_addr);
-      err_free_netdev:
+err_free_netdev:
        free_netdev(dev);
-      err_release_region:
+err_release_region:
        release_region(ioaddr, PCNET32_TOTAL_SIZE);
        return ret;
 }
@@ -2089,6 +2086,7 @@ static void pcnet32_free_ring(struct net_device *dev)
 static int pcnet32_open(struct net_device *dev)
 {
        struct pcnet32_private *lp = netdev_priv(dev);
+       struct pci_dev *pdev = lp->pci_dev;
        unsigned long ioaddr = dev->base_addr;
        u16 val;
        int i;
@@ -2149,9 +2147,9 @@ static int pcnet32_open(struct net_device *dev)
        lp->a.write_csr(ioaddr, 124, val);
 
        /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */
-       if (lp->pci_dev->subsystem_vendor == PCI_VENDOR_ID_AT &&
-           (lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX ||
-            lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) {
+       if (pdev && pdev->subsystem_vendor == PCI_VENDOR_ID_AT &&
+           (pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX ||
+            pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) {
                if (lp->options & PCNET32_PORT_ASEL) {
                        lp->options = PCNET32_PORT_FD | PCNET32_PORT_100;
                        if (netif_msg_link(lp))