diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/Kconfig | 8 | ||||
-rw-r--r-- | drivers/acpi/device_pm.c | 56 | ||||
-rw-r--r-- | drivers/acpi/power.c | 104 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 1 |
4 files changed, 8 insertions, 161 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 22327e6a7236..6efe2ac6902f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -24,7 +24,7 @@ menuconfig ACPI | |||
24 | are configured, ACPI is used. | 24 | are configured, ACPI is used. |
25 | 25 | ||
26 | The project home page for the Linux ACPI subsystem is here: | 26 | The project home page for the Linux ACPI subsystem is here: |
27 | <http://www.lesswatts.org/projects/acpi/> | 27 | <https://01.org/linux-acpi> |
28 | 28 | ||
29 | Linux support for ACPI is based on Intel Corporation's ACPI | 29 | Linux support for ACPI is based on Intel Corporation's ACPI |
30 | Component Architecture (ACPI CA). For more information on the | 30 | Component Architecture (ACPI CA). For more information on the |
@@ -123,9 +123,9 @@ config ACPI_BUTTON | |||
123 | default y | 123 | default y |
124 | help | 124 | help |
125 | This driver handles events on the power, sleep, and lid buttons. | 125 | This driver handles events on the power, sleep, and lid buttons. |
126 | A daemon reads /proc/acpi/event and perform user-defined actions | 126 | A daemon reads events from input devices or via netlink and |
127 | such as shutting down the system. This is necessary for | 127 | performs user-defined actions such as shutting down the system. |
128 | software-controlled poweroff. | 128 | This is necessary for software-controlled poweroff. |
129 | 129 | ||
130 | To compile this driver as a module, choose M here: | 130 | To compile this driver as a module, choose M here: |
131 | the module will be called button. | 131 | the module will be called button. |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 59d3202f6b36..a94383d1f350 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -1025,60 +1025,4 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off) | |||
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); | 1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); |
1028 | |||
1029 | /** | ||
1030 | * acpi_dev_pm_add_dependent - Add physical device depending for PM. | ||
1031 | * @handle: Handle of ACPI device node. | ||
1032 | * @depdev: Device depending on that node for PM. | ||
1033 | */ | ||
1034 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev) | ||
1035 | { | ||
1036 | struct acpi_device_physical_node *dep; | ||
1037 | struct acpi_device *adev; | ||
1038 | |||
1039 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1040 | return; | ||
1041 | |||
1042 | mutex_lock(&adev->physical_node_lock); | ||
1043 | |||
1044 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1045 | if (dep->dev == depdev) | ||
1046 | goto out; | ||
1047 | |||
1048 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
1049 | if (dep) { | ||
1050 | dep->dev = depdev; | ||
1051 | list_add_tail(&dep->node, &adev->power_dependent); | ||
1052 | } | ||
1053 | |||
1054 | out: | ||
1055 | mutex_unlock(&adev->physical_node_lock); | ||
1056 | } | ||
1057 | EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent); | ||
1058 | |||
1059 | /** | ||
1060 | * acpi_dev_pm_remove_dependent - Remove physical device depending for PM. | ||
1061 | * @handle: Handle of ACPI device node. | ||
1062 | * @depdev: Device depending on that node for PM. | ||
1063 | */ | ||
1064 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev) | ||
1065 | { | ||
1066 | struct acpi_device_physical_node *dep; | ||
1067 | struct acpi_device *adev; | ||
1068 | |||
1069 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1070 | return; | ||
1071 | |||
1072 | mutex_lock(&adev->physical_node_lock); | ||
1073 | |||
1074 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1075 | if (dep->dev == depdev) { | ||
1076 | list_del(&dep->node); | ||
1077 | kfree(dep); | ||
1078 | break; | ||
1079 | } | ||
1080 | |||
1081 | mutex_unlock(&adev->physical_node_lock); | ||
1082 | } | ||
1083 | EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent); | ||
1084 | #endif /* CONFIG_PM */ | 1028 | #endif /* CONFIG_PM */ |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 0dbe5cdf3396..c2ad391d8041 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -59,16 +59,9 @@ ACPI_MODULE_NAME("power"); | |||
59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 | 59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 |
60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF | 60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF |
61 | 61 | ||
62 | struct acpi_power_dependent_device { | ||
63 | struct list_head node; | ||
64 | struct acpi_device *adev; | ||
65 | struct work_struct work; | ||
66 | }; | ||
67 | |||
68 | struct acpi_power_resource { | 62 | struct acpi_power_resource { |
69 | struct acpi_device device; | 63 | struct acpi_device device; |
70 | struct list_head list_node; | 64 | struct list_head list_node; |
71 | struct list_head dependent; | ||
72 | char *name; | 65 | char *name; |
73 | u32 system_level; | 66 | u32 system_level; |
74 | u32 order; | 67 | u32 order; |
@@ -233,32 +226,6 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) | |||
233 | return 0; | 226 | return 0; |
234 | } | 227 | } |
235 | 228 | ||
236 | static void acpi_power_resume_dependent(struct work_struct *work) | ||
237 | { | ||
238 | struct acpi_power_dependent_device *dep; | ||
239 | struct acpi_device_physical_node *pn; | ||
240 | struct acpi_device *adev; | ||
241 | int state; | ||
242 | |||
243 | dep = container_of(work, struct acpi_power_dependent_device, work); | ||
244 | adev = dep->adev; | ||
245 | if (acpi_power_get_inferred_state(adev, &state)) | ||
246 | return; | ||
247 | |||
248 | if (state > ACPI_STATE_D0) | ||
249 | return; | ||
250 | |||
251 | mutex_lock(&adev->physical_node_lock); | ||
252 | |||
253 | list_for_each_entry(pn, &adev->physical_node_list, node) | ||
254 | pm_request_resume(pn->dev); | ||
255 | |||
256 | list_for_each_entry(pn, &adev->power_dependent, node) | ||
257 | pm_request_resume(pn->dev); | ||
258 | |||
259 | mutex_unlock(&adev->physical_node_lock); | ||
260 | } | ||
261 | |||
262 | static int __acpi_power_on(struct acpi_power_resource *resource) | 229 | static int __acpi_power_on(struct acpi_power_resource *resource) |
263 | { | 230 | { |
264 | acpi_status status = AE_OK; | 231 | acpi_status status = AE_OK; |
@@ -283,14 +250,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource) | |||
283 | resource->name)); | 250 | resource->name)); |
284 | } else { | 251 | } else { |
285 | result = __acpi_power_on(resource); | 252 | result = __acpi_power_on(resource); |
286 | if (result) { | 253 | if (result) |
287 | resource->ref_count--; | 254 | resource->ref_count--; |
288 | } else { | ||
289 | struct acpi_power_dependent_device *dep; | ||
290 | |||
291 | list_for_each_entry(dep, &resource->dependent, node) | ||
292 | schedule_work(&dep->work); | ||
293 | } | ||
294 | } | 255 | } |
295 | return result; | 256 | return result; |
296 | } | 257 | } |
@@ -390,52 +351,6 @@ static int acpi_power_on_list(struct list_head *list) | |||
390 | return result; | 351 | return result; |
391 | } | 352 | } |
392 | 353 | ||
393 | static void acpi_power_add_dependent(struct acpi_power_resource *resource, | ||
394 | struct acpi_device *adev) | ||
395 | { | ||
396 | struct acpi_power_dependent_device *dep; | ||
397 | |||
398 | mutex_lock(&resource->resource_lock); | ||
399 | |||
400 | list_for_each_entry(dep, &resource->dependent, node) | ||
401 | if (dep->adev == adev) | ||
402 | goto out; | ||
403 | |||
404 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
405 | if (!dep) | ||
406 | goto out; | ||
407 | |||
408 | dep->adev = adev; | ||
409 | INIT_WORK(&dep->work, acpi_power_resume_dependent); | ||
410 | list_add_tail(&dep->node, &resource->dependent); | ||
411 | |||
412 | out: | ||
413 | mutex_unlock(&resource->resource_lock); | ||
414 | } | ||
415 | |||
416 | static void acpi_power_remove_dependent(struct acpi_power_resource *resource, | ||
417 | struct acpi_device *adev) | ||
418 | { | ||
419 | struct acpi_power_dependent_device *dep; | ||
420 | struct work_struct *work = NULL; | ||
421 | |||
422 | mutex_lock(&resource->resource_lock); | ||
423 | |||
424 | list_for_each_entry(dep, &resource->dependent, node) | ||
425 | if (dep->adev == adev) { | ||
426 | list_del(&dep->node); | ||
427 | work = &dep->work; | ||
428 | break; | ||
429 | } | ||
430 | |||
431 | mutex_unlock(&resource->resource_lock); | ||
432 | |||
433 | if (work) { | ||
434 | cancel_work_sync(work); | ||
435 | kfree(dep); | ||
436 | } | ||
437 | } | ||
438 | |||
439 | static struct attribute *attrs[] = { | 354 | static struct attribute *attrs[] = { |
440 | NULL, | 355 | NULL, |
441 | }; | 356 | }; |
@@ -524,8 +439,6 @@ static void acpi_power_expose_hide(struct acpi_device *adev, | |||
524 | 439 | ||
525 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | 440 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) |
526 | { | 441 | { |
527 | struct acpi_device_power_state *ps; | ||
528 | struct acpi_power_resource_entry *entry; | ||
529 | int state; | 442 | int state; |
530 | 443 | ||
531 | if (adev->wakeup.flags.valid) | 444 | if (adev->wakeup.flags.valid) |
@@ -535,16 +448,6 @@ void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | |||
535 | if (!adev->power.flags.power_resources) | 448 | if (!adev->power.flags.power_resources) |
536 | return; | 449 | return; |
537 | 450 | ||
538 | ps = &adev->power.states[ACPI_STATE_D0]; | ||
539 | list_for_each_entry(entry, &ps->resources, node) { | ||
540 | struct acpi_power_resource *resource = entry->resource; | ||
541 | |||
542 | if (add) | ||
543 | acpi_power_add_dependent(resource, adev); | ||
544 | else | ||
545 | acpi_power_remove_dependent(resource, adev); | ||
546 | } | ||
547 | |||
548 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) | 451 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) |
549 | acpi_power_expose_hide(adev, | 452 | acpi_power_expose_hide(adev, |
550 | &adev->power.states[state].resources, | 453 | &adev->power.states[state].resources, |
@@ -882,7 +785,6 @@ int acpi_add_power_resource(acpi_handle handle) | |||
882 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, | 785 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, |
883 | ACPI_STA_DEFAULT); | 786 | ACPI_STA_DEFAULT); |
884 | mutex_init(&resource->resource_lock); | 787 | mutex_init(&resource->resource_lock); |
885 | INIT_LIST_HEAD(&resource->dependent); | ||
886 | INIT_LIST_HEAD(&resource->list_node); | 788 | INIT_LIST_HEAD(&resource->list_node); |
887 | resource->name = device->pnp.bus_id; | 789 | resource->name = device->pnp.bus_id; |
888 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); | 790 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); |
@@ -936,8 +838,10 @@ void acpi_resume_power_resources(void) | |||
936 | mutex_lock(&resource->resource_lock); | 838 | mutex_lock(&resource->resource_lock); |
937 | 839 | ||
938 | result = acpi_power_get_state(resource->device.handle, &state); | 840 | result = acpi_power_get_state(resource->device.handle, &state); |
939 | if (result) | 841 | if (result) { |
842 | mutex_unlock(&resource->resource_lock); | ||
940 | continue; | 843 | continue; |
844 | } | ||
941 | 845 | ||
942 | if (state == ACPI_POWER_RESOURCE_STATE_OFF | 846 | if (state == ACPI_POWER_RESOURCE_STATE_OFF |
943 | && resource->ref_count) { | 847 | && resource->ref_count) { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 407ad13cac2f..fee8a297c7d9 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -999,7 +999,6 @@ int acpi_device_add(struct acpi_device *device, | |||
999 | INIT_LIST_HEAD(&device->wakeup_list); | 999 | INIT_LIST_HEAD(&device->wakeup_list); |
1000 | INIT_LIST_HEAD(&device->physical_node_list); | 1000 | INIT_LIST_HEAD(&device->physical_node_list); |
1001 | mutex_init(&device->physical_node_lock); | 1001 | mutex_init(&device->physical_node_lock); |
1002 | INIT_LIST_HEAD(&device->power_dependent); | ||
1003 | 1002 | ||
1004 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 1003 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
1005 | if (!new_bus_id) { | 1004 | if (!new_bus_id) { |