From patchwork Fri Jun 29 09:07:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 1130951 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 553B2DFF34 for ; Fri, 29 Jun 2012 09:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752999Ab2F2JIT (ORCPT ); Fri, 29 Jun 2012 05:08:19 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:41924 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752882Ab2F2JIS (ORCPT ); Fri, 29 Jun 2012 05:08:18 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q5T97v15004661; Fri, 29 Jun 2012 04:07:58 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q5T97u43001027; Fri, 29 Jun 2012 14:37:56 +0530 (IST) Received: from dbdp33.itg.ti.com (172.24.170.252) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Fri, 29 Jun 2012 14:37:56 +0530 Received: from ula0393217.india.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp33.itg.ti.com (8.13.8/8.13.8) with ESMTP id q5T97oVI028002; Fri, 29 Jun 2012 14:37:52 +0530 From: Shubhrajyoti D To: CC: , , , , , Shubhrajyoti D , Kevin Hilman Subject: [PATCH] I2C: OMAP: fix runtime PM get/put balance on error Date: Fri, 29 Jun 2012 14:37:48 +0530 Message-ID: <1340960868-7371-1-git-send-email-shubhrajyoti@ti.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 Signed-off-by: Shubhrajyoti D --- 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);