Skip to content

Commit afd6eae

Browse files
Sergei Shtylyovdavem330
authored andcommitted
3c59x: consolidate error cleanup in vortex_init_one()
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 <[email protected]> Acked-by: Steffen Klassert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3f8b963 commit afd6eae

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/net/ethernet/3com/3c59x.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,8 @@ static int vortex_init_one(struct pci_dev *pdev,
10121012
goto out;
10131013

10141014
rc = pci_request_regions(pdev, DRV_NAME);
1015-
if (rc < 0) {
1016-
pci_disable_device(pdev);
1017-
goto out;
1018-
}
1015+
if (rc < 0)
1016+
goto out_disable;
10191017

10201018
unit = vortex_cards_found;
10211019

@@ -1032,23 +1030,24 @@ static int vortex_init_one(struct pci_dev *pdev,
10321030
if (!ioaddr) /* If mapping fails, fall-back to BAR 0... */
10331031
ioaddr = pci_iomap(pdev, 0, 0);
10341032
if (!ioaddr) {
1035-
pci_release_regions(pdev);
1036-
pci_disable_device(pdev);
10371033
rc = -ENOMEM;
1038-
goto out;
1034+
goto out_release;
10391035
}
10401036

10411037
rc = vortex_probe1(&pdev->dev, ioaddr, pdev->irq,
10421038
ent->driver_data, unit);
1043-
if (rc < 0) {
1044-
pci_iounmap(pdev, ioaddr);
1045-
pci_release_regions(pdev);
1046-
pci_disable_device(pdev);
1047-
goto out;
1048-
}
1039+
if (rc < 0)
1040+
goto out_iounmap;
10491041

10501042
vortex_cards_found++;
1043+
goto out;
10511044

1045+
out_iounmap:
1046+
pci_iounmap(pdev, ioaddr);
1047+
out_release:
1048+
pci_release_regions(pdev);
1049+
out_disable:
1050+
pci_disable_device(pdev);
10521051
out:
10531052
return rc;
10541053
}

0 commit comments

Comments
 (0)