Lines Matching refs:resource
61 struct acpi_power_resource *resource; member
95 struct acpi_power_resource *resource = acpi_power_get_context(handle); in acpi_power_resources_list_add() local
98 if (!resource || !list) in acpi_power_resources_list_add()
105 entry->resource = resource; in acpi_power_resources_list_add()
110 if (e->resource->order > resource->order) { in acpi_power_resources_list_add()
205 static int acpi_power_get_state(struct acpi_power_resource *resource, u8 *state) in acpi_power_get_state() argument
207 if (resource->state == ACPI_POWER_RESOURCE_STATE_UNKNOWN) { in acpi_power_get_state()
210 ret = __get_state(resource->device.handle, &resource->state); in acpi_power_get_state()
215 *state = resource->state; in acpi_power_get_state()
229 struct acpi_power_resource *resource = entry->resource; in acpi_power_get_list_state() local
232 mutex_lock(&resource->resource_lock); in acpi_power_get_list_state()
233 result = acpi_power_get_state(resource, &cur_state); in acpi_power_get_list_state()
234 mutex_unlock(&resource->resource_lock); in acpi_power_get_list_state()
249 acpi_power_resource_add_dependent(struct acpi_power_resource *resource, in acpi_power_resource_add_dependent() argument
255 mutex_lock(&resource->resource_lock); in acpi_power_resource_add_dependent()
256 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_add_dependent()
269 list_add_tail(&dep->node, &resource->dependents); in acpi_power_resource_add_dependent()
271 resource_dev_name(resource)); in acpi_power_resource_add_dependent()
274 mutex_unlock(&resource->resource_lock); in acpi_power_resource_add_dependent()
279 acpi_power_resource_remove_dependent(struct acpi_power_resource *resource, in acpi_power_resource_remove_dependent() argument
284 mutex_lock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
285 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_remove_dependent()
290 resource_dev_name(resource)); in acpi_power_resource_remove_dependent()
294 mutex_unlock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
324 ret = acpi_power_resource_add_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
333 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
358 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_remove_dependent()
361 static int __acpi_power_on(struct acpi_power_resource *resource) in __acpi_power_on() argument
363 acpi_handle handle = resource->device.handle; in __acpi_power_on()
369 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in __acpi_power_on()
373 resource->state = ACPI_POWER_RESOURCE_STATE_ON; in __acpi_power_on()
382 if (list_empty(&resource->dependents) || in __acpi_power_on()
383 list_is_singular(&resource->dependents)) in __acpi_power_on()
386 list_for_each_entry(dep, &resource->dependents, node) { in __acpi_power_on()
388 resource_dev_name(resource)); in __acpi_power_on()
395 static int acpi_power_on_unlocked(struct acpi_power_resource *resource) in acpi_power_on_unlocked() argument
399 if (resource->ref_count++) { in acpi_power_on_unlocked()
400 acpi_handle_debug(resource->device.handle, in acpi_power_on_unlocked()
403 result = __acpi_power_on(resource); in acpi_power_on_unlocked()
405 resource->ref_count--; in acpi_power_on_unlocked()
410 static int acpi_power_on(struct acpi_power_resource *resource) in acpi_power_on() argument
414 mutex_lock(&resource->resource_lock); in acpi_power_on()
415 result = acpi_power_on_unlocked(resource); in acpi_power_on()
416 mutex_unlock(&resource->resource_lock); in acpi_power_on()
420 static int __acpi_power_off(struct acpi_power_resource *resource) in __acpi_power_off() argument
422 acpi_handle handle = resource->device.handle; in __acpi_power_off()
427 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in __acpi_power_off()
431 resource->state = ACPI_POWER_RESOURCE_STATE_OFF; in __acpi_power_off()
438 static int acpi_power_off_unlocked(struct acpi_power_resource *resource) in acpi_power_off_unlocked() argument
442 if (!resource->ref_count) { in acpi_power_off_unlocked()
443 acpi_handle_debug(resource->device.handle, in acpi_power_off_unlocked()
448 if (--resource->ref_count) { in acpi_power_off_unlocked()
449 acpi_handle_debug(resource->device.handle, in acpi_power_off_unlocked()
452 result = __acpi_power_off(resource); in acpi_power_off_unlocked()
454 resource->ref_count++; in acpi_power_off_unlocked()
459 static int acpi_power_off(struct acpi_power_resource *resource) in acpi_power_off() argument
463 mutex_lock(&resource->resource_lock); in acpi_power_off()
464 result = acpi_power_off_unlocked(resource); in acpi_power_off()
465 mutex_unlock(&resource->resource_lock); in acpi_power_off()
475 result = acpi_power_off(entry->resource); in acpi_power_off_list()
483 acpi_power_on(entry->resource); in acpi_power_off_list()
494 result = acpi_power_on(entry->resource); in acpi_power_on_list()
502 acpi_power_off(entry->resource); in acpi_power_on_list()
545 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_hide_list()
569 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_expose_list()
616 struct acpi_power_resource *resource = entry->resource; in acpi_power_wakeup_list_init() local
619 mutex_lock(&resource->resource_lock); in acpi_power_wakeup_list_init()
625 if (!resource->ref_count && in acpi_power_wakeup_list_init()
626 !acpi_power_get_state(resource, &state) && in acpi_power_wakeup_list_init()
628 __acpi_power_off(resource); in acpi_power_wakeup_list_init()
630 if (system_level > resource->system_level) in acpi_power_wakeup_list_init()
631 system_level = resource->system_level; in acpi_power_wakeup_list_init()
633 mutex_unlock(&resource->resource_lock); in acpi_power_wakeup_list_init()
787 ret = acpi_power_off(entry->resource); in acpi_disable_wakeup_device_power()
882 struct acpi_power_resource *resource; in acpi_release_power_resource() local
884 resource = container_of(device, struct acpi_power_resource, device); in acpi_release_power_resource()
887 list_del(&resource->list_node); in acpi_release_power_resource()
891 kfree(resource); in acpi_release_power_resource()
898 struct acpi_power_resource *resource; in resource_in_use_show() local
900 resource = to_power_resource(to_acpi_device(dev)); in resource_in_use_show()
901 return sprintf(buf, "%u\n", !!resource->ref_count); in resource_in_use_show()
910 static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource) in acpi_power_add_resource_to_list() argument
918 if (r->order > resource->order) { in acpi_power_add_resource_to_list()
919 list_add_tail(&resource->list_node, &r->list_node); in acpi_power_add_resource_to_list()
923 list_add_tail(&resource->list_node, &acpi_power_resource_list); in acpi_power_add_resource_to_list()
932 struct acpi_power_resource *resource; in acpi_add_power_resource() local
942 resource = kzalloc(sizeof(*resource), GFP_KERNEL); in acpi_add_power_resource()
943 if (!resource) in acpi_add_power_resource()
946 device = &resource->device; in acpi_add_power_resource()
949 mutex_init(&resource->resource_lock); in acpi_add_power_resource()
950 INIT_LIST_HEAD(&resource->list_node); in acpi_add_power_resource()
951 INIT_LIST_HEAD(&resource->dependents); in acpi_add_power_resource()
962 resource->system_level = acpi_object.power_resource.system_level; in acpi_add_power_resource()
963 resource->order = acpi_object.power_resource.resource_order; in acpi_add_power_resource()
964 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_add_power_resource()
967 if (acpi_power_get_state(resource, &state_dummy)) in acpi_add_power_resource()
968 __acpi_power_on(resource); in acpi_add_power_resource()
983 acpi_power_add_resource_to_list(resource); in acpi_add_power_resource()
995 struct acpi_power_resource *resource; in acpi_resume_power_resources() local
999 list_for_each_entry(resource, &acpi_power_resource_list, list_node) { in acpi_resume_power_resources()
1003 mutex_lock(&resource->resource_lock); in acpi_resume_power_resources()
1005 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_resume_power_resources()
1006 result = acpi_power_get_state(resource, &state); in acpi_resume_power_resources()
1008 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1013 && resource->ref_count) { in acpi_resume_power_resources()
1014 acpi_handle_debug(resource->device.handle, "Turning ON\n"); in acpi_resume_power_resources()
1015 __acpi_power_on(resource); in acpi_resume_power_resources()
1018 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1030 struct acpi_power_resource *resource; in acpi_turn_off_unused_power_resources() local
1034 list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) { in acpi_turn_off_unused_power_resources()
1035 mutex_lock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()
1037 if (!resource->ref_count && in acpi_turn_off_unused_power_resources()
1038 resource->state == ACPI_POWER_RESOURCE_STATE_ON) { in acpi_turn_off_unused_power_resources()
1039 acpi_handle_debug(resource->device.handle, "Turning OFF\n"); in acpi_turn_off_unused_power_resources()
1040 __acpi_power_off(resource); in acpi_turn_off_unused_power_resources()
1043 mutex_unlock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()