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

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>

authored by

Ivan Khoronzhuk and committed by
Brian Norris
30a3970c 05103825

+17 -29
+17 -29
drivers/mtd/nand/davinci_nand.c
··· 615 615 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 616 616 if (!info) { 617 617 dev_err(&pdev->dev, "unable to allocate memory\n"); 618 - ret = -ENOMEM; 619 - goto err_nomem; 618 + return -ENOMEM; 620 619 } 621 620 622 621 platform_set_drvdata(pdev, info); ··· 624 625 res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 625 626 if (!res1 || !res2) { 626 627 dev_err(&pdev->dev, "resource missing\n"); 627 - ret = -EINVAL; 628 - goto err_nomem; 628 + return -EINVAL; 629 629 } 630 630 631 631 vaddr = devm_ioremap_resource(&pdev->dev, res1); 632 - if (IS_ERR(vaddr)) { 633 - ret = PTR_ERR(vaddr); 634 - goto err_ioremap; 635 - } 632 + if (IS_ERR(vaddr)) 633 + return PTR_ERR(vaddr); 634 + 636 635 base = devm_ioremap_resource(&pdev->dev, res2); 637 - if (IS_ERR(base)) { 638 - ret = PTR_ERR(base); 639 - goto err_ioremap; 640 - } 636 + if (IS_ERR(base)) 637 + return PTR_ERR(base); 641 638 642 639 info->dev = &pdev->dev; 643 640 info->base = base; ··· 700 705 spin_unlock_irq(&davinci_nand_lock); 701 706 702 707 if (ret == -EBUSY) 703 - goto err_ecc; 708 + return ret; 704 709 705 710 info->chip.ecc.calculate = nand_davinci_calculate_4bit; 706 711 info->chip.ecc.correct = nand_davinci_correct_4bit; ··· 716 721 info->chip.ecc.strength = pdata->ecc_bits; 717 722 break; 718 723 default: 719 - ret = -EINVAL; 720 - goto err_ecc; 724 + return -EINVAL; 721 725 } 722 726 info->chip.ecc.mode = ecc_mode; 723 727 ··· 724 730 if (IS_ERR(info->clk)) { 725 731 ret = PTR_ERR(info->clk); 726 732 dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); 727 - goto err_clk; 733 + return ret; 728 734 } 729 735 730 736 ret = clk_prepare_enable(info->clk); ··· 753 759 info->core_chipsel); 754 760 if (ret < 0) { 755 761 dev_dbg(&pdev->dev, "NAND timing values setup fail\n"); 756 - goto err_timing; 762 + goto err; 757 763 } 758 764 759 765 spin_lock_irq(&davinci_nand_lock); ··· 769 775 ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1, NULL); 770 776 if (ret < 0) { 771 777 dev_dbg(&pdev->dev, "no NAND chip(s) found\n"); 772 - goto err_scan; 778 + goto err; 773 779 } 774 780 775 781 /* Update ECC layout if needed ... for 1-bit HW ECC, the default ··· 783 789 if (!chunks || info->mtd.oobsize < 16) { 784 790 dev_dbg(&pdev->dev, "too small\n"); 785 791 ret = -EINVAL; 786 - goto err_scan; 792 + goto err; 787 793 } 788 794 789 795 /* For small page chips, preserve the manufacturer's ··· 814 820 dev_warn(&pdev->dev, "no 4-bit ECC support yet " 815 821 "for 4KiB-page NAND\n"); 816 822 ret = -EIO; 817 - goto err_scan; 823 + goto err; 818 824 819 825 syndrome_done: 820 826 info->chip.ecc.layout = &info->ecclayout; ··· 822 828 823 829 ret = nand_scan_tail(&info->mtd); 824 830 if (ret < 0) 825 - goto err_scan; 831 + goto err; 826 832 827 833 if (pdata->parts) 828 834 ret = mtd_device_parse_register(&info->mtd, NULL, NULL, ··· 835 841 NULL, 0); 836 842 } 837 843 if (ret < 0) 838 - goto err_scan; 844 + goto err; 839 845 840 846 val = davinci_nand_readl(info, NRCSR_OFFSET); 841 847 dev_info(&pdev->dev, "controller rev. %d.%d\n", ··· 843 849 844 850 return 0; 845 851 846 - err_scan: 847 - err_timing: 852 + err: 848 853 clk_disable_unprepare(info->clk); 849 854 850 855 err_clk_enable: ··· 851 858 if (ecc_mode == NAND_ECC_HW_SYNDROME) 852 859 ecc4_busy = false; 853 860 spin_unlock_irq(&davinci_nand_lock); 854 - 855 - err_ecc: 856 - err_clk: 857 - err_ioremap: 858 - err_nomem: 859 861 return ret; 860 862 } 861 863