]> Pileus Git - ~andy/linux/commitdiff
3c59x: consolidate error cleanup in vortex_init_one()
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Sun, 9 Jun 2013 20:16:52 +0000 (00:16 +0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Jun 2013 08:53:52 +0000 (01:53 -0700)
The PCI driver's probe() method  duplicates the error cleanup code each time it
has to do error exit. Consolidate the error cleanup code  in  one place and use
*goto* to jump to the right places.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Steffen Klassert <klassert@mathematik.tu-chemnitz.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/3com/3c59x.c

index 30e74211a75537d7430d11dc3d12b00555fe68c3..ad5272b348f07debb61c540a909da8fa0e1593f1 100644 (file)
@@ -1012,10 +1012,8 @@ static int vortex_init_one(struct pci_dev *pdev,
                goto out;
 
        rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc < 0) {
-               pci_disable_device(pdev);
-               goto out;
-       }
+       if (rc < 0)
+               goto out_disable;
 
        unit = vortex_cards_found;
 
@@ -1032,23 +1030,24 @@ static int vortex_init_one(struct pci_dev *pdev,
        if (!ioaddr) /* If mapping fails, fall-back to BAR 0... */
                ioaddr = pci_iomap(pdev, 0, 0);
        if (!ioaddr) {
-               pci_release_regions(pdev);
-               pci_disable_device(pdev);
                rc = -ENOMEM;
-               goto out;
+               goto out_release;
        }
 
        rc = vortex_probe1(&pdev->dev, ioaddr, pdev->irq,
                           ent->driver_data, unit);
-       if (rc < 0) {
-               pci_iounmap(pdev, ioaddr);
-               pci_release_regions(pdev);
-               pci_disable_device(pdev);
-               goto out;
-       }
+       if (rc < 0)
+               goto out_iounmap;
 
        vortex_cards_found++;
+       goto out;
 
+out_iounmap:
+       pci_iounmap(pdev, ioaddr);
+out_release:
+       pci_release_regions(pdev);
+out_disable:
+       pci_disable_device(pdev);
 out:
        return rc;
 }