PM / Domains: Check for existing PM domain in dev_pm_domain_attach()
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 26 Apr 2018 08:53:03 +0000 (10:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 14 May 2018 20:58:44 +0000 (22:58 +0200)
Instead of checking if an existing PM domain pointer has been assigned in
genpd_dev_pm_attach() and acpi_dev_pm_attach(), move the check to the
common path in dev_pm_domain_attach(), thus potentially avoid one
unnecessary check.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/device_pm.c
drivers/base/power/common.c
drivers/base/power/domain.c

index 3d96e4da2d98c9bbffc220856805dc5c77e43f3e..d006300161764ed45ed8a12387e9d676d7262172 100644 (file)
@@ -1259,9 +1259,6 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
        if (!adev)
                return -ENODEV;
 
-       if (dev->pm_domain)
-               return -EEXIST;
-
        /*
         * Only attach the power domain to the first device if the
         * companion is shared by multiple. This is to prevent doing power
index f6a9ad52cbbff0663e58540f33bb29e08abf0e96..f3cf61f58f2586602bdc818ac01de9f6ae5d292b 100644 (file)
@@ -104,6 +104,9 @@ int dev_pm_domain_attach(struct device *dev, bool power_on)
 {
        int ret;
 
+       if (dev->pm_domain)
+               return -EEXIST;
+
        ret = acpi_dev_pm_attach(dev, power_on);
        if (ret)
                ret = genpd_dev_pm_attach(dev);
index d4b96edb027daecc46e21ff47b476e9727b1df73..b816adbe1e6204fe8b68e15fd2849f6f6efa2716 100644 (file)
@@ -2194,9 +2194,6 @@ int genpd_dev_pm_attach(struct device *dev)
        if (!dev->of_node)
                return -ENODEV;
 
-       if (dev->pm_domain)
-               return -EEXIST;
-
        ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
                                        "#power-domain-cells", 0, &pd_args);
        if (ret < 0)