Skip to content

Commit ef4e0c2

Browse files
Mrugesh Katepallewardedekind
authored andcommitted
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>
1 parent 221b1bd commit ef4e0c2

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

‎drivers/mtd/nand/davinci_nand.c‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
606606
if (pdev->id < 0 || pdev->id > 3)
607607
return -ENODEV;
608608

609-
info = kzalloc(sizeof(*info), GFP_KERNEL);
609+
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
610610
if (!info) {
611611
dev_err(&pdev->dev, "unable to allocate memory\n");
612612
ret = -ENOMEM;
@@ -623,11 +623,11 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
623623
goto err_nomem;
624624
}
625625

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);
628628
if (!vaddr || !base) {
629629
dev_err(&pdev->dev, "ioremap failed\n");
630-
ret = -EINVAL;
630+
ret = -EADDRNOTAVAIL;
631631
goto err_ioremap;
632632
}
633633

@@ -717,7 +717,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
717717
}
718718
info->chip.ecc.mode = ecc_mode;
719719

720-
info->clk = clk_get(&pdev->dev, "aemif");
720+
info->clk = devm_clk_get(&pdev->dev, "aemif");
721721
if (IS_ERR(info->clk)) {
722722
ret = PTR_ERR(info->clk);
723723
dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
@@ -845,8 +845,6 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
845845
clk_disable_unprepare(info->clk);
846846

847847
err_clk_enable:
848-
clk_put(info->clk);
849-
850848
spin_lock_irq(&davinci_nand_lock);
851849
if (ecc_mode == NAND_ECC_HW_SYNDROME)
852850
ecc4_busy = false;
@@ -855,13 +853,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
855853
err_ecc:
856854
err_clk:
857855
err_ioremap:
858-
if (base)
859-
iounmap(base);
860-
if (vaddr)
861-
iounmap(vaddr);
862-
863856
err_nomem:
864-
kfree(info);
865857
return ret;
866858
}
867859

@@ -874,15 +866,9 @@ static int __exit nand_davinci_remove(struct platform_device *pdev)
874866
ecc4_busy = false;
875867
spin_unlock_irq(&davinci_nand_lock);
876868

877-
iounmap(info->base);
878-
iounmap(info->vaddr);
879-
880869
nand_release(&info->mtd);
881870

882871
clk_disable_unprepare(info->clk);
883-
clk_put(info->clk);
884-
885-
kfree(info);
886872

887873
return 0;
888874
}

0 commit comments

Comments
 (0)