Based upon suggestions from Stephen Rothwell.
Signed-off-by: David S. Miller <davem@davemloft.net>
p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) {
printk(KERN_ERR PFX "Cannot allocate controller info.\n");
- goto out_free;
+ goto out_err;
}
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n");
- goto out_free;
+ goto out_free_controller;
}
p->pbm_A.iommu = iommu;
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n");
- goto out_free;
+ goto out_free_iommu_A;
}
p->pbm_B.iommu = iommu;
return pci_fire_pbm_init(p, dp, portid);
-out_free:
- if (p) {
- if (p->pbm_A.iommu)
- kfree(p->pbm_A.iommu);
- if (p->pbm_B.iommu)
- kfree(p->pbm_B.iommu);
- kfree(p);
- }
+out_free_iommu_A:
+ kfree(p->pbm_A.iommu);
+
+out_free_controller:
+ kfree(p);
+
+out_err:
return err;
}
p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) {
printk(KERN_ERR PFX "Cannot allocate controller info.\n");
- goto out_free;
+ goto out_err;
}
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n");
- goto out_free;
+ goto out_free_controller;
}
p->pbm_A.iommu = p->pbm_B.iommu = iommu;
err = -ENODEV;
if (!pr_regs) {
printk(KERN_ERR PFX "No reg property.\n");
- goto out_free;
+ goto out_free_iommu;
}
p->pbm_A.controller_regs = pr_regs[2].phys_addr;
err = psycho_iommu_init(&p->pbm_A);
if (err)
- goto out_free;
+ goto out_free_iommu;
is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000);
return 0;
-out_free:
- if (p) {
- if (p->pbm_A.iommu)
- kfree(p->pbm_A.iommu);
- kfree(p);
- }
+out_free_iommu:
+ kfree(p->pbm_A.iommu);
+
+out_free_controller:
+ kfree(p);
+
+out_err:
return err;
}
p = kzalloc(sizeof(*p), GFP_ATOMIC);
if (!p) {
printk(KERN_ERR PFX "Cannot allocate controller info.\n");
- goto out_free;
+ goto out_err;
}
iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n");
- goto out_free;
+ goto out_free_controller;
}
pbm = &p->pbm_A;
err = -ENODEV;
if (!pr_regs) {
printk(KERN_ERR PFX "No reg property\n");
- goto out_free;
+ goto out_free_iommu;
}
/*
vdma = of_get_property(dp, "virtual-dma", NULL);
if (!vdma) {
printk(KERN_ERR PFX "No virtual-dma property\n");
- goto out_free;
+ goto out_free_iommu;
}
dma_mask = vdma[0];
break;
default:
printk(KERN_ERR PFX "Strange virtual-dma size.\n");
- goto out_free;
+ goto out_free_iommu;
}
err = sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask);
if (err)
- goto out_free;
+ goto out_free_iommu;
/*
* Look for APB underneath.
sabre_pbm_init(p, pbm, dp);
return 0;
-out_free:
- if (p) {
- if (p->pbm_A.iommu)
- kfree(p->pbm_A.iommu);
- kfree(p);
- }
+out_free_iommu:
+ kfree(p->pbm_A.iommu);
+
+out_free_controller:
+ kfree(p);
+
+out_err:
return err;
}
struct pci_pbm_info *pbm;
struct iommu *iommu;
u32 portid;
+ int err;
portid = of_getintprop_default(dp, "portid", 0xff);
+ err = -ENOMEM;
for (pbm = pci_pbm_root; pbm; pbm = pbm->next) {
if (portid_compare(pbm->portid, portid, chip_type)) {
if (schizo_pbm_init(pbm->parent, dp,
portid, chip_type))
- return -ENOMEM;
+ goto out_err;
return 0;
}
}
p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) {
printk(KERN_ERR PFX "Cannot allocate controller info.\n");
- goto out_free;
+ goto out_err;
}
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n");
- goto out_free;
+ goto out_free_controller;
}
p->pbm_A.iommu = iommu;
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Cannot allocate PBM B iommu.\n");
- goto out_free;
+ goto out_free_iommu_A;
}
p->pbm_B.iommu = iommu;
if (schizo_pbm_init(p, dp, portid, chip_type))
- goto out_free;
+ goto out_free_iommu_B;
return 0;
-out_free:
- if (p) {
- if (p->pbm_A.iommu)
- kfree(p->pbm_A.iommu);
- if (p->pbm_B.iommu)
- kfree(p->pbm_B.iommu);
- kfree(p);
- }
- return -ENOMEM;
+out_free_iommu_B:
+ kfree(p->pbm_B.iommu);
+
+out_free_iommu_A:
+ kfree(p->pbm_A.iommu);
+
+out_free_controller:
+ kfree(p);
+
+out_err:
+ return err;
}
static int __devinit schizo_probe(struct of_device *op,
struct device_node *dp;
struct iommu *iommu;
u32 devhandle;
- int i;
+ int i, err;
dp = op->node;
}
regs = of_get_property(dp, "reg", NULL);
+ err = -ENODEV;
if (!regs) {
printk(KERN_ERR PFX "Could not find config registers\n");
- return -ENODEV;
+ goto out_err;
}
devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff;
}
}
+ err = -ENOMEM;
for_each_possible_cpu(i) {
unsigned long page = get_zeroed_page(GFP_ATOMIC);
if (!page)
- return -ENOMEM;
+ goto out_err;
per_cpu(iommu_batch, i).pglist = (u64 *) page;
}
p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) {
printk(KERN_ERR PFX "Could not allocate pci_controller_info\n");
- goto out_free;
+ goto out_err;
}
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Could not allocate pbm A iommu\n");
- goto out_free;
+ goto out_free_controller;
}
p->pbm_A.iommu = iommu;
iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
if (!iommu) {
printk(KERN_ERR PFX "Could not allocate pbm B iommu\n");
- goto out_free;
+ goto out_free_iommu_A;
}
p->pbm_B.iommu = iommu;
return pci_sun4v_pbm_init(p, dp, devhandle);
-out_free:
- if (p) {
- if (p->pbm_A.iommu)
- kfree(p->pbm_A.iommu);
- if (p->pbm_B.iommu)
- kfree(p->pbm_B.iommu);
- kfree(p);
- }
- return -ENOMEM;
+out_free_iommu_A:
+ kfree(p->pbm_A.iommu);
+
+out_free_controller:
+ kfree(p);
+
+out_err:
+ return err;
}
static struct of_device_id __initdata pci_sun4v_match[] = {