From patchwork Thu Apr 21 09:26:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 613031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qrD5Z3Vbxz9t3c for ; Thu, 21 Apr 2016 19:31:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750989AbcDUJbM (ORCPT ); Thu, 21 Apr 2016 05:31:12 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:8266 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbcDUJbL (ORCPT ); Thu, 21 Apr 2016 05:31:11 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u3L9QOuU016908; Thu, 21 Apr 2016 02:30:42 -0700 Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 22bmwffh9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 21 Apr 2016 02:30:42 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Thu, 21 Apr 2016 02:30:40 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1104.5 via Frontend Transport; Thu, 21 Apr 2016 02:30:40 -0700 Received: from xhacker.marvell.com (unknown [10.37.130.132]) by maili.marvell.com (Postfix) with ESMTP id AECAD3F703F; Thu, 21 Apr 2016 02:30:39 -0700 (PDT) From: Jisheng Zhang To: , , , CC: , , , Jisheng Zhang Subject: [PATCH v2] i2c: designware-platdrv: fix unbalanced clk enable and prepare Date: Thu, 21 Apr 2016 17:26:51 +0800 Message-ID: <1461230811-7495-1-git-send-email-jszhang@marvell.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-04-21_06:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1604210153 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If i2c_dw_probe() fail, we should disable and unprepare the clk, otherwise the clk enable and prepare is left unbalanced. In dw_i2c_plat_remove(), we'd better to not rely on rpm to disable and unprepare the clk since CONFIG_PM may be disabled when configuring the kernel. So we explicitly disable and unprepare the clk in dw_i2c_plat_remove(). Signed-off-by: Jisheng Zhang --- Since v1: - fix commit msg: "not rely on rpm" rather than "rely on rpm" - call i2c_dw_plat_prepare_clk after pm_rumtime_disable() drivers/i2c/busses/i2c-designware-platdrv.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index d656657..a771781 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -253,8 +253,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) } r = i2c_dw_probe(dev); - if (r && !dev->pm_runtime_disabled) - pm_runtime_disable(&pdev->dev); + if (r) { + if (!dev->pm_runtime_disabled) + pm_runtime_disable(&pdev->dev); + i2c_dw_plat_prepare_clk(dev, false); + } return r; } @@ -264,15 +267,16 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) struct dw_i2c_dev *dev = platform_get_drvdata(pdev); pm_runtime_get_sync(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); + if (!dev->pm_runtime_disabled) + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); i2c_del_adapter(&dev->adapter); i2c_dw_disable(dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); - pm_runtime_put_sync(&pdev->dev); - if (!dev->pm_runtime_disabled) - pm_runtime_disable(&pdev->dev); + i2c_dw_plat_prepare_clk(dev, false); return 0; }