From patchwork Tue Jun 14 15:07:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 70034 Delivered-To: patches@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2098599qgf; Tue, 14 Jun 2016 08:07:57 -0700 (PDT) X-Received: by 10.25.29.12 with SMTP id d12mr2042679lfd.142.1465916869039; Tue, 14 Jun 2016 08:07:49 -0700 (PDT) Return-Path: Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com. [2a00:1450:4010:c07::22a]) by mx.google.com with ESMTPS id m80si14627918lfg.355.2016.06.14.08.07.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:07:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) client-ip=2a00:1450:4010:c07::22a; 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::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22a.google.com with SMTP id f6so85411965lfg.0 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=WHBlxH7vE2J2Lqrs2Ye+Vc6RYQLgd5+7ROhZb2ab5sQ=; b=EjjVb1WGmPuJg8h/ZD1s6T2c3/Dw47tQ7Uy31hKisnpwej9jszttAmjj1BOHzPdFd1 JvNB3PLpz4raO5IBtRJIYPq1OXuqVGW8Rx63UHxzY6hMM9bS2hmk1O+ZNkHu72cKCOsL qPberD0soPYVSrTHaXPxj0R63AigSYOTkMxkQ= 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=WHBlxH7vE2J2Lqrs2Ye+Vc6RYQLgd5+7ROhZb2ab5sQ=; b=J6oTid6+wpI1JAFImCMHFQzJAtrkyzLTiNG9oxkBTJTBDORV7S0zgPp9ZLS3y9ts1K G6UvwsiquGylEqxskdb4MSVYhBceqxP7AJ3p8f5GsQdNQtzdIqhAnY2M7dyScPuVsgXM skXlnK+2WKr4kpss9Ly1ny52yVWKkdwnSgrzLpfClJFd33ZJLsC0MW13K3viDyzm1q80 HBCmf27I56SRbVnUsMw9hCW9t2SQ3VtV0OlMHo1TAwS6z88/vChwB19N0X8BlP4Zk70T +7oiV1uZwSHcyPltyoOvsRjIPeFNAylFNE/zV6O6hTMPwXHFwtjA9z6rdnjO2kQ4LiHt hFAw== X-Gm-Message-State: ALyK8tJy1Yy5RIOlPv7XLYh7Id0Tfi/8EVTPj3FMnRLBw52F6V5Wnlg3M97ddyIXmHg+fuVdWzc= X-Received: by 10.25.18.234 with SMTP id 103mr2266658lfs.118.1465916868648; Tue, 14 Jun 2016 08:07:48 -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.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 08:07:47 -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 03/10] i2c: designware-platdrv: Unconditionally enable runtime PM Date: Tue, 14 Jun 2016 17:07:21 +0200 Message-Id: <1465916848-8207-4-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> In cases when the designware specific flag "pm_runtime_disable" is set, ->probe() calls pm_runtime_forbid() for the device, but without enabling runtime PM. This increases the runtime PM usage count for the device, but as runtime PM is disabled it's pointless. Let's instead convert to unconditionally enable runtime PM, which has the effect of making a parent device aware of its child. To also maintain the old behaviour when the "pm_runtime_disable" flag is set, which prevents userspace to enable runtime PM suspend via sysfs, switch from calling pm_runtime_forbid() into pm_runtime_get_noresume() during ->probe(). While changing this, let's also also correct the error path in ->probe() and fix ->remove(), as to decrease the runtime PM usage count when it has been in increased by pm_runtime_forbid() (after this change, by pm_runtime_get_noresume()). Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 19174e7..94ff953 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -236,21 +236,21 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) 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 { - pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - } + pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + if (dev->pm_runtime_disabled) + pm_runtime_get_noresume(&pdev->dev); r = i2c_dw_probe(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_disable(&pdev->dev); + if (dev->pm_runtime_disabled) + pm_runtime_put_noidle(&pdev->dev); } pm_runtime_put(&pdev->dev); @@ -267,10 +267,11 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) i2c_dw_disable(dev); + if (dev->pm_runtime_disabled) + pm_runtime_put_noidle(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_put_sync(&pdev->dev); - if (!dev->pm_runtime_disabled) - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(&pdev->dev); return 0; }