mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 16:53:54 +08:00
mtd: bcm_umi_nand: clean up error handling code
Convert error handling code to use gotos. At the same time, this adds calls to kfree and iounmap in a few cases where they were overlooked. Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Jiandong Zheng <jdzheng@broadcom.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
This commit is contained in:
parent
f975c6bcb0
commit
38ca6ebc72
@ -374,16 +374,18 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
|
||||||
if (!r)
|
if (!r) {
|
||||||
return -ENXIO;
|
err = -ENXIO;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
/* map physical address */
|
/* map physical address */
|
||||||
bcm_umi_io_base = ioremap(r->start, resource_size(r));
|
bcm_umi_io_base = ioremap(r->start, resource_size(r));
|
||||||
|
|
||||||
if (!bcm_umi_io_base) {
|
if (!bcm_umi_io_base) {
|
||||||
printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n");
|
printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n");
|
||||||
kfree(board_mtd);
|
err = -EIO;
|
||||||
return -EIO;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get pointer to private data */
|
/* Get pointer to private data */
|
||||||
@ -399,9 +401,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
/* Initialize the NAND hardware. */
|
/* Initialize the NAND hardware. */
|
||||||
if (bcm_umi_nand_inithw() < 0) {
|
if (bcm_umi_nand_inithw() < 0) {
|
||||||
printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n");
|
printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n");
|
||||||
iounmap(bcm_umi_io_base);
|
err = -EIO;
|
||||||
kfree(board_mtd);
|
goto out_unmap;
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set address of NAND IO lines */
|
/* Set address of NAND IO lines */
|
||||||
@ -434,7 +435,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
#if USE_DMA
|
#if USE_DMA
|
||||||
err = nand_dma_init();
|
err = nand_dma_init();
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
return err;
|
goto out_unmap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Figure out the size of the device that we have.
|
/* Figure out the size of the device that we have.
|
||||||
@ -445,9 +446,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
err = nand_scan_ident(board_mtd, 1, NULL);
|
err = nand_scan_ident(board_mtd, 1, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
||||||
iounmap(bcm_umi_io_base);
|
goto out_unmap;
|
||||||
kfree(board_mtd);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that we know the nand size, we can setup the ECC layout */
|
/* Now that we know the nand size, we can setup the ECC layout */
|
||||||
@ -466,7 +465,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n",
|
printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n",
|
||||||
board_mtd->writesize);
|
board_mtd->writesize);
|
||||||
return -EINVAL;
|
err = -EINVAL;
|
||||||
|
goto out_unmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,9 +483,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
err = nand_scan_tail(board_mtd);
|
err = nand_scan_tail(board_mtd);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
||||||
iounmap(bcm_umi_io_base);
|
goto out_unmap;
|
||||||
kfree(board_mtd);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the partitions */
|
/* Register the partitions */
|
||||||
@ -494,6 +492,11 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
/* Return happy */
|
/* Return happy */
|
||||||
return 0;
|
return 0;
|
||||||
|
out_unmap:
|
||||||
|
iounmap(bcm_umi_io_base);
|
||||||
|
out_free:
|
||||||
|
kfree(board_mtd);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm_umi_nand_remove(struct platform_device *pdev)
|
static int bcm_umi_nand_remove(struct platform_device *pdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user