From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 4/4] watchdog: imx2: simplify resource allocation
Date: Mon, 24 Oct 2011 13:56:49 +0200 [thread overview]
Message-ID: <20111024115649.GM8708@ponder.secretlab.ca> (raw)
In-Reply-To: <1319445729-14841-5-git-send-email-w.sang@pengutronix.de>
On Mon, Oct 24, 2011 at 10:42:09AM +0200, Wolfram Sang wrote:
> Use the new devm_resource_to_mapped_ptr function to simplify the code
> and standardize the error-handling. Silently fixes a wrong type for the
> resource_size variable as well.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
> drivers/watchdog/imx2_wdt.c | 22 +++-------------------
> 1 files changed, 3 insertions(+), 19 deletions(-)
w00t! I can see a lot of drivers simplified by using this.
g.
>
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index b8ef2c6..1fc6714 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -247,28 +247,12 @@ static struct miscdevice imx2_wdt_miscdev = {
> static int __init imx2_wdt_probe(struct platform_device *pdev)
> {
> int ret;
> - int res_size;
> struct resource *res;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res) {
> - dev_err(&pdev->dev, "can't get device resources\n");
> - return -ENODEV;
> - }
> -
> - res_size = resource_size(res);
> - if (!devm_request_mem_region(&pdev->dev, res->start, res_size,
> - res->name)) {
> - dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
> - res_size, res->start);
> - return -ENOMEM;
> - }
> -
> - imx2_wdt.base = devm_ioremap_nocache(&pdev->dev, res->start, res_size);
> - if (!imx2_wdt.base) {
> - dev_err(&pdev->dev, "ioremap failed\n");
> - return -ENOMEM;
> - }
> + ret = devm_resource_to_mapped_ptr(&pdev->dev, res, &imx2_wdt.base);
> + if (ret)
> + return ret;
>
> imx2_wdt.clk = clk_get(&pdev->dev, NULL);
> if (IS_ERR(imx2_wdt.clk)) {
> --
> 1.7.6.3
>
next prev parent reply other threads:[~2011-10-24 11:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 8:42 [RFC 0/4] simplify remapping a resource for drivers Wolfram Sang
[not found] ` <1319445729-14841-5-git-send-email-w.sang@pengutronix.de>
2011-10-24 11:56 ` Grant Likely [this message]
[not found] ` <1319445729-14841-2-git-send-email-w.sang@pengutronix.de>
2011-10-24 15:25 ` [RFC 1/4] Documentation: devres: add allocation functions to list of supported calls Tejun Heo
[not found] ` <1319445729-14841-4-git-send-email-w.sang@pengutronix.de>
2011-10-24 11:56 ` [RFC 3/4] lib: devres: add convenience function to remap a resource Grant Likely
2011-10-24 15:44 ` Tejun Heo
2011-10-24 15:43 ` Tejun Heo
2011-10-24 20:09 ` Wolfram Sang
2011-10-24 20:19 ` Tejun Heo
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=20111024115649.GM8708@ponder.secretlab.ca \
--to=grant.likely@secretlab.ca \
--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).