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

mtd: davinci_nand: Use managed resources

davinci_nand driver currently uses normal kzalloc, ioremap and get_clk
routines. This patch replaces these routines with devm_kzalloc,
devm_request_and_ioremap and devm_clk_get resp.

Signed-off-by: Mrugesh Katepallewar <mrugesh.mk@ti.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

authored by

Mrugesh Katepallewar and committed by
Artem Bityutskiy
ef4e0c21 221b1bd3

+5 -19
+5 -19
drivers/mtd/nand/davinci_nand.c
··· 606 606 if (pdev->id < 0 || pdev->id > 3) 607 607 return -ENODEV; 608 608 609 - info = kzalloc(sizeof(*info), GFP_KERNEL); 609 + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 610 610 if (!info) { 611 611 dev_err(&pdev->dev, "unable to allocate memory\n"); 612 612 ret = -ENOMEM; ··· 623 623 goto err_nomem; 624 624 } 625 625 626 - vaddr = ioremap(res1->start, resource_size(res1)); 627 - base = ioremap(res2->start, resource_size(res2)); 626 + vaddr = devm_request_and_ioremap(&pdev->dev, res1); 627 + base = devm_request_and_ioremap(&pdev->dev, res2); 628 628 if (!vaddr || !base) { 629 629 dev_err(&pdev->dev, "ioremap failed\n"); 630 - ret = -EINVAL; 630 + ret = -EADDRNOTAVAIL; 631 631 goto err_ioremap; 632 632 } 633 633 ··· 717 717 } 718 718 info->chip.ecc.mode = ecc_mode; 719 719 720 - info->clk = clk_get(&pdev->dev, "aemif"); 720 + info->clk = devm_clk_get(&pdev->dev, "aemif"); 721 721 if (IS_ERR(info->clk)) { 722 722 ret = PTR_ERR(info->clk); 723 723 dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); ··· 845 845 clk_disable_unprepare(info->clk); 846 846 847 847 err_clk_enable: 848 - clk_put(info->clk); 849 - 850 848 spin_lock_irq(&davinci_nand_lock); 851 849 if (ecc_mode == NAND_ECC_HW_SYNDROME) 852 850 ecc4_busy = false; ··· 853 855 err_ecc: 854 856 err_clk: 855 857 err_ioremap: 856 - if (base) 857 - iounmap(base); 858 - if (vaddr) 859 - iounmap(vaddr); 860 - 861 858 err_nomem: 862 - kfree(info); 863 859 return ret; 864 860 } 865 861 ··· 866 874 ecc4_busy = false; 867 875 spin_unlock_irq(&davinci_nand_lock); 868 876 869 - iounmap(info->base); 870 - iounmap(info->vaddr); 871 - 872 877 nand_release(&info->mtd); 873 878 874 879 clk_disable_unprepare(info->clk); 875 - clk_put(info->clk); 876 - 877 - kfree(info); 878 880 879 881 return 0; 880 882 }