aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2011-08-10 04:14:14 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 08:02:17 -0400
commit38ca6ebc72d59c0c4f52d443c69fc4a17765666a (patch)
tree97758a3df7ce49ea585e310bb1c8b51f3b411e49 /drivers/mtd/nand
parentf975c6bcb07caacff7fa9904e5d2daa51bcf549d (diff)
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>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/bcm_umi_nand.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
index a8ae89865a86..46b58d672847 100644
--- a/drivers/mtd/nand/bcm_umi_nand.c
+++ b/drivers/mtd/nand/bcm_umi_nand.c
@@ -374,16 +374,18 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
374 374
375 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 375 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
376 376
377 if (!r) 377 if (!r) {
378 return -ENXIO; 378 err = -ENXIO;
379 goto out_free;
380 }
379 381
380 /* map physical address */ 382 /* map physical address */
381 bcm_umi_io_base = ioremap(r->start, resource_size(r)); 383 bcm_umi_io_base = ioremap(r->start, resource_size(r));
382 384
383 if (!bcm_umi_io_base) { 385 if (!bcm_umi_io_base) {
384 printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n"); 386 printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n");
385 kfree(board_mtd); 387 err = -EIO;
386 return -EIO; 388 goto out_free;
387 } 389 }
388 390
389 /* Get pointer to private data */ 391 /* Get pointer to private data */
@@ -399,9 +401,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
399 /* Initialize the NAND hardware. */ 401 /* Initialize the NAND hardware. */
400 if (bcm_umi_nand_inithw() < 0) { 402 if (bcm_umi_nand_inithw() < 0) {
401 printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n"); 403 printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n");
402 iounmap(bcm_umi_io_base); 404 err = -EIO;
403 kfree(board_mtd); 405 goto out_unmap;
404 return -EIO;
405 } 406 }
406 407
407 /* Set address of NAND IO lines */ 408 /* Set address of NAND IO lines */
@@ -434,7 +435,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
434#if USE_DMA 435#if USE_DMA
435 err = nand_dma_init(); 436 err = nand_dma_init();
436 if (err != 0) 437 if (err != 0)
437 return err; 438 goto out_unmap;
438#endif 439#endif
439 440
440 /* Figure out the size of the device that we have. 441 /* 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)
445 err = nand_scan_ident(board_mtd, 1, NULL); 446 err = nand_scan_ident(board_mtd, 1, NULL);
446 if (err) { 447 if (err) {
447 printk(KERN_ERR "nand_scan failed: %d\n", err); 448 printk(KERN_ERR "nand_scan failed: %d\n", err);
448 iounmap(bcm_umi_io_base); 449 goto out_unmap;
449 kfree(board_mtd);
450 return err;
451 } 450 }
452 451
453 /* Now that we know the nand size, we can setup the ECC layout */ 452 /* 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)
466 { 465 {
467 printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n", 466 printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n",
468 board_mtd->writesize); 467 board_mtd->writesize);
469 return -EINVAL; 468 err = -EINVAL;
469 goto out_unmap;
470 } 470 }
471 } 471 }
472 472
@@ -483,9 +483,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
483 err = nand_scan_tail(board_mtd); 483 err = nand_scan_tail(board_mtd);
484 if (err) { 484 if (err) {
485 printk(KERN_ERR "nand_scan failed: %d\n", err); 485 printk(KERN_ERR "nand_scan failed: %d\n", err);
486 iounmap(bcm_umi_io_base); 486 goto out_unmap;
487 kfree(board_mtd);
488 return err;
489 } 487 }
490 488
491 /* Register the partitions */ 489 /* Register the partitions */
@@ -494,6 +492,11 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
494 492
495 /* Return happy */ 493 /* Return happy */
496 return 0; 494 return 0;
495out_unmap:
496 iounmap(bcm_umi_io_base);
497out_free:
498 kfree(board_mtd);
499 return err;
497} 500}
498 501
499static int bcm_umi_nand_remove(struct platform_device *pdev) 502static int bcm_umi_nand_remove(struct platform_device *pdev)