Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
i2c: imx: call ioremap only after request_mem_region
Browse files Browse the repository at this point in the history
accordingly adapt order of release_mem_region and release_mem_region on
remove.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Wolfram Sang <[email protected]>
Cc: Richard Zhao <[email protected]>
Cc: Darius Augulis <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: [email protected]
Acked-by: Wolfram Sang <[email protected]>
Signed-off-by: Ben Dooks <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and Ben Dooks committed Jan 24, 2010
1 parent a1ee06b commit 4927fbf
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions drivers/i2c/busses/i2c-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,22 +497,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;
}

Expand Down Expand Up @@ -583,11 +584,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
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);
Expand Down Expand Up @@ -619,8 +620,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;
}
Expand Down

0 comments on commit 4927fbf

Please sign in to comment.