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: 635355 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 3rTY184X0Gz9t12 for ; Wed, 15 Jun 2016 01:07:56 +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=EjjVb1WG; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751202AbcFNPHz (ORCPT ); Tue, 14 Jun 2016 11:07:55 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:33263 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbcFNPHz (ORCPT ); Tue, 14 Jun 2016 11:07:55 -0400 Received: by mail-lf0-f53.google.com with SMTP id f6so85411978lfg.0 for ; Tue, 14 Jun 2016 08:07:54 -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=bLoT57PM1OdyqwnhPhL0U72qbDXSmqgYgZp1ey8Wl+q2ssTewszoFJrE1ZjY0VItvH TZUf/iCXdcJEbOCAjUYRgBLGtZyVKlAsSMbpaVGKFj6rCYuUw4vZx9FPE1ZyDVTFvQMt WwLcRuPBZCX75eFRpXEuCJoHqg03FB4Rk4q/xYlaB6wf4DYRHwY8EO6GzCtE6skDGBh0 amzyjdSWPigwRs8VgPYyZLPuHpQ6Jj1zqZbUUxWeLihtfa55hAs/zIsfbfQF4iWiFU+m 7kNqb+erpW98ljK9SKFadWtqlyyZKW4/wm/T73kHHfFnGuFswXfXUmhF+MgdwGUsBhjH axlA== X-Gm-Message-State: ALyK8tLvwGA8Dk76kIGZMTqzSKGEvLBmu/KMjfIDPo7mSwcPiJV9VGgtWQznC4Z8CLdZmNeW X-Received: by 10.25.18.234 with SMTP id 103mr2266658lfs.118.1465916868648; Tue, 14 Jun 2016 08:07:48 -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.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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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; }