Commit ef4e0c2145e928b1c165ac88a9aa20038a981488

Authored by Mrugesh Katepallewar
Committed by Artem Bityutskiy
1 parent 221b1bd3d4

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>

Showing 1 changed file with 5 additions and 19 deletions Side-by-side Diff

drivers/mtd/nand/davinci_nand.c
... ... @@ -606,7 +606,7 @@
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;
613 613  
... ... @@ -623,11 +623,11 @@
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,7 +717,7 @@
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,8 +845,6 @@
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 851  
... ... @@ -855,13 +853,7 @@
855 853 err_ecc:
856 854 err_clk:
857 855 err_ioremap:
858   - if (base)
859   - iounmap(base);
860   - if (vaddr)
861   - iounmap(vaddr);
862   -
863 856 err_nomem:
864   - kfree(info);
865 857 return ret;
866 858 }
867 859  
868 860  
... ... @@ -874,15 +866,9 @@
874 866 ecc4_busy = false;
875 867 spin_unlock_irq(&davinci_nand_lock);
876 868  
877   - iounmap(info->base);
878   - iounmap(info->vaddr);
879   -
880 869 nand_release(&info->mtd);
881 870  
882 871 clk_disable_unprepare(info->clk);
883   - clk_put(info->clk);
884   -
885   - kfree(info);
886 872  
887 873 return 0;
888 874 }