public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Olof Johansson <olof@lixom.net>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] bus: omap_l3_smx: Use devm_* managed allocators
Date: Tue, 01 Apr 2014 11:46:39 +0800	[thread overview]
Message-ID: <1396323999.15053.2.camel@phoenix> (raw)
In-Reply-To: <1396323961.15053.1.camel@phoenix>

This simplifies error and cleanup code paths.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/bus/omap_l3_smx.c | 53 +++++++++++------------------------------------
 1 file changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/bus/omap_l3_smx.c b/drivers/bus/omap_l3_smx.c
index acc2164..90840cf 100644
--- a/drivers/bus/omap_l3_smx.c
+++ b/drivers/bus/omap_l3_smx.c
@@ -217,68 +217,39 @@ static int __init omap3_l3_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
+	l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
 	if (!l3)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, l3);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "couldn't find resource\n");
-		ret = -ENODEV;
-		goto err0;
-	}
-	l3->rt = ioremap(res->start, resource_size(res));
-	if (!l3->rt) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -ENOMEM;
-		goto err0;
-	}
+	l3->rt = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(l3->rt))
+		return PTR_ERR(l3->rt);
 
 	l3->debug_irq = platform_get_irq(pdev, 0);
-	ret = request_irq(l3->debug_irq, omap3_l3_app_irq,
-		IRQF_DISABLED | IRQF_TRIGGER_RISING,
-		"l3-debug-irq", l3);
+	ret = devm_request_irq(&pdev->dev, l3->debug_irq, omap3_l3_app_irq,
+			       IRQF_DISABLED | IRQF_TRIGGER_RISING,
+			       "l3-debug-irq", l3);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't request debug irq\n");
-		goto err1;
+		return ret;
 	}
 
 	l3->app_irq = platform_get_irq(pdev, 1);
-	ret = request_irq(l3->app_irq, omap3_l3_app_irq,
-		IRQF_DISABLED | IRQF_TRIGGER_RISING,
-		"l3-app-irq", l3);
+	ret = devm_request_irq(&pdev->dev, l3->app_irq, omap3_l3_app_irq,
+			       IRQF_DISABLED | IRQF_TRIGGER_RISING,
+			       "l3-app-irq", l3);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't request app irq\n");
-		goto err2;
+		return ret;
 	}
 
 	return 0;
-
-err2:
-	free_irq(l3->debug_irq, l3);
-err1:
-	iounmap(l3->rt);
-err0:
-	kfree(l3);
-	return ret;
-}
-
-static int __exit omap3_l3_remove(struct platform_device *pdev)
-{
-	struct omap3_l3         *l3 = platform_get_drvdata(pdev);
-
-	free_irq(l3->app_irq, l3);
-	free_irq(l3->debug_irq, l3);
-	iounmap(l3->rt);
-	kfree(l3);
-
-	return 0;
 }
 
 static struct platform_driver omap3_l3_driver = {
-	.remove         = __exit_p(omap3_l3_remove),
 	.driver         = {
 	.name   = "omap_l3_smx",
 	},
-- 
1.8.3.2




      reply	other threads:[~2014-04-01  3:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01  3:46 [PATCH 1/2] bus: omap_l3_noc: Use devm_* managed allocators Axel Lin
2014-04-01  3:46 ` Axel Lin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396323999.15053.2.camel@phoenix \
    --to=axel.lin@ingics.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=olof@lixom.net \
    --cc=santosh.shilimkar@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox