linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] I2C: OMAP: fix runtime PM get/put balance on error
@ 2012-06-29  9:07 Shubhrajyoti D
  2012-06-29 12:02 ` Kevin Hilman
  0 siblings, 1 reply; 4+ messages in thread
From: Shubhrajyoti D @ 2012-06-29  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

    ensure pm_runtime_put() is called, on pm_runtime_get_sync()
    failure.

    Without this, after a failed call, the runtime PM usecount will have
    been incremented, but not decremented causing the usecount to never
    reach zero after a failure. Thanks to Kevin for educating about it. 
    While at it also fix a missing pm_runtime_disable in the probe error
    path.

Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 2500f19..c8e5c76 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1113,10 +1113,10 @@ err_free_irq:
 	free_irq(dev->irq, dev);
 err_unuse_clocks:
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
+err_free_mem:
 	pm_runtime_put(dev->dev);
 	iounmap(dev->base);
 	pm_runtime_disable(&pdev->dev);
-err_free_mem:
 	platform_set_drvdata(pdev, NULL);
 	kfree(dev);
 err_release_region:
@@ -1136,10 +1136,9 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev)
 	free_irq(dev->irq, dev);
 	i2c_del_adapter(&dev->adapter);
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (IS_ERR_VALUE(ret))
-		return ret;
+	if (!IS_ERR_VALUE(ret))
+		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 
-	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	iounmap(dev->base);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-29 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-29  9:07 [PATCH] I2C: OMAP: fix runtime PM get/put balance on error Shubhrajyoti D
2012-06-29 12:02 ` Kevin Hilman
2012-06-29 12:55   ` Shubhrajyoti
2012-06-29 14:00     ` Kevin Hilman

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).