From patchwork Fri May 18 10:31:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OuwhZT3r"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPcN5KB8z9s33 for ; Fri, 18 May 2018 20:32:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbeERKcD (ORCPT ); Fri, 18 May 2018 06:32:03 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33099 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627AbeERKb6 (ORCPT ); Fri, 18 May 2018 06:31:58 -0400 Received: by mail-lf0-f66.google.com with SMTP id h9-v6so13239049lfi.0 for ; Fri, 18 May 2018 03:31:57 -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=sU8YoiDnS9KwTX3yb8JNQw8Hu2BQlzK2ChcOcpzCzno=; b=OuwhZT3re7bOZzUyx1ZCKemt3sE86/MtuzIsxvjP2qcsOl7FYo1gFL82H8qsU20Sh9 /655EcFClraw10GEeLB/WMdCKbKBF4gF7pB6b6fBy5DbR8mP1R1kcQPNfmpZq5eXQ9mv 0/+PKS9QyhZ4CCnWMMXHBsZbX/pKvv4+3EQZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sU8YoiDnS9KwTX3yb8JNQw8Hu2BQlzK2ChcOcpzCzno=; b=jcniUW26c5BpWwi0THT9+AV4XdLuhKRZk6hmh4gh94hYgySaDHtXRfIGKuks11w7/6 wk+DaP41O9qzcTX0rmAmHFKGX94p8t+GCL6bqQixRWNavg4DWqN1PLe6zhWsMI15/DtW +SLqeA6SC79J8H/sN7mG5YxzXUjCGAxvy66J/lYrEZ2pUr8iQO6CjCNL8RozQgB8sghA PM1qbcPEGAzSDNGBGQwlwj/k28hZuaOD7r8A5ncvTHnwBT8EvZIhwngigh73AJgSMDec YWqncrKn6DuScfTJWp/QKMQEcePZrT2lNKyfMGojTYCQcGcSy+QZ1TO7MWX/2Cs68ft7 fIXQ== X-Gm-Message-State: ALKqPwfDCTl4zrfCSPaK8hYeNcjSCtLH5zQFCDoBtMLidAyeBBOqtV7/ Mplue0qHQ9t8CEr+AZ7vlQ6WdQ== X-Google-Smtp-Source: AB8JxZog55BJ5wlqBKzzx6/qzmykM0WVtUMCUbPNJ3dKVeDfFA03E89utYZkZf18WbLt9/JtdUezVg== X-Received: by 2002:a2e:4d5d:: with SMTP id a90-v6mr5576174ljb.86.1526639516836; Fri, 18 May 2018 03:31:56 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id u14-v6sm393447lfk.55.2018.05.18.03.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 7/9] PM / Domains: Split genpd_dev_pm_attach() Date: Fri, 18 May 2018 12:31:28 +0200 Message-Id: <1526639490-12167-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org To extend genpd to deal with allowing multiple PM domains per device, some of the code in genpd_dev_pm_attach() can be re-used. Let's prepare for this by moving some of the code into a sub-function. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4597e1c..d538640 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2221,38 +2221,15 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -/** - * genpd_dev_pm_attach - Attach a device to its PM domain using DT. - * @dev: Device to attach. - * - * Parse device's OF node to find a PM domain specifier. If such is found, - * attaches the device to retrieved pm_domain ops. - * - * Returns 1 on successfully attached PM domain, 0 when the device don't need a - * PM domain or when multiple power-domains exists for it, else a negative error - * code. Note that if a power-domain exists for the device, but it cannot be - * found or turned on, then return -EPROBE_DEFER to ensure that the device is - * not probed and to re-try again later. - */ -int genpd_dev_pm_attach(struct device *dev) +static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, + unsigned int index) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; int ret; - if (!dev->of_node) - return 0; - - /* - * Devices with multiple PM domains must be attached separately, as we - * can only attach one PM domain per device. - */ - if (of_count_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells") != 1) - return 0; - - ret = of_parse_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells", 0, &pd_args); + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", index, &pd_args); if (ret < 0) return ret; @@ -2290,6 +2267,35 @@ int genpd_dev_pm_attach(struct device *dev) return ret ? -EPROBE_DEFER : 1; } + +/** + * genpd_dev_pm_attach - Attach a device to its PM domain using DT. + * @dev: Device to attach. + * + * Parse device's OF node to find a PM domain specifier. If such is found, + * attaches the device to retrieved pm_domain ops. + * + * Returns 1 on successfully attached PM domain, 0 when the device don't need a + * PM domain or when multiple power-domains exists for it, else a negative error + * code. Note that if a power-domain exists for the device, but it cannot be + * found or turned on, then return -EPROBE_DEFER to ensure that the device is + * not probed and to re-try again later. + */ +int genpd_dev_pm_attach(struct device *dev) +{ + if (!dev->of_node) + return 0; + + /* + * Devices with multiple PM domains must be attached separately, as we + * can only attach one PM domain per device. + */ + if (of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells") != 1) + return 0; + + return __genpd_dev_pm_attach(dev, dev->of_node, 0); +} EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); static const struct of_device_id idle_state_match[] = {