diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-imx.c')
-rw-r--r-- | drivers/i2c/busses/i2c-imx.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index e3654d683e15..75bf820e7ccb 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -226,7 +226,6 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) | |||
226 | temp = readb(i2c_imx->base + IMX_I2C_I2CR); | 226 | temp = readb(i2c_imx->base + IMX_I2C_I2CR); |
227 | temp &= ~(I2CR_MSTA | I2CR_MTX); | 227 | temp &= ~(I2CR_MSTA | I2CR_MTX); |
228 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); | 228 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); |
229 | i2c_imx->stopped = 1; | ||
230 | } | 229 | } |
231 | if (cpu_is_mx1()) { | 230 | if (cpu_is_mx1()) { |
232 | /* | 231 | /* |
@@ -236,8 +235,10 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) | |||
236 | udelay(i2c_imx->disable_delay); | 235 | udelay(i2c_imx->disable_delay); |
237 | } | 236 | } |
238 | 237 | ||
239 | if (!i2c_imx->stopped) | 238 | if (!i2c_imx->stopped) { |
240 | i2c_imx_bus_busy(i2c_imx, 0); | 239 | i2c_imx_bus_busy(i2c_imx, 0); |
240 | i2c_imx->stopped = 1; | ||
241 | } | ||
241 | 242 | ||
242 | /* Disable I2C controller */ | 243 | /* Disable I2C controller */ |
243 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); | 244 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); |
@@ -496,22 +497,23 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
496 | } | 497 | } |
497 | 498 | ||
498 | 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 | |||
499 | base = ioremap(res->start, res_size); | 506 | base = ioremap(res->start, res_size); |
500 | if (!base) { | 507 | if (!base) { |
501 | dev_err(&pdev->dev, "ioremap failed\n"); | 508 | dev_err(&pdev->dev, "ioremap failed\n"); |
502 | ret = -EIO; | 509 | ret = -EIO; |
503 | goto fail0; | 510 | goto fail1; |
504 | } | 511 | } |
505 | 512 | ||
506 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); | 513 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); |
507 | if (!i2c_imx) { | 514 | if (!i2c_imx) { |
508 | dev_err(&pdev->dev, "can't allocate interface\n"); | 515 | dev_err(&pdev->dev, "can't allocate interface\n"); |
509 | ret = -ENOMEM; | 516 | ret = -ENOMEM; |
510 | goto fail1; | ||
511 | } | ||
512 | |||
513 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
514 | ret = -EBUSY; | ||
515 | goto fail2; | 517 | goto fail2; |
516 | } | 518 | } |
517 | 519 | ||
@@ -582,11 +584,11 @@ fail5: | |||
582 | fail4: | 584 | fail4: |
583 | clk_put(i2c_imx->clk); | 585 | clk_put(i2c_imx->clk); |
584 | fail3: | 586 | fail3: |
585 | release_mem_region(i2c_imx->res->start, resource_size(res)); | ||
586 | fail2: | ||
587 | kfree(i2c_imx); | 587 | kfree(i2c_imx); |
588 | fail1: | 588 | fail2: |
589 | iounmap(base); | 589 | iounmap(base); |
590 | fail1: | ||
591 | release_mem_region(res->start, resource_size(res)); | ||
590 | fail0: | 592 | fail0: |
591 | if (pdata && pdata->exit) | 593 | if (pdata && pdata->exit) |
592 | pdata->exit(&pdev->dev); | 594 | pdata->exit(&pdev->dev); |
@@ -618,8 +620,8 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) | |||
618 | 620 | ||
619 | clk_put(i2c_imx->clk); | 621 | clk_put(i2c_imx->clk); |
620 | 622 | ||
621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
622 | iounmap(i2c_imx->base); | 623 | iounmap(i2c_imx->base); |
624 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
623 | kfree(i2c_imx); | 625 | kfree(i2c_imx); |
624 | return 0; | 626 | return 0; |
625 | } | 627 | } |