Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Bryan Wu and committed by
David Woodhouse
4f0ca70e 0ee002b0

+24 -14
+24 -14
drivers/mtd/nand/bf5xx_nand.c
··· 549 549 /* 550 550 * System initialization functions 551 551 */ 552 - 553 552 static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info) 554 553 { 555 554 int ret; ··· 579 580 /* Turn off the DMA channel first */ 580 581 disable_dma(CH_NFC); 581 582 return 0; 583 + } 584 + 585 + static void bf5xx_nand_dma_remove(struct bf5xx_nand_info *info) 586 + { 587 + /* Free NFC DMA channel */ 588 + if (hardware_ecc) 589 + free_dma(CH_NFC); 582 590 } 583 591 584 592 /* ··· 664 658 } 665 659 666 660 peripheral_free_list(bfin_nfc_pin_req); 661 + bf5xx_nand_dma_remove(info); 667 662 668 663 /* free the common resources */ 669 664 kfree(info); ··· 690 683 691 684 dev_dbg(&pdev->dev, "(%p)\n", pdev); 692 685 686 + if (!plat) { 687 + dev_err(&pdev->dev, "no platform specific information\n"); 688 + return -EINVAL; 689 + } 690 + 693 691 if (peripheral_request_list(bfin_nfc_pin_req, DRV_NAME)) { 694 692 dev_err(&pdev->dev, "requesting Peripherals failed\n"); 695 693 return -EFAULT; 696 - } 697 - 698 - if (!plat) { 699 - dev_err(&pdev->dev, "no platform specific information\n"); 700 - goto exit_error; 701 694 } 702 695 703 696 info = kzalloc(sizeof(*info), GFP_KERNEL); 704 697 if (info == NULL) { 705 698 dev_err(&pdev->dev, "no memory for flash info\n"); 706 699 err = -ENOMEM; 707 - goto exit_error; 700 + goto out_err_kzalloc; 708 701 } 709 702 710 703 platform_set_drvdata(pdev, info); ··· 748 741 749 742 /* initialise the hardware */ 750 743 err = bf5xx_nand_hw_init(info); 751 - if (err != 0) 752 - goto exit_error; 744 + if (err) 745 + goto out_err_hw_init; 753 746 754 747 /* setup hardware ECC data struct */ 755 748 if (hardware_ecc) { ··· 779 772 /* scan hardware nand chip and setup mtd info data struct */ 780 773 if (nand_scan(mtd, 1)) { 781 774 err = -ENXIO; 782 - goto exit_error; 775 + goto out_err_nand_scan; 783 776 } 784 777 785 778 /* add NAND partition */ ··· 788 781 dev_dbg(&pdev->dev, "initialised ok\n"); 789 782 return 0; 790 783 791 - exit_error: 792 - bf5xx_nand_remove(pdev); 784 + out_err_nand_scan: 785 + bf5xx_nand_dma_remove(info); 786 + out_err_hw_init: 787 + platform_set_drvdata(pdev, NULL); 788 + kfree(info); 789 + out_err_kzalloc: 790 + peripheral_free_list(bfin_nfc_pin_req); 793 791 794 - if (err == 0) 795 - err = -EINVAL; 796 792 return err; 797 793 } 798 794