From patchwork Tue Jun 14 15:07:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9176109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0FAB60868 for ; Tue, 14 Jun 2016 15:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3C08265B9 for ; Tue, 14 Jun 2016 15:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B837D27DF9; Tue, 14 Jun 2016 15:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96030265B9 for ; Tue, 14 Jun 2016 15:10:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCpx6-0003zR-AJ; Tue, 14 Jun 2016 15:08:28 +0000 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCpwn-0003ig-7O for linux-arm-kernel@lists.infradead.org; Tue, 14 Jun 2016 15:08:10 +0000 Received: by mail-lf0-x22a.google.com with SMTP id q132so68628684lfe.3 for ; Tue, 14 Jun 2016 08:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iX7BU4KISf/O8fUCFF10+Ug/IjOb+Yt/RNwhSrNmuJM=; b=IXQ833Z0BNFyk7Y00af/K/8rvTna8OT/hsTpz0Y1c4cSenmxO0SHFoSI2dhYvrFluN lxio34G0gpluP08Nb/+Dlv3pdBTqiBWag/NqWuncflqBMGtAkm41kGHINrS7M8/r3Aki woxB4Nx33DNyYjcBPIkPCCmB3HJz2qOWOQ1YM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iX7BU4KISf/O8fUCFF10+Ug/IjOb+Yt/RNwhSrNmuJM=; b=RKj4TWI0seTV6I3dyqAKGkMVNbr8MMeZJCpb1F/3BQDQWe0dmNc1diYBVal04YNgZy zLFi8QCe3vKssqPhcf3UFzd+kJcZ953eikAMuyu5o5WWcMAlXlTUmWXKv9Lr31L9WZIr Pbg8aDW9V4tIhudynDp4pUMgOKiPM8ZoSuJzihe+VtXCxFHZjWZ6xDOqyqJMPFaZ7Plb gjR/17P7jH6jAJFYCpVzugd955jTNUOlD3NE/Ub/piybeWfHnHG6cLx/9nGvwIrFlkbn T8oAZj9flrfWN8UHxDB2BOXu2z6m3VlUmEF/pIhaU4G/Hxcl3cPGjGo0dOSAsbJkqyuM n3lA== X-Gm-Message-State: ALyK8tLS/RuEHJJTosdFj2Zdq+as0PRQwiznVs2ofZcMI0RdmTeAcVQ6slkZkuEglVO5DFhh X-Received: by 10.25.160.205 with SMTP id j196mr2126242lfe.47.1465916867125; Tue, 14 Jun 2016 08:07:47 -0700 (PDT) Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id f195sm3477060lfb.47.2016.06.14.08.07.45 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 08:07:45 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , linux-i2c@vger.kernel.org Subject: [PATCH 02/10] i2c: designware-platdrv: Gate clk in error path in ->probe() Date: Tue, 14 Jun 2016 17:07:20 +0200 Message-Id: <1465916848-8207-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> References: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160614_080809_590807_E11D6B3C X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Guodong Xu , John Stultz , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The call to i2c_dw_probe() may fail in ->probe() in which case the clock remains ungated. Fix the error path by gating the clock before the error code is returned. Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index e39962b..19174e7 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -235,6 +235,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); adap->dev.of_node = pdev->dev.of_node; + pm_runtime_get_noresume(&pdev->dev); if (dev->pm_runtime_disabled) { pm_runtime_forbid(&pdev->dev); } else { @@ -245,8 +246,13 @@ 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 (!IS_ERR(dev->clk)) + clk_disable_unprepare(dev->clk); + if (!dev->pm_runtime_disabled) + pm_runtime_disable(&pdev->dev); + } + pm_runtime_put(&pdev->dev); return r; }