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: 635353 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 3rTY120JRsz9t12 for ; Wed, 15 Jun 2016 01:07:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=IXQ833Z0; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751221AbcFNPHt (ORCPT ); Tue, 14 Jun 2016 11:07:49 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35862 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbcFNPHs (ORCPT ); Tue, 14 Jun 2016 11:07:48 -0400 Received: by mail-lf0-f50.google.com with SMTP id q132so68628683lfe.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=gWm/kf24AkkkAtHtsa3wukPlsBcLkigoLzXweimDQWPtskD5k4gjgwWfpLoY7NOJp+ v8Nqz8ybdG02+yx6+DtQNM3WOnLL1jPwuyl6i5SIcsd1osyQv1sv9brzsx+JQxWdr8mM DZyuHN7A0A5vc9B9IFrz/fjWT5zWinUfco/jjWxjXy1gp+Lz44yGctfjJdipG11eDnca kSS+ZbM2rkaAL10+KLpbk7DDI8GLMkLpLNE0EUiCkHWODpg14iFsQ7RiHvaWX33Du5ix 2HsgrclkVpeJv7fWuZHD+TLVb+gJ/GFYXKruiF2fm6o1GShwaBtKTwLcr+8SLahDYkcY BjNg== X-Gm-Message-State: ALyK8tI50+DE10rHCavq9pbtAd811htpaojzx9iR1sX4IOH2CiohGgrYkCnK8oo0E7aoN9pu 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 Cc: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , John Stultz , Guodong Xu , linux-arm-kernel@lists.infradead.org, Ulf Hansson 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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; }