aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/davinci_nand.c
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@ti.com>2013-12-17 08:37:00 -0500
committerBrian Norris <computersforpeace@gmail.com>2014-01-03 14:22:25 -0500
commit30a3970cde5be1e2950946f2e943fb84d07938fc (patch)
treeb7a0bf7707737269babfe29f9dbc7c6be744f5fc /drivers/mtd/nand/davinci_nand.c
parent05103825fc1ef9a60a45ecf95db2b60c6e09be9a (diff)
mtd: nand: davinci: simplify error handling
There is not needed to use a lot of names for err handling. It complicates code support and reading. Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Taras Kondratiuk <taras@ti.com> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/davinci_nand.c')
-rw-r--r--drivers/mtd/nand/davinci_nand.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 9eea26953871..e6757b3a33b1 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -615,8 +615,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
615 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 615 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
616 if (!info) { 616 if (!info) {
617 dev_err(&pdev->dev, "unable to allocate memory\n"); 617 dev_err(&pdev->dev, "unable to allocate memory\n");
618 ret = -ENOMEM; 618 return -ENOMEM;
619 goto err_nomem;
620 } 619 }
621 620
622 platform_set_drvdata(pdev, info); 621 platform_set_drvdata(pdev, info);
@@ -625,20 +624,16 @@ static int nand_davinci_probe(struct platform_device *pdev)
625 res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 624 res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
626 if (!res1 || !res2) { 625 if (!res1 || !res2) {
627 dev_err(&pdev->dev, "resource missing\n"); 626 dev_err(&pdev->dev, "resource missing\n");
628 ret = -EINVAL; 627 return -EINVAL;
629 goto err_nomem;
630 } 628 }
631 629
632 vaddr = devm_ioremap_resource(&pdev->dev, res1); 630 vaddr = devm_ioremap_resource(&pdev->dev, res1);
633 if (IS_ERR(vaddr)) { 631 if (IS_ERR(vaddr))
634 ret = PTR_ERR(vaddr); 632 return PTR_ERR(vaddr);
635 goto err_ioremap; 633
636 }
637 base = devm_ioremap_resource(&pdev->dev, res2); 634 base = devm_ioremap_resource(&pdev->dev, res2);
638 if (IS_ERR(base)) { 635 if (IS_ERR(base))
639 ret = PTR_ERR(base); 636 return PTR_ERR(base);
640 goto err_ioremap;
641 }
642 637
643 info->dev = &pdev->dev; 638 info->dev = &pdev->dev;
644 info->base = base; 639 info->base = base;
@@ -705,7 +700,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
705 spin_unlock_irq(&davinci_nand_lock); 700 spin_unlock_irq(&davinci_nand_lock);
706 701
707 if (ret == -EBUSY) 702 if (ret == -EBUSY)
708 goto err_ecc; 703 return ret;
709 704
710 info->chip.ecc.calculate = nand_davinci_calculate_4bit; 705 info->chip.ecc.calculate = nand_davinci_calculate_4bit;
711 info->chip.ecc.correct = nand_davinci_correct_4bit; 706 info->chip.ecc.correct = nand_davinci_correct_4bit;
@@ -721,8 +716,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
721 info->chip.ecc.strength = pdata->ecc_bits; 716 info->chip.ecc.strength = pdata->ecc_bits;
722 break; 717 break;
723 default: 718 default:
724 ret = -EINVAL; 719 return -EINVAL;
725 goto err_ecc;
726 } 720 }
727 info->chip.ecc.mode = ecc_mode; 721 info->chip.ecc.mode = ecc_mode;
728 722
@@ -730,7 +724,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
730 if (IS_ERR(info->clk)) { 724 if (IS_ERR(info->clk)) {
731 ret = PTR_ERR(info->clk); 725 ret = PTR_ERR(info->clk);
732 dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); 726 dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
733 goto err_clk; 727 return ret;
734 } 728 }
735 729
736 ret = clk_prepare_enable(info->clk); 730 ret = clk_prepare_enable(info->clk);
@@ -759,7 +753,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
759 info->core_chipsel); 753 info->core_chipsel);
760 if (ret < 0) { 754 if (ret < 0) {
761 dev_dbg(&pdev->dev, "NAND timing values setup fail\n"); 755 dev_dbg(&pdev->dev, "NAND timing values setup fail\n");
762 goto err_timing; 756 goto err;
763 } 757 }
764 758
765 spin_lock_irq(&davinci_nand_lock); 759 spin_lock_irq(&davinci_nand_lock);
@@ -775,7 +769,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
775 ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1, NULL); 769 ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1, NULL);
776 if (ret < 0) { 770 if (ret < 0) {
777 dev_dbg(&pdev->dev, "no NAND chip(s) found\n"); 771 dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
778 goto err_scan; 772 goto err;
779 } 773 }
780 774
781 /* Update ECC layout if needed ... for 1-bit HW ECC, the default 775 /* Update ECC layout if needed ... for 1-bit HW ECC, the default
@@ -789,7 +783,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
789 if (!chunks || info->mtd.oobsize < 16) { 783 if (!chunks || info->mtd.oobsize < 16) {
790 dev_dbg(&pdev->dev, "too small\n"); 784 dev_dbg(&pdev->dev, "too small\n");
791 ret = -EINVAL; 785 ret = -EINVAL;
792 goto err_scan; 786 goto err;
793 } 787 }
794 788
795 /* For small page chips, preserve the manufacturer's 789 /* For small page chips, preserve the manufacturer's
@@ -820,7 +814,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
820 dev_warn(&pdev->dev, "no 4-bit ECC support yet " 814 dev_warn(&pdev->dev, "no 4-bit ECC support yet "
821 "for 4KiB-page NAND\n"); 815 "for 4KiB-page NAND\n");
822 ret = -EIO; 816 ret = -EIO;
823 goto err_scan; 817 goto err;
824 818
825syndrome_done: 819syndrome_done:
826 info->chip.ecc.layout = &info->ecclayout; 820 info->chip.ecc.layout = &info->ecclayout;
@@ -828,7 +822,7 @@ syndrome_done:
828 822
829 ret = nand_scan_tail(&info->mtd); 823 ret = nand_scan_tail(&info->mtd);
830 if (ret < 0) 824 if (ret < 0)
831 goto err_scan; 825 goto err;
832 826
833 if (pdata->parts) 827 if (pdata->parts)
834 ret = mtd_device_parse_register(&info->mtd, NULL, NULL, 828 ret = mtd_device_parse_register(&info->mtd, NULL, NULL,
@@ -841,7 +835,7 @@ syndrome_done:
841 NULL, 0); 835 NULL, 0);
842 } 836 }
843 if (ret < 0) 837 if (ret < 0)
844 goto err_scan; 838 goto err;
845 839
846 val = davinci_nand_readl(info, NRCSR_OFFSET); 840 val = davinci_nand_readl(info, NRCSR_OFFSET);
847 dev_info(&pdev->dev, "controller rev. %d.%d\n", 841 dev_info(&pdev->dev, "controller rev. %d.%d\n",
@@ -849,8 +843,7 @@ syndrome_done:
849 843
850 return 0; 844 return 0;
851 845
852err_scan: 846err:
853err_timing:
854 clk_disable_unprepare(info->clk); 847 clk_disable_unprepare(info->clk);
855 848
856err_clk_enable: 849err_clk_enable:
@@ -858,11 +851,6 @@ err_clk_enable:
858 if (ecc_mode == NAND_ECC_HW_SYNDROME) 851 if (ecc_mode == NAND_ECC_HW_SYNDROME)
859 ecc4_busy = false; 852 ecc4_busy = false;
860 spin_unlock_irq(&davinci_nand_lock); 853 spin_unlock_irq(&davinci_nand_lock);
861
862err_ecc:
863err_clk:
864err_ioremap:
865err_nomem:
866 return ret; 854 return ret;
867} 855}
868 856