aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2016-01-07 10:46:13 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-01-07 19:12:06 -0500
commit989561de9b5112999475b406557d9c7e9e59c041 (patch)
tree1c4257ef719116fecbea9ecdd14febb6af2c336b /drivers/acpi
parent6b9cb42752dafba3761dde0002ca58ca518b6311 (diff)
PM / Domains: add setter for dev.pm_domain
Adds a function that sets the pointer to dev_pm_domain in struct device and that warns if the device has already finished probing. The reason why we want to enforce that is because in the general case that can cause problems and also that we can simplify code quite a bit if we can always assume that. This patch also changes all current code that directly sets the dev.pm_domain pointer. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_lpss.c5
-rw-r--r--drivers/acpi/device_pm.c5
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 047281a6ae11..c570b1d9f094 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -18,6 +18,7 @@
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/platform_data/clk-lpss.h> 20#include <linux/platform_data/clk-lpss.h>
21#include <linux/pm_domain.h>
21#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
22#include <linux/delay.h> 23#include <linux/delay.h>
23 24
@@ -875,13 +876,14 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb,
875 876
876 switch (action) { 877 switch (action) {
877 case BUS_NOTIFY_BIND_DRIVER: 878 case BUS_NOTIFY_BIND_DRIVER:
878 pdev->dev.pm_domain = &acpi_lpss_pm_domain; 879 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain);
879 break; 880 break;
880 case BUS_NOTIFY_DRIVER_NOT_BOUND: 881 case BUS_NOTIFY_DRIVER_NOT_BOUND:
881 case BUS_NOTIFY_UNBOUND_DRIVER: 882 case BUS_NOTIFY_UNBOUND_DRIVER:
882 pdev->dev.pm_domain = NULL; 883 pdev->dev.pm_domain = NULL;
883 break; 884 break;
884 case BUS_NOTIFY_ADD_DEVICE: 885 case BUS_NOTIFY_ADD_DEVICE:
886 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain);
885 if (pdata->dev_desc->flags & LPSS_LTR) 887 if (pdata->dev_desc->flags & LPSS_LTR)
886 return sysfs_create_group(&pdev->dev.kobj, 888 return sysfs_create_group(&pdev->dev.kobj,
887 &lpss_attr_group); 889 &lpss_attr_group);
@@ -889,6 +891,7 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb,
889 case BUS_NOTIFY_DEL_DEVICE: 891 case BUS_NOTIFY_DEL_DEVICE:
890 if (pdata->dev_desc->flags & LPSS_LTR) 892 if (pdata->dev_desc->flags & LPSS_LTR)
891 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); 893 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
894 dev_pm_domain_set(&pdev->dev, NULL);
892 break; 895 break;
893 default: 896 default:
894 break; 897 break;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 08a02cdc737c..cd2c3d6d40e0 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -22,6 +22,7 @@
22#include <linux/export.h> 22#include <linux/export.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/pm_qos.h> 24#include <linux/pm_qos.h>
25#include <linux/pm_domain.h>
25#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
26 27
27#include "internal.h" 28#include "internal.h"
@@ -1059,7 +1060,7 @@ static void acpi_dev_pm_detach(struct device *dev, bool power_off)
1059 struct acpi_device *adev = ACPI_COMPANION(dev); 1060 struct acpi_device *adev = ACPI_COMPANION(dev);
1060 1061
1061 if (adev && dev->pm_domain == &acpi_general_pm_domain) { 1062 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1062 dev->pm_domain = NULL; 1063 dev_pm_domain_set(dev, NULL);
1063 acpi_remove_pm_notifier(adev); 1064 acpi_remove_pm_notifier(adev);
1064 if (power_off) { 1065 if (power_off) {
1065 /* 1066 /*
@@ -1111,7 +1112,7 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
1111 return -EBUSY; 1112 return -EBUSY;
1112 1113
1113 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func); 1114 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
1114 dev->pm_domain = &acpi_general_pm_domain; 1115 dev_pm_domain_set(dev, &acpi_general_pm_domain);
1115 if (power_on) { 1116 if (power_on) {
1116 acpi_dev_pm_full_power(adev); 1117 acpi_dev_pm_full_power(adev);
1117 acpi_device_wakeup(adev, ACPI_STATE_S0, false); 1118 acpi_device_wakeup(adev, ACPI_STATE_S0, false);