From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-mmc@vger.kernel.org
Cc: linux-sh@vger.kernel.org,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Chris Ball <chris@printf.net>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
magnus.damm@opensource.se, linux-kernel@lists.codethink.co.uk,
Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH v2 2/6] mmc: sh-mmcif: use devm_ for ioremap
Date: Tue, 01 Apr 2014 12:01:42 +0000 [thread overview]
Message-ID: <1396353706-31864-3-git-send-email-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <1396353706-31864-1-git-send-email-ben.dooks@codethink.co.uk>
Start tidying the probe/release code by using devm_ioremap_resource() to
map the IO registers.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Fixes from v1:
- return the PTR_ERR() from devm_ioremap
- remove error print as it already shows an error
---
drivers/mmc/host/sh_mmcif.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 738b155..bb8e4e6 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1379,22 +1379,15 @@ static int sh_mmcif_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Get irq error\n");
return -ENXIO;
}
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "platform_get_resource error.\n");
- return -ENXIO;
- }
- reg = ioremap(res->start, resource_size(res));
- if (!reg) {
- dev_err(&pdev->dev, "ioremap error.\n");
- return -ENOMEM;
- }
+ reg = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(reg))
+ return PTR_ERR(reg);
mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), &pdev->dev);
- if (!mmc) {
- ret = -ENOMEM;
- goto ealloch;
- }
+ if (!mmc)
+ return -ENOMEM;
ret = mmc_of_parse(mmc);
if (ret < 0)
@@ -1499,8 +1492,6 @@ eclkget:
pm_runtime_disable(&pdev->dev);
eofparse:
mmc_free_host(mmc);
-ealloch:
- iounmap(reg);
return ret;
}
@@ -1525,9 +1516,6 @@ static int sh_mmcif_remove(struct platform_device *pdev)
*/
cancel_delayed_work_sync(&host->timeout_work);
- if (host->addr)
- iounmap(host->addr);
-
irq[0] = platform_get_irq(pdev, 0);
irq[1] = platform_get_irq(pdev, 1);
--
1.9.0
next prev parent reply other threads:[~2014-04-01 12:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 12:01 sh mmcif cleanups Ben Dooks
2014-04-01 12:01 ` [PATCH v2 1/6] mmc: sh-mmcif: update to print version and bus clock rate on probe Ben Dooks
2014-04-01 12:01 ` Ben Dooks [this message]
2014-04-01 12:01 ` [PATCH v2 3/6] mmc: sh-mmcif: use devm_ for clock management Ben Dooks
2014-04-01 12:01 ` [PATCH v2 4/6] mmc: sh-mmcif: use devm_ for irq management Ben Dooks
2014-04-01 12:01 ` [PATCH v2 5/6] mmc: sh-mmcif: no need to call pm_runtime_suspend on error Ben Dooks
2014-04-01 12:01 ` [PATCH v2 6/6] mmc: sh-mmcif: final error path cleanup Ben Dooks
2014-04-01 12:45 ` sh mmcif cleanups Laurent Pinchart
2014-04-01 21:13 ` Ben Dooks
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=1396353706-31864-3-git-send-email-ben.dooks@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=chris@printf.net \
--cc=g.liakhovetski@gmx.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@lists.codethink.co.uk \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@opensource.se \
--cc=ulf.hansson@linaro.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).