Lines Matching refs:resource
62 struct acpi_power_resource *resource; member
96 struct acpi_power_resource *resource = acpi_power_get_context(handle); in acpi_power_resources_list_add() local
99 if (!resource || !list) in acpi_power_resources_list_add()
106 entry->resource = resource; in acpi_power_resources_list_add()
111 if (e->resource->order > resource->order) { in acpi_power_resources_list_add()
206 static int acpi_power_get_state(struct acpi_power_resource *resource, u8 *state) in acpi_power_get_state() argument
208 if (resource->state == ACPI_POWER_RESOURCE_STATE_UNKNOWN) { in acpi_power_get_state()
211 ret = __get_state(resource->device.handle, &resource->state); in acpi_power_get_state()
216 *state = resource->state; in acpi_power_get_state()
230 struct acpi_power_resource *resource = entry->resource; in acpi_power_get_list_state() local
233 mutex_lock(&resource->resource_lock); in acpi_power_get_list_state()
234 result = acpi_power_get_state(resource, &cur_state); in acpi_power_get_list_state()
235 mutex_unlock(&resource->resource_lock); in acpi_power_get_list_state()
250 acpi_power_resource_add_dependent(struct acpi_power_resource *resource, in acpi_power_resource_add_dependent() argument
256 mutex_lock(&resource->resource_lock); in acpi_power_resource_add_dependent()
257 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_add_dependent()
270 list_add_tail(&dep->node, &resource->dependents); in acpi_power_resource_add_dependent()
272 resource_dev_name(resource)); in acpi_power_resource_add_dependent()
275 mutex_unlock(&resource->resource_lock); in acpi_power_resource_add_dependent()
280 acpi_power_resource_remove_dependent(struct acpi_power_resource *resource, in acpi_power_resource_remove_dependent() argument
285 mutex_lock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
286 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_remove_dependent()
291 resource_dev_name(resource)); in acpi_power_resource_remove_dependent()
295 mutex_unlock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
325 ret = acpi_power_resource_add_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
334 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
359 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_remove_dependent()
362 static int __acpi_power_on(struct acpi_power_resource *resource) in __acpi_power_on() argument
364 acpi_handle handle = resource->device.handle; in __acpi_power_on()
370 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in __acpi_power_on()
374 resource->state = ACPI_POWER_RESOURCE_STATE_ON; in __acpi_power_on()
383 if (list_empty(&resource->dependents) || in __acpi_power_on()
384 list_is_singular(&resource->dependents)) in __acpi_power_on()
387 list_for_each_entry(dep, &resource->dependents, node) { in __acpi_power_on()
389 resource_dev_name(resource)); in __acpi_power_on()
396 static int acpi_power_on_unlocked(struct acpi_power_resource *resource) in acpi_power_on_unlocked() argument
400 if (resource->ref_count++) { in acpi_power_on_unlocked()
401 acpi_handle_debug(resource->device.handle, in acpi_power_on_unlocked()
404 result = __acpi_power_on(resource); in acpi_power_on_unlocked()
406 resource->ref_count--; in acpi_power_on_unlocked()
411 static int acpi_power_on(struct acpi_power_resource *resource) in acpi_power_on() argument
415 mutex_lock(&resource->resource_lock); in acpi_power_on()
416 result = acpi_power_on_unlocked(resource); in acpi_power_on()
417 mutex_unlock(&resource->resource_lock); in acpi_power_on()
421 static int __acpi_power_off(struct acpi_power_resource *resource) in __acpi_power_off() argument
423 acpi_handle handle = resource->device.handle; in __acpi_power_off()
428 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in __acpi_power_off()
432 resource->state = ACPI_POWER_RESOURCE_STATE_OFF; in __acpi_power_off()
439 static int acpi_power_off_unlocked(struct acpi_power_resource *resource) in acpi_power_off_unlocked() argument
443 if (!resource->ref_count) { in acpi_power_off_unlocked()
444 acpi_handle_debug(resource->device.handle, in acpi_power_off_unlocked()
449 if (--resource->ref_count) { in acpi_power_off_unlocked()
450 acpi_handle_debug(resource->device.handle, in acpi_power_off_unlocked()
453 result = __acpi_power_off(resource); in acpi_power_off_unlocked()
455 resource->ref_count++; in acpi_power_off_unlocked()
460 static int acpi_power_off(struct acpi_power_resource *resource) in acpi_power_off() argument
464 mutex_lock(&resource->resource_lock); in acpi_power_off()
465 result = acpi_power_off_unlocked(resource); in acpi_power_off()
466 mutex_unlock(&resource->resource_lock); in acpi_power_off()
476 result = acpi_power_off(entry->resource); in acpi_power_off_list()
484 acpi_power_on(entry->resource); in acpi_power_off_list()
495 result = acpi_power_on(entry->resource); in acpi_power_on_list()
503 acpi_power_off(entry->resource); in acpi_power_on_list()
546 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_hide_list()
570 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_expose_list()
617 struct acpi_power_resource *resource = entry->resource; in acpi_power_wakeup_list_init() local
620 mutex_lock(&resource->resource_lock); in acpi_power_wakeup_list_init()
626 if (!resource->ref_count && in acpi_power_wakeup_list_init()
627 !acpi_power_get_state(resource, &state) && in acpi_power_wakeup_list_init()
629 __acpi_power_off(resource); in acpi_power_wakeup_list_init()
631 if (system_level > resource->system_level) in acpi_power_wakeup_list_init()
632 system_level = resource->system_level; in acpi_power_wakeup_list_init()
634 mutex_unlock(&resource->resource_lock); in acpi_power_wakeup_list_init()
788 ret = acpi_power_off(entry->resource); in acpi_disable_wakeup_device_power()
883 struct acpi_power_resource *resource; in acpi_release_power_resource() local
885 resource = container_of(device, struct acpi_power_resource, device); in acpi_release_power_resource()
888 list_del(&resource->list_node); in acpi_release_power_resource()
892 kfree(resource); in acpi_release_power_resource()
899 struct acpi_power_resource *resource; in resource_in_use_show() local
901 resource = to_power_resource(to_acpi_device(dev)); in resource_in_use_show()
902 return sprintf(buf, "%u\n", !!resource->ref_count); in resource_in_use_show()
911 static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource) in acpi_power_add_resource_to_list() argument
919 if (r->order > resource->order) { in acpi_power_add_resource_to_list()
920 list_add_tail(&resource->list_node, &r->list_node); in acpi_power_add_resource_to_list()
924 list_add_tail(&resource->list_node, &acpi_power_resource_list); in acpi_power_add_resource_to_list()
933 struct acpi_power_resource *resource; in acpi_add_power_resource() local
943 resource = kzalloc(sizeof(*resource), GFP_KERNEL); in acpi_add_power_resource()
944 if (!resource) in acpi_add_power_resource()
947 device = &resource->device; in acpi_add_power_resource()
950 mutex_init(&resource->resource_lock); in acpi_add_power_resource()
951 INIT_LIST_HEAD(&resource->list_node); in acpi_add_power_resource()
952 INIT_LIST_HEAD(&resource->dependents); in acpi_add_power_resource()
963 resource->system_level = acpi_object.power_resource.system_level; in acpi_add_power_resource()
964 resource->order = acpi_object.power_resource.resource_order; in acpi_add_power_resource()
965 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_add_power_resource()
968 if (acpi_power_get_state(resource, &state_dummy)) in acpi_add_power_resource()
969 __acpi_power_on(resource); in acpi_add_power_resource()
984 acpi_power_add_resource_to_list(resource); in acpi_add_power_resource()
996 struct acpi_power_resource *resource; in acpi_resume_power_resources() local
1000 list_for_each_entry(resource, &acpi_power_resource_list, list_node) { in acpi_resume_power_resources()
1004 mutex_lock(&resource->resource_lock); in acpi_resume_power_resources()
1006 resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; in acpi_resume_power_resources()
1007 result = acpi_power_get_state(resource, &state); in acpi_resume_power_resources()
1009 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1014 && resource->ref_count) { in acpi_resume_power_resources()
1015 acpi_handle_debug(resource->device.handle, "Turning ON\n"); in acpi_resume_power_resources()
1016 __acpi_power_on(resource); in acpi_resume_power_resources()
1019 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1046 struct acpi_power_resource *resource; in acpi_turn_off_unused_power_resources() local
1053 list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) { in acpi_turn_off_unused_power_resources()
1054 mutex_lock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()
1056 if (!resource->ref_count && in acpi_turn_off_unused_power_resources()
1057 resource->state == ACPI_POWER_RESOURCE_STATE_ON) { in acpi_turn_off_unused_power_resources()
1058 acpi_handle_debug(resource->device.handle, "Turning OFF\n"); in acpi_turn_off_unused_power_resources()
1059 __acpi_power_off(resource); in acpi_turn_off_unused_power_resources()
1062 mutex_unlock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()