[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1262967797-2001-1-git-send-email-u.kleine-koenig@pengutronix.de>
Date: Fri, 8 Jan 2010 17:23:17 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: linux-kernel@...r.kernel.org
Cc: Ben Dooks <ben-linux@...ff.org>,
Wolfram Sang <w.sang@...gutronix.de>,
Richard Zhao <linuxzsc@...il.com>,
Darius Augulis <augulis.darius@...il.com>,
Sascha Hauer <s.hauer@...gutronix.de>,
linux-i2c@...r.kernel.org
Subject: [PATCH] i2c/imx: call ioremap only after request_mem_region
accordingly adapt order of release_mem_region and release_mem_region on
remove.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Cc: Ben Dooks <ben-linux@...ff.org>
Cc: Wolfram Sang <w.sang@...gutronix.de>
Cc: Richard Zhao <linuxzsc@...il.com>
Cc: Darius Augulis <augulis.darius@...il.com>
Cc: Sascha Hauer <s.hauer@...gutronix.de>
Cc: linux-i2c@...r.kernel.org
---
drivers/i2c/busses/i2c-imx.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index e3654d6..8431500 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -496,22 +496,23 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
}
res_size = resource_size(res);
+
+ if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
+ ret = -EBUSY;
+ goto fail0;
+ }
+
base = ioremap(res->start, res_size);
if (!base) {
dev_err(&pdev->dev, "ioremap failed\n");
ret = -EIO;
- goto fail0;
+ goto fail1;
}
i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL);
if (!i2c_imx) {
dev_err(&pdev->dev, "can't allocate interface\n");
ret = -ENOMEM;
- goto fail1;
- }
-
- if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
- ret = -EBUSY;
goto fail2;
}
@@ -582,11 +583,11 @@ fail5:
fail4:
clk_put(i2c_imx->clk);
fail3:
- release_mem_region(i2c_imx->res->start, resource_size(res));
-fail2:
kfree(i2c_imx);
-fail1:
+fail2:
iounmap(base);
+fail1:
+ release_mem_region(res->start, resource_size(res));
fail0:
if (pdata && pdata->exit)
pdata->exit(&pdev->dev);
@@ -618,8 +619,8 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
clk_put(i2c_imx->clk);
- release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res));
iounmap(i2c_imx->base);
+ release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res));
kfree(i2c_imx);
return 0;
}
--
1.6.5.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists