From: Ulf Hansson Date: Thu, 18 Apr 2019 10:27:57 +0000 (+0200) Subject: PM / Domains: Enable genpd_dev_pm_attach_by_id|name() for single PM domain X-Git-Tag: v5.15~6480^2^3~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ccf3f0cd1971e007680114ff732e8a717aafbf8;p=platform%2Fkernel%2Flinux-starfive.git PM / Domains: Enable genpd_dev_pm_attach_by_id|name() for single PM domain If a call to dev_pm_domain_attach() succeeds to attach a device to its single PM domain, the important point is to prevent subsequent dev_pm_domain_attach_by_name|id() calls from failing. That is done by checking the dev->pm_domain pointer and then returning -EEXIST, rather than continuing to call genpd_dev_pm_attach_by_id|name(). For this reason, enable genpd_dev_pm_attach_by_id|name() to be used for single PM domains too. This simplifies future users, so they only need to use dev_pm_domain_attach_by_id|name() instead of having to combine it with dev_pm_domain_attach(). Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar Acked-by: Niklas Cassel Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index a0b021d..d97bcf6 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2439,10 +2439,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, if (!dev->of_node) return NULL; - /* Deal only with devices using multiple PM domains. */ + /* Verify that the index is within a valid range. */ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells"); - if (num_domains < 2 || index >= num_domains) + if (index >= num_domains) return NULL; /* Allocate and register device on the genpd bus. */