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: 70033 Delivered-To: patches@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2098549qgf; Tue, 14 Jun 2016 08:07:52 -0700 (PDT) X-Received: by 10.46.32.38 with SMTP id g38mr4987216ljg.31.1465916867431; Tue, 14 Jun 2016 08:07:47 -0700 (PDT) Return-Path: Received: from mail-lf0-x231.google.com (mail-lf0-x231.google.com. [2a00:1450:4010:c07::231]) by mx.google.com with ESMTPS id v70si14669751lfd.132.2016.06.14.08.07.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:07:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) client-ip=2a00:1450:4010:c07::231; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x231.google.com with SMTP id f6so85411447lfg.0 for ; Tue, 14 Jun 2016 08:07:47 -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=CqRvYfbc17UXxWMkpNAYkq36JO0uWLgRsGe9i7A1muw+bzJmJPB715aVIhXXXt3ou3 vmtdwaNciJDixj4OIDHG3cW2dpGW6/pHrFn1ODYviP57Y8eGXlsSm2UZYmlNLyOZ9skO uu3/GtUP6ZonHV3+slr3MGxNshifVbUsLdNSeVXuO+AUELh728JRat6RKHV0zd/EMdXK nDfWAH+S3HIVoFG8f7cZ4EZWaMWaLstKdRh935R539WzR4Ybkgk0FYFVKqeendlg3Iv+ dg7wiQhailYRS0Dps3fBokMLRW5s+ailH8nnDTqZm+6WL0zzwF8wPfYuzX1upOBG104Z C91A== X-Gm-Message-State: ALyK8tLJbjbcoFSPHESavHNY9WE8kOQSu5Ikm/fBXl7XOvX3nDj4WZhEit9WnUqVOwG1D4r9CNU= X-Received: by 10.25.160.205 with SMTP id j196mr2126242lfe.47.1465916867125; Tue, 14 Jun 2016 08:07:47 -0700 (PDT) Return-Path: 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> 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(-) -- 1.9.1 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; }