Lines Matching refs:resource

62 	struct acpi_power_resource *resource;  member
91 struct acpi_power_resource *resource = acpi_power_get_context(handle); in acpi_power_resources_list_add() local
94 if (!resource || !list) in acpi_power_resources_list_add()
101 entry->resource = resource; in acpi_power_resources_list_add()
106 if (e->resource->order > resource->order) { in acpi_power_resources_list_add()
218 struct acpi_power_resource *resource = entry->resource; in acpi_power_get_list_state() local
219 acpi_handle handle = resource->device.handle; in acpi_power_get_list_state()
222 mutex_lock(&resource->resource_lock); in acpi_power_get_list_state()
224 mutex_unlock(&resource->resource_lock); in acpi_power_get_list_state()
240 acpi_power_resource_add_dependent(struct acpi_power_resource *resource, in acpi_power_resource_add_dependent() argument
246 mutex_lock(&resource->resource_lock); in acpi_power_resource_add_dependent()
247 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_add_dependent()
260 list_add_tail(&dep->node, &resource->dependents); in acpi_power_resource_add_dependent()
261 dev_dbg(dev, "added power dependency to [%s]\n", resource->name); in acpi_power_resource_add_dependent()
264 mutex_unlock(&resource->resource_lock); in acpi_power_resource_add_dependent()
269 acpi_power_resource_remove_dependent(struct acpi_power_resource *resource, in acpi_power_resource_remove_dependent() argument
274 mutex_lock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
275 list_for_each_entry(dep, &resource->dependents, node) { in acpi_power_resource_remove_dependent()
280 resource->name); in acpi_power_resource_remove_dependent()
284 mutex_unlock(&resource->resource_lock); in acpi_power_resource_remove_dependent()
314 ret = acpi_power_resource_add_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
323 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_add_dependent()
348 acpi_power_resource_remove_dependent(entry->resource, dev); in acpi_device_power_remove_dependent()
351 static int __acpi_power_on(struct acpi_power_resource *resource) in __acpi_power_on() argument
356 status = acpi_evaluate_object(resource->device.handle, "_ON", NULL, NULL); in __acpi_power_on()
361 resource->name)); in __acpi_power_on()
368 if (list_empty(&resource->dependents) || in __acpi_power_on()
369 list_is_singular(&resource->dependents)) in __acpi_power_on()
372 list_for_each_entry(dep, &resource->dependents, node) { in __acpi_power_on()
374 resource->name); in __acpi_power_on()
381 static int acpi_power_on_unlocked(struct acpi_power_resource *resource) in acpi_power_on_unlocked() argument
385 if (resource->ref_count++) { in acpi_power_on_unlocked()
388 resource->name)); in acpi_power_on_unlocked()
390 result = __acpi_power_on(resource); in acpi_power_on_unlocked()
392 resource->ref_count--; in acpi_power_on_unlocked()
397 static int acpi_power_on(struct acpi_power_resource *resource) in acpi_power_on() argument
401 mutex_lock(&resource->resource_lock); in acpi_power_on()
402 result = acpi_power_on_unlocked(resource); in acpi_power_on()
403 mutex_unlock(&resource->resource_lock); in acpi_power_on()
407 static int __acpi_power_off(struct acpi_power_resource *resource) in __acpi_power_off() argument
411 status = acpi_evaluate_object(resource->device.handle, "_OFF", in __acpi_power_off()
417 resource->name)); in __acpi_power_off()
421 static int acpi_power_off_unlocked(struct acpi_power_resource *resource) in acpi_power_off_unlocked() argument
425 if (!resource->ref_count) { in acpi_power_off_unlocked()
428 resource->name)); in acpi_power_off_unlocked()
432 if (--resource->ref_count) { in acpi_power_off_unlocked()
435 resource->name)); in acpi_power_off_unlocked()
437 result = __acpi_power_off(resource); in acpi_power_off_unlocked()
439 resource->ref_count++; in acpi_power_off_unlocked()
444 static int acpi_power_off(struct acpi_power_resource *resource) in acpi_power_off() argument
448 mutex_lock(&resource->resource_lock); in acpi_power_off()
449 result = acpi_power_off_unlocked(resource); in acpi_power_off()
450 mutex_unlock(&resource->resource_lock); in acpi_power_off()
460 result = acpi_power_off(entry->resource); in acpi_power_off_list()
468 acpi_power_on(entry->resource); in acpi_power_off_list()
479 result = acpi_power_on(entry->resource); in acpi_power_on_list()
487 acpi_power_off(entry->resource); in acpi_power_on_list()
530 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_hide_list()
554 struct acpi_device *res_dev = &entry->resource->device; in acpi_power_expose_list()
601 struct acpi_power_resource *resource = entry->resource; in acpi_power_wakeup_list_init() local
602 acpi_handle handle = resource->device.handle; in acpi_power_wakeup_list_init()
606 mutex_lock(&resource->resource_lock); in acpi_power_wakeup_list_init()
610 mutex_unlock(&resource->resource_lock); in acpi_power_wakeup_list_init()
614 resource->ref_count++; in acpi_power_wakeup_list_init()
615 resource->wakeup_enabled = true; in acpi_power_wakeup_list_init()
617 if (system_level > resource->system_level) in acpi_power_wakeup_list_init()
618 system_level = resource->system_level; in acpi_power_wakeup_list_init()
620 mutex_unlock(&resource->resource_lock); in acpi_power_wakeup_list_init()
711 struct acpi_power_resource *resource = entry->resource; in acpi_enable_wakeup_device_power() local
713 mutex_lock(&resource->resource_lock); in acpi_enable_wakeup_device_power()
715 if (!resource->wakeup_enabled) { in acpi_enable_wakeup_device_power()
716 err = acpi_power_on_unlocked(resource); in acpi_enable_wakeup_device_power()
718 resource->wakeup_enabled = true; in acpi_enable_wakeup_device_power()
721 mutex_unlock(&resource->resource_lock); in acpi_enable_wakeup_device_power()
774 struct acpi_power_resource *resource = entry->resource; in acpi_disable_wakeup_device_power() local
776 mutex_lock(&resource->resource_lock); in acpi_disable_wakeup_device_power()
778 if (resource->wakeup_enabled) { in acpi_disable_wakeup_device_power()
779 err = acpi_power_off_unlocked(resource); in acpi_disable_wakeup_device_power()
781 resource->wakeup_enabled = false; in acpi_disable_wakeup_device_power()
784 mutex_unlock(&resource->resource_lock); in acpi_disable_wakeup_device_power()
877 struct acpi_power_resource *resource; in acpi_release_power_resource() local
879 resource = container_of(device, struct acpi_power_resource, device); in acpi_release_power_resource()
882 list_del(&resource->list_node); in acpi_release_power_resource()
886 kfree(resource); in acpi_release_power_resource()
892 struct acpi_power_resource *resource; in acpi_power_in_use_show() local
894 resource = to_power_resource(to_acpi_device(dev)); in acpi_power_in_use_show()
895 return sprintf(buf, "%u\n", !!resource->ref_count); in acpi_power_in_use_show()
904 static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource) in acpi_power_add_resource_to_list() argument
912 if (r->order > resource->order) { in acpi_power_add_resource_to_list()
913 list_add_tail(&resource->list_node, &r->list_node); in acpi_power_add_resource_to_list()
917 list_add_tail(&resource->list_node, &acpi_power_resource_list); in acpi_power_add_resource_to_list()
925 struct acpi_power_resource *resource; in acpi_add_power_resource() local
936 resource = kzalloc(sizeof(*resource), GFP_KERNEL); in acpi_add_power_resource()
937 if (!resource) in acpi_add_power_resource()
940 device = &resource->device; in acpi_add_power_resource()
943 mutex_init(&resource->resource_lock); in acpi_add_power_resource()
944 INIT_LIST_HEAD(&resource->list_node); in acpi_add_power_resource()
945 INIT_LIST_HEAD(&resource->dependents); in acpi_add_power_resource()
946 resource->name = device->pnp.bus_id; in acpi_add_power_resource()
956 resource->system_level = acpi_object.power_resource.system_level; in acpi_add_power_resource()
957 resource->order = acpi_object.power_resource.resource_order; in acpi_add_power_resource()
974 acpi_power_add_resource_to_list(resource); in acpi_add_power_resource()
986 struct acpi_power_resource *resource; in acpi_resume_power_resources() local
990 list_for_each_entry(resource, &acpi_power_resource_list, list_node) { in acpi_resume_power_resources()
993 mutex_lock(&resource->resource_lock); in acpi_resume_power_resources()
995 result = acpi_power_get_state(resource->device.handle, &state); in acpi_resume_power_resources()
997 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1002 && resource->ref_count) { in acpi_resume_power_resources()
1003 dev_info(&resource->device.dev, "Turning ON\n"); in acpi_resume_power_resources()
1004 __acpi_power_on(resource); in acpi_resume_power_resources()
1007 mutex_unlock(&resource->resource_lock); in acpi_resume_power_resources()
1015 struct acpi_power_resource *resource; in acpi_turn_off_unused_power_resources() local
1019 list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) { in acpi_turn_off_unused_power_resources()
1022 mutex_lock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()
1024 result = acpi_power_get_state(resource->device.handle, &state); in acpi_turn_off_unused_power_resources()
1026 mutex_unlock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()
1031 && !resource->ref_count) { in acpi_turn_off_unused_power_resources()
1032 dev_info(&resource->device.dev, "Turning OFF\n"); in acpi_turn_off_unused_power_resources()
1033 __acpi_power_off(resource); in acpi_turn_off_unused_power_resources()
1036 mutex_unlock(&resource->resource_lock); in acpi_turn_off_unused_power_resources()