diff options
author | Bryan Wu <cooloney@kernel.org> | 2008-07-30 15:35:04 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-08-01 10:44:22 -0400 |
commit | 4f0ca70e52b67f41287d853f0d572dafa875e485 (patch) | |
tree | f94dbab8700bee7e8ba0a802fa67f7e4decbb3ae /drivers/mtd/nand | |
parent | 0ee002b041cb45ab3cc5384b86271d41ccf90fe1 (diff) |
[MTD] [NAND] Blackfin NFC Driver: Cleanup the error exit path of bf5xx_nand_probe function
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Cc: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/bf5xx_nand.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c index 6cf7fb86c256..9af2a2cc1153 100644 --- a/drivers/mtd/nand/bf5xx_nand.c +++ b/drivers/mtd/nand/bf5xx_nand.c | |||
@@ -549,7 +549,6 @@ static void bf5xx_nand_dma_write_buf(struct mtd_info *mtd, | |||
549 | /* | 549 | /* |
550 | * System initialization functions | 550 | * System initialization functions |
551 | */ | 551 | */ |
552 | |||
553 | static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info) | 552 | static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info) |
554 | { | 553 | { |
555 | int ret; | 554 | int ret; |
@@ -582,6 +581,13 @@ static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info) | |||
582 | return 0; | 581 | return 0; |
583 | } | 582 | } |
584 | 583 | ||
584 | static void bf5xx_nand_dma_remove(struct bf5xx_nand_info *info) | ||
585 | { | ||
586 | /* Free NFC DMA channel */ | ||
587 | if (hardware_ecc) | ||
588 | free_dma(CH_NFC); | ||
589 | } | ||
590 | |||
585 | /* | 591 | /* |
586 | * BF5XX NFC hardware initialization | 592 | * BF5XX NFC hardware initialization |
587 | * - pin mux setup | 593 | * - pin mux setup |
@@ -658,6 +664,7 @@ static int __devexit bf5xx_nand_remove(struct platform_device *pdev) | |||
658 | } | 664 | } |
659 | 665 | ||
660 | peripheral_free_list(bfin_nfc_pin_req); | 666 | peripheral_free_list(bfin_nfc_pin_req); |
667 | bf5xx_nand_dma_remove(info); | ||
661 | 668 | ||
662 | /* free the common resources */ | 669 | /* free the common resources */ |
663 | kfree(info); | 670 | kfree(info); |
@@ -683,21 +690,21 @@ static int __devinit bf5xx_nand_probe(struct platform_device *pdev) | |||
683 | 690 | ||
684 | dev_dbg(&pdev->dev, "(%p)\n", pdev); | 691 | dev_dbg(&pdev->dev, "(%p)\n", pdev); |
685 | 692 | ||
693 | if (!plat) { | ||
694 | dev_err(&pdev->dev, "no platform specific information\n"); | ||
695 | return -EINVAL; | ||
696 | } | ||
697 | |||
686 | if (peripheral_request_list(bfin_nfc_pin_req, DRV_NAME)) { | 698 | if (peripheral_request_list(bfin_nfc_pin_req, DRV_NAME)) { |
687 | dev_err(&pdev->dev, "requesting Peripherals failed\n"); | 699 | dev_err(&pdev->dev, "requesting Peripherals failed\n"); |
688 | return -EFAULT; | 700 | return -EFAULT; |
689 | } | 701 | } |
690 | 702 | ||
691 | if (!plat) { | ||
692 | dev_err(&pdev->dev, "no platform specific information\n"); | ||
693 | goto exit_error; | ||
694 | } | ||
695 | |||
696 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 703 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
697 | if (info == NULL) { | 704 | if (info == NULL) { |
698 | dev_err(&pdev->dev, "no memory for flash info\n"); | 705 | dev_err(&pdev->dev, "no memory for flash info\n"); |
699 | err = -ENOMEM; | 706 | err = -ENOMEM; |
700 | goto exit_error; | 707 | goto out_err_kzalloc; |
701 | } | 708 | } |
702 | 709 | ||
703 | platform_set_drvdata(pdev, info); | 710 | platform_set_drvdata(pdev, info); |
@@ -741,8 +748,8 @@ static int __devinit bf5xx_nand_probe(struct platform_device *pdev) | |||
741 | 748 | ||
742 | /* initialise the hardware */ | 749 | /* initialise the hardware */ |
743 | err = bf5xx_nand_hw_init(info); | 750 | err = bf5xx_nand_hw_init(info); |
744 | if (err != 0) | 751 | if (err) |
745 | goto exit_error; | 752 | goto out_err_hw_init; |
746 | 753 | ||
747 | /* setup hardware ECC data struct */ | 754 | /* setup hardware ECC data struct */ |
748 | if (hardware_ecc) { | 755 | if (hardware_ecc) { |
@@ -772,7 +779,7 @@ static int __devinit bf5xx_nand_probe(struct platform_device *pdev) | |||
772 | /* scan hardware nand chip and setup mtd info data struct */ | 779 | /* scan hardware nand chip and setup mtd info data struct */ |
773 | if (nand_scan(mtd, 1)) { | 780 | if (nand_scan(mtd, 1)) { |
774 | err = -ENXIO; | 781 | err = -ENXIO; |
775 | goto exit_error; | 782 | goto out_err_nand_scan; |
776 | } | 783 | } |
777 | 784 | ||
778 | /* add NAND partition */ | 785 | /* add NAND partition */ |
@@ -781,11 +788,14 @@ static int __devinit bf5xx_nand_probe(struct platform_device *pdev) | |||
781 | dev_dbg(&pdev->dev, "initialised ok\n"); | 788 | dev_dbg(&pdev->dev, "initialised ok\n"); |
782 | return 0; | 789 | return 0; |
783 | 790 | ||
784 | exit_error: | 791 | out_err_nand_scan: |
785 | bf5xx_nand_remove(pdev); | 792 | bf5xx_nand_dma_remove(info); |
793 | out_err_hw_init: | ||
794 | platform_set_drvdata(pdev, NULL); | ||
795 | kfree(info); | ||
796 | out_err_kzalloc: | ||
797 | peripheral_free_list(bfin_nfc_pin_req); | ||
786 | 798 | ||
787 | if (err == 0) | ||
788 | err = -EINVAL; | ||
789 | return err; | 799 | return err; |
790 | } | 800 | } |
791 | 801 | ||