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: 136285 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1056692lji; Fri, 18 May 2018 03:31:57 -0700 (PDT) X-Received: by 2002:a2e:9c90:: with SMTP id x16-v6mr5333475lji.13.1526639517068; Fri, 18 May 2018 03:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526639517; cv=none; d=google.com; s=arc-20160816; b=KmZYMSmSiaaCYKBOCFa4mQBR7/PCAfDVi/zxJaALZxwTziAyUXQCjeAV3k891htD7x P/f4jP8T6L6oPsv6MQamevzQzY0jA1Qq0W6IrvVt9I3VQXPHUIGgsYcMyhaDgiaDMOUs ZG8+3MeIlOptU92BD5gguU0mrvtgRpMbwAgdm3CO4GyZdvYp4I2/C1LGH98WfFmtotZd pCnln9KthlFAornWVzkl+WR3loG+FHMTZK4pCpPV8/Fa3fvzXisYCFvc/uaahyHOSBrv guBZKsmGDeO2MDHJ/3HV//fwEPHUMt0MIyWW0PBxfI2T4WrX68PSn0cd2IF/TbGVDiSq CtjA== 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=sU8YoiDnS9KwTX3yb8JNQw8Hu2BQlzK2ChcOcpzCzno=; b=pIL9ciMVaimujcipLy1RkzvdspMRMQHQsgB8zISXYh3vA9uDrnwY1nPgcNdCssPwkM d3bp7F1Pqxee3WJuO+8Hxi3+U5GwtXCOkFTdAJjQtCnjw6zy9wXMmCaqEaebA8/mItVU aMMpxrMc5hFeHgxMKJSB/qtpEwIliVtUHs1Nn87wxnYU4Ei5fEp3DoJAtlTuK1/Ot5F0 Mz2Q1tmPj36Y+vfpjv98emg5Kz2EGlkdCZZzfrT+O35lpdeCguFs0FBSJ5KRFKZtLfyb r7LAQZaOXan3womJqBqP99hMvauSrxNXaCyq+GpFmVexph1azq3fXbDzrtRnSBv6eZgI 7gow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OuwhZT3r; 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 p23-v6sor1770480lji.3.2018.05.18.03.31.57 for (Google Transport Security); Fri, 18 May 2018 03:31:57 -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=OuwhZT3r; 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=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=rxEpvAP8ZG6oWkG+PNE7EaUMRgIP4QX3at+4b+OoKXPLS5K23EeLG9aB+D0RzwPcX+ g46i4X3m1zM22nncm0V/0t/MtCvJUbSytU1u9qlGkHl75grjuozXfrlPiSRGeaWlihhc /mFzqlWfF3HGLG81caKKaRQbLTtEsih3rtlbkyGUNwGPDqwK//G5sPbXcaK2Lg2QYxdS uwSCC4rKHGqFWuioa8wmeci/G+mOjiftEEwDpHrRyipIk5Poft2rwthbptiTLm8pK8xu bKUS/VyhXtGtnVwdxuVrXdbePqx+pe1iteAaZ2XYX9/DmJpS76dgadiLWO4srw+/PcWM QRZw== X-Gm-Message-State: ALKqPwet0F96t06kkfzOdF4I6OjyNk7H/J+0B1ZSWuXGjAJWvYErU+mj xfZE6/eUtAEPSL8Uy35duXzi8zZy 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) 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 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> 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.7.4 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[] = {