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()
778 ret = acpi_power_off(entry->resource); in acpi_disable_wakeup_device_power()
870 struct acpi_power_resource *resource; in acpi_release_power_resource() local
872 resource = container_of(device, struct acpi_power_resource, device); in acpi_release_power_resource()
875 list_del(&resource->list_node); in acpi_release_power_resource()
879 kfree(resource); in acpi_release_power_resource()
886 struct acpi_power_resource *resource; in resource_in_use_show() local
888 resource = to_power_resource(to_acpi_device(dev)); in resource_in_use_show()
889 return sprintf(buf, "%u\n", !!resource->ref_count); in resource_in_use_show()
898 static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource) in acpi_power_add_resource_to_list() argument
906 if (r->order > resource->order) { in acpi_power_add_resource_to_list()
907 list_add_tail(&resource->list_node, &r->list_node); in acpi_power_add_resource_to_list()
911 list_add_tail(&resource->list_node, &acpi_power_resource_list); in acpi_power_add_resource_to_list()
919 struct acpi_power_resource *resource; in acpi_add_power_resource() local
931 resource = kzalloc(sizeof(*resource), GFP_KERNEL); in acpi_add_power_resource()
932 if (!resource) in acpi_add_power_resource()
935 device = &resource->device; in acpi_add_power_resource()
937 mutex_init(&resource->resource_lock); in acpi_add_power_resource()
938 INIT_LIST_HEAD(&resource->list_node); in acpi_add_power_resource()
939 INIT_LIST_HEAD(&resource->dependents); in acpi_add_power_resource()
949 resource->system_level = acpi_object.power_resource.system_level; in acpi_add_power_resource()
950 resource->order = acpi_object.power_resource.resource_order; in acpi_add_power_resource()
951 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_add_power_resource()
954 if (acpi_power_get_state(resource, &state_dummy)) in acpi_add_power_resource()
955 __acpi_power_on(resource); in acpi_add_power_resource()
967 acpi_power_add_resource_to_list(resource); in acpi_add_power_resource()
979 struct acpi_power_resource *resource; in acpi_resume_power_resources() local
983 list_for_each_entry(resource, &acpi_power_resource_list, list_node) { in acpi_resume_power_resources()
987 mutex_lock(&resource->resource_lock); in acpi_resume_power_resources()
989 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_resume_power_resources()
990 result = acpi_power_get_state(resource, &state); in acpi_resume_power_resources()
992 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
997 && resource->ref_count) { in acpi_resume_power_resources()
998 acpi_handle_debug(resource->device.handle, "Turning ON\n"); in acpi_resume_power_resources()
999 __acpi_power_on(resource); in acpi_resume_power_resources()
1002 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1014 struct acpi_power_resource *resource; in acpi_turn_off_unused_power_resources() local
1018 list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) { in acpi_turn_off_unused_power_resources()
1019 mutex_lock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()
1021 if (!resource->ref_count && in acpi_turn_off_unused_power_resources()
1022 resource->state == ACPI_POWER_RESOURCE_STATE_ON) { in acpi_turn_off_unused_power_resources()
1023 acpi_handle_debug(resource->device.handle, "Turning OFF\n"); in acpi_turn_off_unused_power_resources()
1024 __acpi_power_off(resource); in acpi_turn_off_unused_power_resources()
1027 mutex_unlock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()