2 * Copyright (c) 2001 Michael Smith
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/kernel.h>
33 #include <sys/malloc.h>
36 #include <contrib/dev/acpica/include/acpi.h>
37 #include <contrib/dev/acpica/include/accommon.h>
39 #include <dev/acpica/acpivar.h>
42 * ACPI power resource management.
44 * Power resource behaviour is slightly complicated by the fact that
45 * a single power resource may provide power for more than one device.
46 * Thus, we must track the device(s) being powered by a given power
47 * resource, and only deactivate it when there are no powered devices.
49 * Note that this only manages resources for known devices. There is an
50 * ugly case where we may turn off power to a device which is in use because
51 * we don't know that it depends on a given resource. We should perhaps
52 * try to be smarter about this, but a more complete solution would involve
53 * scanning all of the ACPI namespace to find devices we're not currently
54 * aware of, and this raises questions about whether they should be left
55 * on, turned off, etc.
58 static MALLOC_DEFINE(M_ACPIPWR, "acpipwr", "ACPI power resources");
60 /* Hooks for the ACPI CA debugging infrastructure */
61 #define _COMPONENT ACPI_POWERRES
62 ACPI_MODULE_NAME("POWERRES")
64 /* Return values from _STA on a power resource */
65 #define ACPI_PWR_OFF 0
68 /* A relationship between a power resource and a consumer. */
69 struct acpi_powerreference {
70 struct acpi_powerconsumer *ar_consumer;
71 struct acpi_powerresource *ar_resource;
72 TAILQ_ENTRY(acpi_powerreference) ar_rlink; /* link on resource list */
73 TAILQ_ENTRY(acpi_powerreference) ar_clink; /* link on consumer */
76 /* A power-managed device. */
77 struct acpi_powerconsumer {
78 /* Device which is powered */
79 ACPI_HANDLE ac_consumer;
81 TAILQ_ENTRY(acpi_powerconsumer) ac_link;
82 TAILQ_HEAD(,acpi_powerreference) ac_references;
85 /* A power resource. */
86 struct acpi_powerresource {
87 TAILQ_ENTRY(acpi_powerresource) ap_link;
88 TAILQ_HEAD(,acpi_powerreference) ap_references;
89 ACPI_HANDLE ap_resource;
90 UINT64 ap_systemlevel;
94 static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource)
96 static TAILQ_HEAD(acpi_powerconsumer_list, acpi_powerconsumer)
98 ACPI_SERIAL_DECL(powerres, "ACPI power resources");
100 static ACPI_STATUS acpi_pwr_register_consumer(ACPI_HANDLE consumer);
102 static ACPI_STATUS acpi_pwr_deregister_consumer(ACPI_HANDLE consumer);
104 static ACPI_STATUS acpi_pwr_register_resource(ACPI_HANDLE res);
106 static ACPI_STATUS acpi_pwr_deregister_resource(ACPI_HANDLE res);
108 static void acpi_pwr_reference_resource(ACPI_OBJECT *obj,
110 static int acpi_pwr_dereference_resource(struct acpi_powerconsumer
112 static ACPI_STATUS acpi_pwr_switch_power(void);
113 static struct acpi_powerresource
114 *acpi_pwr_find_resource(ACPI_HANDLE res);
115 static struct acpi_powerconsumer
116 *acpi_pwr_find_consumer(ACPI_HANDLE consumer);
118 /* Initialise our lists. */
120 acpi_pwr_init(void *junk)
122 TAILQ_INIT(&acpi_powerresources);
123 TAILQ_INIT(&acpi_powerconsumers);
125 SYSINIT(acpi_powerresource, SI_SUB_TUNABLES, SI_ORDER_ANY, acpi_pwr_init, NULL);
128 * Register a power resource.
130 * It's OK to call this if we already know about the resource.
133 acpi_pwr_register_resource(ACPI_HANDLE res)
138 struct acpi_powerresource *rp, *srp;
140 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
141 ACPI_SERIAL_ASSERT(powerres);
146 /* Look to see if we know about this resource */
147 if (acpi_pwr_find_resource(res) != NULL)
148 return_ACPI_STATUS (AE_OK); /* already know about it */
150 /* Allocate a new resource */
151 if ((rp = malloc(sizeof(*rp), M_ACPIPWR, M_NOWAIT | M_ZERO)) == NULL) {
152 status = AE_NO_MEMORY;
155 TAILQ_INIT(&rp->ap_references);
156 rp->ap_resource = res;
158 /* Get the Power Resource object */
159 buf.Length = ACPI_ALLOCATE_BUFFER;
160 if (ACPI_FAILURE(status = AcpiEvaluateObject(res, NULL, NULL, &buf))) {
161 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "no power resource object\n"));
165 if (obj->Type != ACPI_TYPE_POWER) {
166 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
167 "questionable power resource object %s\n",
172 rp->ap_systemlevel = obj->PowerResource.SystemLevel;
173 rp->ap_order = obj->PowerResource.ResourceOrder;
175 /* Sort the resource into the list */
177 srp = TAILQ_FIRST(&acpi_powerresources);
178 if (srp == NULL || rp->ap_order < srp->ap_order) {
179 TAILQ_INSERT_HEAD(&acpi_powerresources, rp, ap_link);
182 TAILQ_FOREACH(srp, &acpi_powerresources, ap_link) {
183 if (rp->ap_order < srp->ap_order) {
184 TAILQ_INSERT_BEFORE(srp, rp, ap_link);
188 TAILQ_INSERT_TAIL(&acpi_powerresources, rp, ap_link);
191 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
192 "registered power resource %s\n", acpi_name(res)));
195 if (buf.Pointer != NULL)
196 AcpiOsFree(buf.Pointer);
197 if (ACPI_FAILURE(status) && rp != NULL)
199 return_ACPI_STATUS (status);
204 * Deregister a power resource.
207 acpi_pwr_deregister_resource(ACPI_HANDLE res)
209 struct acpi_powerresource *rp;
211 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
212 ACPI_SERIAL_ASSERT(powerres);
216 /* Find the resource */
217 if ((rp = acpi_pwr_find_resource(res)) == NULL)
218 return_ACPI_STATUS (AE_BAD_PARAMETER);
220 /* Check that there are no consumers referencing this resource */
221 if (TAILQ_FIRST(&rp->ap_references) != NULL)
222 return_ACPI_STATUS (AE_BAD_PARAMETER);
224 /* Pull it off the list and free it */
225 TAILQ_REMOVE(&acpi_powerresources, rp, ap_link);
228 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "deregistered power resource %s\n",
231 return_ACPI_STATUS (AE_OK);
236 * Register a power consumer.
238 * It's OK to call this if we already know about the consumer.
241 acpi_pwr_register_consumer(ACPI_HANDLE consumer)
243 struct acpi_powerconsumer *pc;
245 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
246 ACPI_SERIAL_ASSERT(powerres);
248 /* Check to see whether we know about this consumer already */
249 if (acpi_pwr_find_consumer(consumer) != NULL)
250 return_ACPI_STATUS (AE_OK);
252 /* Allocate a new power consumer */
253 if ((pc = malloc(sizeof(*pc), M_ACPIPWR, M_NOWAIT)) == NULL)
254 return_ACPI_STATUS (AE_NO_MEMORY);
255 TAILQ_INSERT_HEAD(&acpi_powerconsumers, pc, ac_link);
256 TAILQ_INIT(&pc->ac_references);
257 pc->ac_consumer = consumer;
259 /* XXX we should try to find its current state */
260 pc->ac_state = ACPI_STATE_UNKNOWN;
262 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "registered power consumer %s\n",
263 acpi_name(consumer)));
265 return_ACPI_STATUS (AE_OK);
270 * Deregister a power consumer.
272 * This should only be done once the consumer has been powered off.
273 * (XXX is this correct? Check once implemented)
276 acpi_pwr_deregister_consumer(ACPI_HANDLE consumer)
278 struct acpi_powerconsumer *pc;
280 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
281 ACPI_SERIAL_ASSERT(powerres);
283 /* Find the consumer */
284 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL)
285 return_ACPI_STATUS (AE_BAD_PARAMETER);
287 /* Make sure the consumer's not referencing anything right now */
288 if (TAILQ_FIRST(&pc->ac_references) != NULL)
289 return_ACPI_STATUS (AE_BAD_PARAMETER);
291 /* Pull the consumer off the list and free it */
292 TAILQ_REMOVE(&acpi_powerconsumers, pc, ac_link);
295 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "deregistered power consumer %s\n",
296 acpi_name(consumer)));
298 return_ACPI_STATUS (AE_OK);
303 * Set a power consumer to a particular power state.
306 acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
308 struct acpi_powerconsumer *pc;
309 ACPI_HANDLE method_handle, reslist_handle, pr0_handle;
310 ACPI_BUFFER reslist_buffer;
311 ACPI_OBJECT *reslist_object;
313 char *method_name, *reslist_name;
315 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
317 /* It's never ok to switch a non-existent consumer. */
318 if (consumer == NULL)
319 return_ACPI_STATUS (AE_NOT_FOUND);
320 reslist_buffer.Pointer = NULL;
321 reslist_object = NULL;
322 ACPI_SERIAL_BEGIN(powerres);
324 /* Find the consumer */
325 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
326 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer)))
328 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL)
329 panic("acpi added power consumer but can't find it");
332 /* Check for valid transitions. We can only go to D0 from D3. */
333 status = AE_BAD_PARAMETER;
334 if (pc->ac_state == ACPI_STATE_D3 && state != ACPI_STATE_D0)
337 /* Find transition mechanism(s) */
340 method_name = "_PS0";
341 reslist_name = "_PR0";
344 method_name = "_PS1";
345 reslist_name = "_PR1";
348 method_name = "_PS2";
349 reslist_name = "_PR2";
352 method_name = "_PS3";
353 reslist_name = "_PR3";
358 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "setup to switch %s D%d -> D%d\n",
359 acpi_name(consumer), pc->ac_state, state));
362 * Verify that this state is supported, ie. one of method or
363 * reslist must be present. We need to do this before we go
364 * dereferencing resources (since we might be trying to go to
365 * a state we don't support).
367 * Note that if any states are supported, the device has to
368 * support D0 and D3. It's never an error to try to go to
371 if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle)))
372 method_handle = NULL;
373 if (ACPI_FAILURE(AcpiGetHandle(consumer, reslist_name, &reslist_handle)))
374 reslist_handle = NULL;
375 if (reslist_handle == NULL && method_handle == NULL) {
376 if (state == ACPI_STATE_D0) {
377 pc->ac_state = ACPI_STATE_D0;
381 if (state != ACPI_STATE_D3) {
382 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
383 "attempt to set unsupported state D%d\n", state));
388 * Turn off the resources listed in _PR0 to go to D3. If there is
389 * no _PR0 method, this object doesn't support ACPI power states.
391 if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle))) {
392 status = AE_NOT_FOUND;
393 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
394 "device missing _PR0 (desired state was D%d)\n", state));
397 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER;
398 status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer);
399 if (ACPI_FAILURE(status)) {
400 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
401 "can't evaluate _PR0 for device %s, state D%d\n",
402 acpi_name(consumer), state));
405 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer;
406 if (!ACPI_PKG_VALID(reslist_object, 1)) {
407 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
408 "invalid package object for state D%d\n", state));
412 AcpiOsFree(reslist_buffer.Pointer);
413 reslist_buffer.Pointer = NULL;
414 reslist_object = NULL;
418 * Check that we can actually fetch the list of power resources
420 if (reslist_handle != NULL) {
421 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER;
422 status = AcpiEvaluateObject(reslist_handle, NULL, NULL,
424 if (ACPI_FAILURE(status)) {
425 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
426 "can't evaluate resource list %s\n",
427 acpi_name(reslist_handle)));
430 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer;
431 if (reslist_object->Type != ACPI_TYPE_PACKAGE) {
432 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
433 "resource list is not ACPI_TYPE_PACKAGE (%d)\n",
434 reslist_object->Type));
441 * Now we are ready to switch, so kill off any current power
442 * resource references.
444 acpi_pwr_dereference_resource(pc);
447 * Add new power resource references, if we have any. Traverse the
448 * package that we got from evaluating reslist_handle, and look up each
449 * of the resources that are referenced.
451 if (reslist_object != NULL) {
452 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "referencing %d new resources\n",
453 reslist_object->Package.Count));
454 acpi_ForeachPackageObject(reslist_object, acpi_pwr_reference_resource,
459 * If we changed anything in the resource list, we need to run a switch
462 if (ACPI_FAILURE(status = acpi_pwr_switch_power())) {
463 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
464 "failed to switch resources from %s to D%d\n",
465 acpi_name(consumer), state));
467 /* XXX is this appropriate? Should we return to previous state? */
471 /* Invoke power state switch method (if present) */
472 if (method_handle != NULL) {
473 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
474 "invoking state transition method %s\n",
475 acpi_name(method_handle)));
476 status = AcpiEvaluateObject(method_handle, NULL, NULL, NULL);
477 if (ACPI_FAILURE(status)) {
478 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "failed to set state - %s\n",
479 AcpiFormatException(status)));
480 pc->ac_state = ACPI_STATE_UNKNOWN;
482 /* XXX Should we return to previous state? */
487 /* Transition was successful */
488 pc->ac_state = state;
492 ACPI_SERIAL_END(powerres);
493 if (reslist_buffer.Pointer != NULL)
494 AcpiOsFree(reslist_buffer.Pointer);
495 return_ACPI_STATUS (status);
498 /* Enable or disable a power resource for wake */
500 acpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable)
503 struct acpi_powerconsumer *pc;
504 struct acpi_prw_data prw;
507 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
509 if (consumer == NULL)
510 return (AE_BAD_PARAMETER);
512 ACPI_SERIAL_BEGIN(powerres);
513 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
514 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer)))
516 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL)
517 panic("acpi wake added power consumer but can't find it");
521 if (acpi_parse_prw(consumer, &prw) != 0)
523 for (i = 0; i < prw.power_res_count; i++)
525 acpi_pwr_reference_resource(&prw.power_res[i], pc);
527 acpi_pwr_dereference_resource(pc);
529 if (prw.power_res_count > 0)
530 acpi_pwr_switch_power();
533 ACPI_SERIAL_END(powerres);
538 * Called to create a reference between a power consumer and a power resource
539 * identified in the object.
542 acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg)
544 struct acpi_powerconsumer *pc = (struct acpi_powerconsumer *)arg;
545 struct acpi_powerreference *pr;
546 struct acpi_powerresource *rp;
550 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
551 ACPI_SERIAL_ASSERT(powerres);
553 res = acpi_GetReference(NULL, obj);
555 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
556 "can't create a power reference for object type %d\n",
561 /* Create/look up the resource */
562 if (ACPI_FAILURE(status = acpi_pwr_register_resource(res))) {
563 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
564 "couldn't register power resource %s - %s\n",
565 obj->String.Pointer, AcpiFormatException(status)));
568 if ((rp = acpi_pwr_find_resource(res)) == NULL) {
569 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "power resource list corrupted\n"));
572 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "found power resource %s\n",
573 acpi_name(rp->ap_resource)));
575 /* Create a reference between the consumer and resource */
576 if ((pr = malloc(sizeof(*pr), M_ACPIPWR, M_NOWAIT | M_ZERO)) == NULL) {
577 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
578 "allocation failed for a power consumer reference\n"));
581 pr->ar_consumer = pc;
582 pr->ar_resource = rp;
583 TAILQ_INSERT_TAIL(&pc->ac_references, pr, ar_clink);
584 TAILQ_INSERT_TAIL(&rp->ap_references, pr, ar_rlink);
590 acpi_pwr_dereference_resource(struct acpi_powerconsumer *pc)
592 struct acpi_powerreference *pr;
595 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
596 ACPI_SERIAL_ASSERT(powerres);
599 while ((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
600 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n",
601 acpi_name(pr->ar_resource->ap_resource)));
602 TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink);
603 TAILQ_REMOVE(&pc->ac_references, pr, ar_clink);
612 * Switch power resources to conform to the desired state.
614 * Consumers may have modified the power resource list in an arbitrary
615 * fashion; we sweep it in sequence order.
618 acpi_pwr_switch_power(void)
620 struct acpi_powerresource *rp;
624 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
625 ACPI_SERIAL_ASSERT(powerres);
628 * Sweep the list forwards turning things on.
630 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) {
631 if (TAILQ_FIRST(&rp->ap_references) == NULL) {
632 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
633 "%s has no references, not turning on\n",
634 acpi_name(rp->ap_resource)));
638 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
639 if (ACPI_FAILURE(status)) {
640 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
641 acpi_name(rp->ap_resource), status));
642 /* XXX is this correct? Always switch if in doubt? */
647 * Switch if required. Note that we ignore the result of the switch
648 * effort; we don't know what to do if it fails, so checking wouldn't
651 if (cur != ACPI_PWR_ON) {
652 status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL);
653 if (ACPI_FAILURE(status)) {
654 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
655 "failed to switch %s on - %s\n",
656 acpi_name(rp->ap_resource),
657 AcpiFormatException(status)));
659 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s on\n",
660 acpi_name(rp->ap_resource)));
663 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already on\n",
664 acpi_name(rp->ap_resource)));
668 /* Sweep the list backwards turning things off. */
669 TAILQ_FOREACH_REVERSE(rp, &acpi_powerresources, acpi_powerresource_list,
672 if (TAILQ_FIRST(&rp->ap_references) != NULL) {
673 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
674 "%s has references, not turning off\n",
675 acpi_name(rp->ap_resource)));
679 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
680 if (ACPI_FAILURE(status)) {
681 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
682 acpi_name(rp->ap_resource), status));
683 /* XXX is this correct? Always switch if in doubt? */
688 * Switch if required. Note that we ignore the result of the switch
689 * effort; we don't know what to do if it fails, so checking wouldn't
692 if (cur != ACPI_PWR_OFF) {
693 status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL);
694 if (ACPI_FAILURE(status)) {
695 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
696 "failed to switch %s off - %s\n",
697 acpi_name(rp->ap_resource),
698 AcpiFormatException(status)));
700 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s off\n",
701 acpi_name(rp->ap_resource)));
704 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already off\n",
705 acpi_name(rp->ap_resource)));
709 return_ACPI_STATUS (AE_OK);
713 * Find a power resource's control structure.
715 static struct acpi_powerresource *
716 acpi_pwr_find_resource(ACPI_HANDLE res)
718 struct acpi_powerresource *rp;
720 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
721 ACPI_SERIAL_ASSERT(powerres);
723 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) {
724 if (rp->ap_resource == res)
732 * Find a power consumer's control structure.
734 static struct acpi_powerconsumer *
735 acpi_pwr_find_consumer(ACPI_HANDLE consumer)
737 struct acpi_powerconsumer *pc;
739 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
740 ACPI_SERIAL_ASSERT(powerres);
742 TAILQ_FOREACH(pc, &acpi_powerconsumers, ac_link) {
743 if (pc->ac_consumer == consumer)