From patchwork Tue May 29 10:04:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 137141 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3845523lji; Tue, 29 May 2018 03:04:39 -0700 (PDT) X-Received: by 2002:a2e:302:: with SMTP id 2-v6mr10608112ljd.9.1527588279682; Tue, 29 May 2018 03:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527588279; cv=none; d=google.com; s=arc-20160816; b=n9sGVz5EObSN+gzR3J1qwMn2+qyrfpGf/Zr2g+/5z9jMOkOxGBMEEAk5LX+ZGpdcv6 AUWTDv6mH36cyPiU118odXpvf68xfD5w01b2iB4d87Q7z8ZWCOfhvlg57ec39VIIeg56 m5T7XDWaEGpUi8xlsVccjEunOQAYARLtRZ/0Ac4BVlIGhPunNgSAGZRybj+AaGQ5wB6c XryyC9wtFdk5t6w0Cf52LhoxiFA6Hs4PJPVC9rAU2YxhyEe8CwyFDfhCJn0G4IySMGZ0 kBL+uedNbhB6t7+K2CQdcoea4iiXdsAJ7r/xJRrA4dkwX+xMzu5OuPULl9YtrPvmriyJ w+zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=w08o5AzxzvUhesJImVVhXniyXaRI88njLEe6l9D4feg=; b=L3X+Aq9VLRXBY7DfSu8uYWCQgDoMYyI1vlVyDoCG+5rKU8JInCrVc8aQmbwAXWHlrD rj7FxOcDhKjSVAn37CvVgrCzrOTYL54fyriC2tJIW6SOVnu822AjyqZUe6GX3UMHUSHI AS4i0RHSDQVlolVYcEonyiq8cCt3BQlvZnQO4EwVV764ob3+B2i8JFqiPRhDowsGZ/fa A30XIzTs2zwg9M/0CYc+IGCK810lxRnwCQxTsh6KoBaG5bJ1DnQ3Ws5CcKB2TZCSw7mU dv/iRUvpZuzih0fBUmFerjb/1mOKTC450/W/QxjR1x4HksnfLG5LzoiqehihG4SnXkln P4Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nt+688gK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q62-v6sor7303462ljq.79.2018.05.29.03.04.39 for (Google Transport Security); Tue, 29 May 2018 03:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nt+688gK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=w08o5AzxzvUhesJImVVhXniyXaRI88njLEe6l9D4feg=; b=Nt+688gKBsSkFKU5Lj4526i3xTldcMu+NNHQT001VY29Q1UhsJEzcq61e6xsZ5U88t lDzymVbNVYLpfChI6orDO7EyYlIjp0+SvMBfoTxagUIlJkmCk4o9MYSvosHkwD9CJMqN wUsgRZSLJXP0vfk4CjV+VfhLo8x9JUcI0jbLw= 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=w08o5AzxzvUhesJImVVhXniyXaRI88njLEe6l9D4feg=; b=oJvnFpjoAupVBaMgaqz+tgDqec/jU70u4vAOSv6LphEYMG/oLHUOjiS8CoDZLARZxg wioDuWItnOFWOmC2MSgxhYd6wwe6FxLBFap0tCtI17vcdoTs1MNg9DhWGFE7uaqdnUA5 9SunrUbs2WP99GZAsglZHP4MqhHRopLoAcXUCgCMfE3ZVVnjsKhNPgyYor2b7G+MUmcf rrnF134I85QXBo/hfBKeaJpVsSns8bB92O9AbzFJl6X9ZilirwNNy/ZFwhPj1RV/vIo7 66ktt+WSoXf/zXXfU6wHh8xogGPA+D/kGMQYn/spjfOTPKOz4QXjeumicSNZJq00aKMa HRyQ== X-Gm-Message-State: ALKqPwdF6fSj6ETfHWt3QGHvN+FH8OyIXGnZdqotIRu5GcH19NS3bEhx yQyJj0f1zfBFehtcmRkdk6xL4Csf X-Google-Smtp-Source: ADUXVKIJ/QliCcGCC68y02tC/ASzBcOLD+ekXuglYfH8fXzdY1EHNuWngpoa3K2ZAqaHOS1rAnoK6w== X-Received: by 2002:a2e:29cf:: with SMTP id p76-v6mr6408280ljp.12.1527588279396; Tue, 29 May 2018 03:04:39 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id e21-v6sm2561718lfg.74.2018.05.29.03.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:38 -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 v2 7/9] PM / Domains: Split genpd_dev_pm_attach() Date: Tue, 29 May 2018 12:04:19 +0200 Message-Id: <20180529100421.31022-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-ulf.hansson@linaro.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(-) -- 2.17.0 Acked-by: Jon Hunter Tested-by: Jon Hunter Reviewed-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 12a20f21974d..2af99bfcbe3c 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[] = {