linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] pwm: pwm-mxs: use devm_* managed functions
Date: Tue, 26 Jun 2012 16:58:10 +0800	[thread overview]
Message-ID: <1340701091-8488-4-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1340701091-8488-1-git-send-email-shawn.guo@linaro.org>

Use devm_* managed functions to have a clean fail-out.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/pwm-mxs.c |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index 7a97997..bbda509 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -129,21 +129,21 @@ static int mxs_pwm_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct mxs_pwm_chip *mxs;
+	struct resource *res;
 	int ret;
 
 	mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL);
 	if (!mxs)
 		return -ENOMEM;
 
-	mxs->base = of_iomap(np, 0);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	mxs->base = devm_request_and_ioremap(&pdev->dev, res);
 	if (!mxs->base)
 		return -EADDRNOTAVAIL;
 
-	mxs->clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR(mxs->clk)) {
-		ret = PTR_ERR(mxs->clk);
-		goto iounmap;
-	}
+	mxs->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(mxs->clk))
+		return PTR_ERR(mxs->clk);
 
 	mxs->chip.dev = &pdev->dev;
 	mxs->chip.ops = &mxs_pwm_ops;
@@ -151,13 +151,13 @@ static int mxs_pwm_probe(struct platform_device *pdev)
 	ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret);
-		goto clk_put;
+		return ret;
 	}
 
 	ret = pwmchip_add(&mxs->chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret);
-		goto clk_put;
+		return ret;
 	}
 
 	mxs->dev = &pdev->dev;
@@ -166,12 +166,6 @@ static int mxs_pwm_probe(struct platform_device *pdev)
 	stmp_reset_block(mxs->base);
 
 	return 0;
-
-clk_put:
-	clk_put(mxs->clk);
-iounmap:
-	iounmap(mxs->base);
-	return ret;
 }
 
 static int __devexit mxs_pwm_remove(struct platform_device *pdev)
@@ -179,8 +173,6 @@ static int __devexit mxs_pwm_remove(struct platform_device *pdev)
 	struct mxs_pwm_chip *mxs = platform_get_drvdata(pdev);
 
 	pwmchip_remove(&mxs->chip);
-	clk_put(mxs->clk);
-	iounmap(mxs->base);
 
 	return 0;
 }
-- 
1.7.5.4

  parent reply	other threads:[~2012-06-26  8:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26  8:58 [PATCH 0/4] pwm-mxs driver updates Shawn Guo
2012-06-26  8:58 ` [PATCH 1/4] pwm: pwm-mxs: encode soc name in compatible string Shawn Guo
2012-06-26  8:58 ` [PATCH 2/4] pwm: pwm-mxs: use global reset function stmp_reset_block Shawn Guo
2012-06-26  9:54   ` Thierry Reding
2012-06-26  9:57     ` Thierry Reding
2012-06-26 11:14       ` Shawn Guo
2012-06-27 13:36   ` [PATCH v2 " Shawn Guo
2012-06-27 13:39     ` Thierry Reding
2012-06-26  8:58 ` Shawn Guo [this message]
2012-06-26  8:58 ` [PATCH 4/4] pwm: pwm-mxs: add pinctrl support Shawn Guo

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=1340701091-8488-4-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).