diff options
author | Mrugesh Katepallewar <mrugesh.mk@ti.com> | 2013-02-07 05:33:15 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-02-13 08:14:02 -0500 |
commit | ef4e0c2145e928b1c165ac88a9aa20038a981488 (patch) | |
tree | 8958e9820873036a93ae68118fdbe02146e21e30 /drivers/mtd/nand/davinci_nand.c | |
parent | 221b1bd3d409b14e8764d8f40994b71ae6887d18 (diff) |
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>
Diffstat (limited to 'drivers/mtd/nand/davinci_nand.c')
-rw-r--r-- | drivers/mtd/nand/davinci_nand.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c index feae55c7b880..94e17af8e450 100644 --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c | |||
@@ -606,7 +606,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev) | |||
606 | if (pdev->id < 0 || pdev->id > 3) | 606 | if (pdev->id < 0 || pdev->id > 3) |
607 | return -ENODEV; | 607 | return -ENODEV; |
608 | 608 | ||
609 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 609 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
610 | if (!info) { | 610 | if (!info) { |
611 | dev_err(&pdev->dev, "unable to allocate memory\n"); | 611 | dev_err(&pdev->dev, "unable to allocate memory\n"); |
612 | ret = -ENOMEM; | 612 | ret = -ENOMEM; |
@@ -623,11 +623,11 @@ static int __init nand_davinci_probe(struct platform_device *pdev) | |||
623 | goto err_nomem; | 623 | goto err_nomem; |
624 | } | 624 | } |
625 | 625 | ||
626 | vaddr = ioremap(res1->start, resource_size(res1)); | 626 | vaddr = devm_request_and_ioremap(&pdev->dev, res1); |
627 | base = ioremap(res2->start, resource_size(res2)); | 627 | base = devm_request_and_ioremap(&pdev->dev, res2); |
628 | if (!vaddr || !base) { | 628 | if (!vaddr || !base) { |
629 | dev_err(&pdev->dev, "ioremap failed\n"); | 629 | dev_err(&pdev->dev, "ioremap failed\n"); |
630 | ret = -EINVAL; | 630 | ret = -EADDRNOTAVAIL; |
631 | goto err_ioremap; | 631 | goto err_ioremap; |
632 | } | 632 | } |
633 | 633 | ||
@@ -717,7 +717,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev) | |||
717 | } | 717 | } |
718 | info->chip.ecc.mode = ecc_mode; | 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 | if (IS_ERR(info->clk)) { | 721 | if (IS_ERR(info->clk)) { |
722 | ret = PTR_ERR(info->clk); | 722 | ret = PTR_ERR(info->clk); |
723 | dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); | 723 | dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); |
@@ -845,8 +845,6 @@ err_timing: | |||
845 | clk_disable_unprepare(info->clk); | 845 | clk_disable_unprepare(info->clk); |
846 | 846 | ||
847 | err_clk_enable: | 847 | err_clk_enable: |
848 | clk_put(info->clk); | ||
849 | |||
850 | spin_lock_irq(&davinci_nand_lock); | 848 | spin_lock_irq(&davinci_nand_lock); |
851 | if (ecc_mode == NAND_ECC_HW_SYNDROME) | 849 | if (ecc_mode == NAND_ECC_HW_SYNDROME) |
852 | ecc4_busy = false; | 850 | ecc4_busy = false; |
@@ -855,13 +853,7 @@ err_clk_enable: | |||
855 | err_ecc: | 853 | err_ecc: |
856 | err_clk: | 854 | err_clk: |
857 | err_ioremap: | 855 | err_ioremap: |
858 | if (base) | ||
859 | iounmap(base); | ||
860 | if (vaddr) | ||
861 | iounmap(vaddr); | ||
862 | |||
863 | err_nomem: | 856 | err_nomem: |
864 | kfree(info); | ||
865 | return ret; | 857 | return ret; |
866 | } | 858 | } |
867 | 859 | ||
@@ -874,15 +866,9 @@ static int __exit nand_davinci_remove(struct platform_device *pdev) | |||
874 | ecc4_busy = false; | 866 | ecc4_busy = false; |
875 | spin_unlock_irq(&davinci_nand_lock); | 867 | spin_unlock_irq(&davinci_nand_lock); |
876 | 868 | ||
877 | iounmap(info->base); | ||
878 | iounmap(info->vaddr); | ||
879 | |||
880 | nand_release(&info->mtd); | 869 | nand_release(&info->mtd); |
881 | 870 | ||
882 | clk_disable_unprepare(info->clk); | 871 | clk_disable_unprepare(info->clk); |
883 | clk_put(info->clk); | ||
884 | |||
885 | kfree(info); | ||
886 | 872 | ||
887 | return 0; | 873 | return 0; |
888 | } | 874 | } |