diff options
author | David S. Miller <davem@davemloft.net> | 2008-08-31 04:33:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-31 04:33:52 -0400 |
commit | d7472c389ee1044d04af8a5b7c51aa7af96ed2db (patch) | |
tree | 121b7fae49d8e329405bad97309f48f2ec8d9e8f /arch/sparc64/kernel/pci_schizo.c | |
parent | fd098316ef533e8441576f020ead4beab93154ce (diff) |
sparc64: Simplify error handling in PCI controller probing.
Based upon suggestions from Stephen Rothwell.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_schizo.c')
-rw-r--r-- | arch/sparc64/kernel/pci_schizo.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index 18fdd887b4ac..bd7612aae17e 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c | |||
@@ -1443,14 +1443,16 @@ static int __devinit __schizo_init(struct device_node *dp, unsigned long chip_ty | |||
1443 | struct pci_pbm_info *pbm; | 1443 | struct pci_pbm_info *pbm; |
1444 | struct iommu *iommu; | 1444 | struct iommu *iommu; |
1445 | u32 portid; | 1445 | u32 portid; |
1446 | int err; | ||
1446 | 1447 | ||
1447 | portid = of_getintprop_default(dp, "portid", 0xff); | 1448 | portid = of_getintprop_default(dp, "portid", 0xff); |
1448 | 1449 | ||
1450 | err = -ENOMEM; | ||
1449 | for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { | 1451 | for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { |
1450 | if (portid_compare(pbm->portid, portid, chip_type)) { | 1452 | if (portid_compare(pbm->portid, portid, chip_type)) { |
1451 | if (schizo_pbm_init(pbm->parent, dp, | 1453 | if (schizo_pbm_init(pbm->parent, dp, |
1452 | portid, chip_type)) | 1454 | portid, chip_type)) |
1453 | return -ENOMEM; | 1455 | goto out_err; |
1454 | return 0; | 1456 | return 0; |
1455 | } | 1457 | } |
1456 | } | 1458 | } |
@@ -1458,13 +1460,13 @@ static int __devinit __schizo_init(struct device_node *dp, unsigned long chip_ty | |||
1458 | p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); | 1460 | p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); |
1459 | if (!p) { | 1461 | if (!p) { |
1460 | printk(KERN_ERR PFX "Cannot allocate controller info.\n"); | 1462 | printk(KERN_ERR PFX "Cannot allocate controller info.\n"); |
1461 | goto out_free; | 1463 | goto out_err; |
1462 | } | 1464 | } |
1463 | 1465 | ||
1464 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); | 1466 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); |
1465 | if (!iommu) { | 1467 | if (!iommu) { |
1466 | printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n"); | 1468 | printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n"); |
1467 | goto out_free; | 1469 | goto out_free_controller; |
1468 | } | 1470 | } |
1469 | 1471 | ||
1470 | p->pbm_A.iommu = iommu; | 1472 | p->pbm_A.iommu = iommu; |
@@ -1472,25 +1474,27 @@ static int __devinit __schizo_init(struct device_node *dp, unsigned long chip_ty | |||
1472 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); | 1474 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); |
1473 | if (!iommu) { | 1475 | if (!iommu) { |
1474 | printk(KERN_ERR PFX "Cannot allocate PBM B iommu.\n"); | 1476 | printk(KERN_ERR PFX "Cannot allocate PBM B iommu.\n"); |
1475 | goto out_free; | 1477 | goto out_free_iommu_A; |
1476 | } | 1478 | } |
1477 | 1479 | ||
1478 | p->pbm_B.iommu = iommu; | 1480 | p->pbm_B.iommu = iommu; |
1479 | 1481 | ||
1480 | if (schizo_pbm_init(p, dp, portid, chip_type)) | 1482 | if (schizo_pbm_init(p, dp, portid, chip_type)) |
1481 | goto out_free; | 1483 | goto out_free_iommu_B; |
1482 | 1484 | ||
1483 | return 0; | 1485 | return 0; |
1484 | 1486 | ||
1485 | out_free: | 1487 | out_free_iommu_B: |
1486 | if (p) { | 1488 | kfree(p->pbm_B.iommu); |
1487 | if (p->pbm_A.iommu) | 1489 | |
1488 | kfree(p->pbm_A.iommu); | 1490 | out_free_iommu_A: |
1489 | if (p->pbm_B.iommu) | 1491 | kfree(p->pbm_A.iommu); |
1490 | kfree(p->pbm_B.iommu); | 1492 | |
1491 | kfree(p); | 1493 | out_free_controller: |
1492 | } | 1494 | kfree(p); |
1493 | return -ENOMEM; | 1495 | |
1496 | out_err: | ||
1497 | return err; | ||
1494 | } | 1498 | } |
1495 | 1499 | ||
1496 | static int __devinit schizo_probe(struct of_device *op, | 1500 | static int __devinit schizo_probe(struct of_device *op, |