linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: davinci_nand: Use managed resources
@ 2013-02-07 10:33 Mrugesh Katepallewar
  2013-02-13 13:13 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Mrugesh Katepallewar @ 2013-02-07 10:33 UTC (permalink / raw)
  To: linux-mtd, linux-kernel, davinci-linux-open-source
  Cc: dwmw2, artem.bityutskiy, m-karicheri2, mturquette, nsekhar

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>
---
Apply on top of v3.8-rc6 of linus tree.

:100644 100644 3502606... e7d5bd6... M	drivers/mtd/nand/davinci_nand.c
 drivers/mtd/nand/davinci_nand.c |   24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 3502606..e7d5bd6 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)
 	if (pdev->id < 0 || pdev->id > 3)
 		return -ENODEV;
 
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info) {
 		dev_err(&pdev->dev, "unable to allocate memory\n");
 		ret = -ENOMEM;
@@ -623,11 +623,11 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
 		goto err_nomem;
 	}
 
-	vaddr = ioremap(res1->start, resource_size(res1));
-	base = ioremap(res2->start, resource_size(res2));
+	vaddr = devm_request_and_ioremap(&pdev->dev, res1);
+	base = devm_request_and_ioremap(&pdev->dev, res2);
 	if (!vaddr || !base) {
 		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -EINVAL;
+		ret = -EADDRNOTAVAIL;
 		goto err_ioremap;
 	}
 
@@ -717,7 +717,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
 	}
 	info->chip.ecc.mode = ecc_mode;
 
-	info->clk = clk_get(&pdev->dev, "aemif");
+	info->clk = devm_clk_get(&pdev->dev, "aemif");
 	if (IS_ERR(info->clk)) {
 		ret = PTR_ERR(info->clk);
 		dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
@@ -845,8 +845,6 @@ err_timing:
 	clk_disable_unprepare(info->clk);
 
 err_clk_enable:
-	clk_put(info->clk);
-
 	spin_lock_irq(&davinci_nand_lock);
 	if (ecc_mode == NAND_ECC_HW_SYNDROME)
 		ecc4_busy = false;
@@ -855,13 +853,7 @@ err_clk_enable:
 err_ecc:
 err_clk:
 err_ioremap:
-	if (base)
-		iounmap(base);
-	if (vaddr)
-		iounmap(vaddr);
-
 err_nomem:
-	kfree(info);
 	return ret;
 }
 
@@ -874,15 +866,9 @@ static int __exit nand_davinci_remove(struct platform_device *pdev)
 		ecc4_busy = false;
 	spin_unlock_irq(&davinci_nand_lock);
 
-	iounmap(info->base);
-	iounmap(info->vaddr);
-
 	nand_release(&info->mtd);
 
 	clk_disable_unprepare(info->clk);
-	clk_put(info->clk);
-
-	kfree(info);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: davinci_nand: Use managed resources
  2013-02-07 10:33 [PATCH] mtd: davinci_nand: Use managed resources Mrugesh Katepallewar
@ 2013-02-13 13:13 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2013-02-13 13:13 UTC (permalink / raw)
  To: Mrugesh Katepallewar
  Cc: linux-mtd, linux-kernel, davinci-linux-open-source, dwmw2,
	m-karicheri2, mturquette, nsekhar

On Thu, 2013-02-07 at 16:03 +0530, Mrugesh Katepallewar wrote:
> 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>

Pushed to l2-mtd.git, thanks!

P.S. you could also kill the unneeded duplicated labels, but this is not
a big deal.

-- 
Best Regards,
Artem Bityutskiy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-13 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 10:33 [PATCH] mtd: davinci_nand: Use managed resources Mrugesh Katepallewar
2013-02-13 13:13 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).