Merge back earlier ACPI PM material for v4.3.
[firefly-linux-kernel-4.4.55.git] / drivers / acpi / device_pm.c
index 88dbbb115285a3ce54ae5c35260692163bae16ca..337e8118836dd76bb30027ba9c90e4ff919fb0e7 100644 (file)
@@ -1123,6 +1123,14 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
        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
+        * management twice.
+        */
+       if (!acpi_device_is_first_physical_node(adev, dev))
+               return -EBUSY;
+
        acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
        dev->pm_domain = &acpi_general_pm_domain;
        if (power_on) {