diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-01-08 11:23:17 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-01-24 10:25:57 -0500 |
commit | 4927fbf11dc1057cd9c94dd40358e5f98c999311 (patch) | |
tree | ef929d0d38cc58424865b5a1fe177922ca523397 /drivers | |
parent | a1ee06b72968d80ab9362ec61143c4f090cc2d1b (diff) |
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@pengutronix.de>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Richard Zhao <linuxzsc@gmail.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-i2c@vger.kernel.org
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | 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 602b30e32cf3..75bf820e7ccb 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -497,22 +497,23 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
497 | } | 497 | } |
498 | 498 | ||
499 | res_size = resource_size(res); | 499 | res_size = resource_size(res); |
500 | |||
501 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
502 | ret = -EBUSY; | ||
503 | goto fail0; | ||
504 | } | ||
505 | |||
500 | base = ioremap(res->start, res_size); | 506 | base = ioremap(res->start, res_size); |
501 | if (!base) { | 507 | if (!base) { |
502 | dev_err(&pdev->dev, "ioremap failed\n"); | 508 | dev_err(&pdev->dev, "ioremap failed\n"); |
503 | ret = -EIO; | 509 | ret = -EIO; |
504 | goto fail0; | 510 | goto fail1; |
505 | } | 511 | } |
506 | 512 | ||
507 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); | 513 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); |
508 | if (!i2c_imx) { | 514 | if (!i2c_imx) { |
509 | dev_err(&pdev->dev, "can't allocate interface\n"); | 515 | dev_err(&pdev->dev, "can't allocate interface\n"); |
510 | ret = -ENOMEM; | 516 | ret = -ENOMEM; |
511 | goto fail1; | ||
512 | } | ||
513 | |||
514 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
515 | ret = -EBUSY; | ||
516 | goto fail2; | 517 | goto fail2; |
517 | } | 518 | } |
518 | 519 | ||
@@ -583,11 +584,11 @@ fail5: | |||
583 | fail4: | 584 | fail4: |
584 | clk_put(i2c_imx->clk); | 585 | clk_put(i2c_imx->clk); |
585 | fail3: | 586 | fail3: |
586 | release_mem_region(i2c_imx->res->start, resource_size(res)); | ||
587 | fail2: | ||
588 | kfree(i2c_imx); | 587 | kfree(i2c_imx); |
589 | fail1: | 588 | fail2: |
590 | iounmap(base); | 589 | iounmap(base); |
590 | fail1: | ||
591 | release_mem_region(res->start, resource_size(res)); | ||
591 | fail0: | 592 | fail0: |
592 | if (pdata && pdata->exit) | 593 | if (pdata && pdata->exit) |
593 | pdata->exit(&pdev->dev); | 594 | pdata->exit(&pdev->dev); |
@@ -619,8 +620,8 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) | |||
619 | 620 | ||
620 | clk_put(i2c_imx->clk); | 621 | clk_put(i2c_imx->clk); |
621 | 622 | ||
622 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
623 | iounmap(i2c_imx->base); | 623 | iounmap(i2c_imx->base); |
624 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
624 | kfree(i2c_imx); | 625 | kfree(i2c_imx); |
625 | return 0; | 626 | return 0; |
626 | } | 627 | } |