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_sun4v.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_sun4v.c')
-rw-r--r-- | arch/sparc64/kernel/pci_sun4v.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index fea51a054be5..21864f065323 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
@@ -949,7 +949,7 @@ static int __devinit pci_sun4v_probe(struct of_device *op, | |||
949 | struct device_node *dp; | 949 | struct device_node *dp; |
950 | struct iommu *iommu; | 950 | struct iommu *iommu; |
951 | u32 devhandle; | 951 | u32 devhandle; |
952 | int i; | 952 | int i, err; |
953 | 953 | ||
954 | dp = op->node; | 954 | dp = op->node; |
955 | 955 | ||
@@ -970,9 +970,10 @@ static int __devinit pci_sun4v_probe(struct of_device *op, | |||
970 | } | 970 | } |
971 | 971 | ||
972 | regs = of_get_property(dp, "reg", NULL); | 972 | regs = of_get_property(dp, "reg", NULL); |
973 | err = -ENODEV; | ||
973 | if (!regs) { | 974 | if (!regs) { |
974 | printk(KERN_ERR PFX "Could not find config registers\n"); | 975 | printk(KERN_ERR PFX "Could not find config registers\n"); |
975 | return -ENODEV; | 976 | goto out_err; |
976 | } | 977 | } |
977 | devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff; | 978 | devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff; |
978 | 979 | ||
@@ -982,11 +983,12 @@ static int __devinit pci_sun4v_probe(struct of_device *op, | |||
982 | } | 983 | } |
983 | } | 984 | } |
984 | 985 | ||
986 | err = -ENOMEM; | ||
985 | for_each_possible_cpu(i) { | 987 | for_each_possible_cpu(i) { |
986 | unsigned long page = get_zeroed_page(GFP_ATOMIC); | 988 | unsigned long page = get_zeroed_page(GFP_ATOMIC); |
987 | 989 | ||
988 | if (!page) | 990 | if (!page) |
989 | return -ENOMEM; | 991 | goto out_err; |
990 | 992 | ||
991 | per_cpu(iommu_batch, i).pglist = (u64 *) page; | 993 | per_cpu(iommu_batch, i).pglist = (u64 *) page; |
992 | } | 994 | } |
@@ -994,13 +996,13 @@ static int __devinit pci_sun4v_probe(struct of_device *op, | |||
994 | p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); | 996 | p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); |
995 | if (!p) { | 997 | if (!p) { |
996 | printk(KERN_ERR PFX "Could not allocate pci_controller_info\n"); | 998 | printk(KERN_ERR PFX "Could not allocate pci_controller_info\n"); |
997 | goto out_free; | 999 | goto out_err; |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); | 1002 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); |
1001 | if (!iommu) { | 1003 | if (!iommu) { |
1002 | printk(KERN_ERR PFX "Could not allocate pbm A iommu\n"); | 1004 | printk(KERN_ERR PFX "Could not allocate pbm A iommu\n"); |
1003 | goto out_free; | 1005 | goto out_free_controller; |
1004 | } | 1006 | } |
1005 | 1007 | ||
1006 | p->pbm_A.iommu = iommu; | 1008 | p->pbm_A.iommu = iommu; |
@@ -1008,22 +1010,21 @@ static int __devinit pci_sun4v_probe(struct of_device *op, | |||
1008 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); | 1010 | iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); |
1009 | if (!iommu) { | 1011 | if (!iommu) { |
1010 | printk(KERN_ERR PFX "Could not allocate pbm B iommu\n"); | 1012 | printk(KERN_ERR PFX "Could not allocate pbm B iommu\n"); |
1011 | goto out_free; | 1013 | goto out_free_iommu_A; |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | p->pbm_B.iommu = iommu; | 1016 | p->pbm_B.iommu = iommu; |
1015 | 1017 | ||
1016 | return pci_sun4v_pbm_init(p, dp, devhandle); | 1018 | return pci_sun4v_pbm_init(p, dp, devhandle); |
1017 | 1019 | ||
1018 | out_free: | 1020 | out_free_iommu_A: |
1019 | if (p) { | 1021 | kfree(p->pbm_A.iommu); |
1020 | if (p->pbm_A.iommu) | 1022 | |
1021 | kfree(p->pbm_A.iommu); | 1023 | out_free_controller: |
1022 | if (p->pbm_B.iommu) | 1024 | kfree(p); |
1023 | kfree(p->pbm_B.iommu); | 1025 | |
1024 | kfree(p); | 1026 | out_err: |
1025 | } | 1027 | return err; |
1026 | return -ENOMEM; | ||
1027 | } | 1028 | } |
1028 | 1029 | ||
1029 | static struct of_device_id __initdata pci_sun4v_match[] = { | 1030 | static struct of_device_id __initdata pci_sun4v_match[] = { |