Deleted Added
full compact
acpi_powerres.c (91125) acpi_powerres.c (96926)
1/*-
2 * Copyright (c) 2001 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

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
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2001 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

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
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/acpica/acpi_powerres.c 91125 2002-02-23 05:28:22Z msmith $
26 * $FreeBSD: head/sys/dev/acpica/acpi_powerres.c 96926 2002-05-19 06:16:47Z peter $
27 */
28
29#include "opt_acpi.h" /* XXX trim includes */
30#include <sys/param.h>
31#include <sys/kernel.h>
32#include <sys/proc.h>
33#include <sys/lock.h>
34#include <sys/malloc.h>

--- 108 unchanged lines hidden (view full) ---

143static ACPI_STATUS
144acpi_pwr_register_resource(ACPI_HANDLE res)
145{
146 ACPI_STATUS status;
147 ACPI_BUFFER buf;
148 ACPI_OBJECT *obj;
149 struct acpi_powerresource *rp, *srp;
150
27 */
28
29#include "opt_acpi.h" /* XXX trim includes */
30#include <sys/param.h>
31#include <sys/kernel.h>
32#include <sys/proc.h>
33#include <sys/lock.h>
34#include <sys/malloc.h>

--- 108 unchanged lines hidden (view full) ---

143static ACPI_STATUS
144acpi_pwr_register_resource(ACPI_HANDLE res)
145{
146 ACPI_STATUS status;
147 ACPI_BUFFER buf;
148 ACPI_OBJECT *obj;
149 struct acpi_powerresource *rp, *srp;
150
151 ACPI_FUNCTION_TRACE(__func__);
151 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
152
153 rp = NULL;
154 buf.Pointer = NULL;
155
156 /* look to see if we know about this resource */
157 if (acpi_pwr_find_resource(res) != NULL)
158 return_ACPI_STATUS(AE_OK); /* already know about it */
159

--- 47 unchanged lines hidden (view full) ---

207/*
208 * Deregister a power resource.
209 */
210static ACPI_STATUS
211acpi_pwr_deregister_resource(ACPI_HANDLE res)
212{
213 struct acpi_powerresource *rp;
214
152
153 rp = NULL;
154 buf.Pointer = NULL;
155
156 /* look to see if we know about this resource */
157 if (acpi_pwr_find_resource(res) != NULL)
158 return_ACPI_STATUS(AE_OK); /* already know about it */
159

--- 47 unchanged lines hidden (view full) ---

207/*
208 * Deregister a power resource.
209 */
210static ACPI_STATUS
211acpi_pwr_deregister_resource(ACPI_HANDLE res)
212{
213 struct acpi_powerresource *rp;
214
215 ACPI_FUNCTION_TRACE(__func__);
215 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
216
217 rp = NULL;
218
219 /* find the resource */
220 if ((rp = acpi_pwr_find_resource(res)) == NULL)
221 return_ACPI_STATUS(AE_BAD_PARAMETER);
222
223 /* check that there are no consumers referencing this resource */

--- 14 unchanged lines hidden (view full) ---

238 *
239 * It's OK to call this if we already know about the consumer.
240 */
241static ACPI_STATUS
242acpi_pwr_register_consumer(ACPI_HANDLE consumer)
243{
244 struct acpi_powerconsumer *pc;
245
216
217 rp = NULL;
218
219 /* find the resource */
220 if ((rp = acpi_pwr_find_resource(res)) == NULL)
221 return_ACPI_STATUS(AE_BAD_PARAMETER);
222
223 /* check that there are no consumers referencing this resource */

--- 14 unchanged lines hidden (view full) ---

238 *
239 * It's OK to call this if we already know about the consumer.
240 */
241static ACPI_STATUS
242acpi_pwr_register_consumer(ACPI_HANDLE consumer)
243{
244 struct acpi_powerconsumer *pc;
245
246 ACPI_FUNCTION_TRACE(__func__);
246 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
247
248 /* check to see whether we know about this consumer already */
249 if ((pc = acpi_pwr_find_consumer(consumer)) != NULL)
250 return_ACPI_STATUS(AE_OK);
251
252 /* allocate a new power consumer */
253 if ((pc = malloc(sizeof(*pc), M_ACPIPWR, M_NOWAIT)) == NULL)
254 return_ACPI_STATUS(AE_NO_MEMORY);

--- 14 unchanged lines hidden (view full) ---

269 * This should only be done once the consumer has been powered off.
270 * (XXX is this correct? Check once implemented)
271 */
272static ACPI_STATUS
273acpi_pwr_deregister_consumer(ACPI_HANDLE consumer)
274{
275 struct acpi_powerconsumer *pc;
276
247
248 /* check to see whether we know about this consumer already */
249 if ((pc = acpi_pwr_find_consumer(consumer)) != NULL)
250 return_ACPI_STATUS(AE_OK);
251
252 /* allocate a new power consumer */
253 if ((pc = malloc(sizeof(*pc), M_ACPIPWR, M_NOWAIT)) == NULL)
254 return_ACPI_STATUS(AE_NO_MEMORY);

--- 14 unchanged lines hidden (view full) ---

269 * This should only be done once the consumer has been powered off.
270 * (XXX is this correct? Check once implemented)
271 */
272static ACPI_STATUS
273acpi_pwr_deregister_consumer(ACPI_HANDLE consumer)
274{
275 struct acpi_powerconsumer *pc;
276
277 ACPI_FUNCTION_TRACE(__func__);
277 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
278
279 /* find the consumer */
280 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL)
281 return_ACPI_STATUS(AE_BAD_PARAMETER);
282
283 /* make sure the consumer's not referencing anything right now */
284 if (TAILQ_FIRST(&pc->ac_references) != NULL)
285 return_ACPI_STATUS(AE_BAD_PARAMETER);

--- 16 unchanged lines hidden (view full) ---

302 struct acpi_powerreference *pr;
303 ACPI_HANDLE method_handle, reslist_handle, pr0_handle;
304 ACPI_BUFFER reslist_buffer;
305 ACPI_OBJECT *reslist_object;
306 ACPI_STATUS status;
307 char *method_name, *reslist_name;
308 int res_changed;
309
278
279 /* find the consumer */
280 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL)
281 return_ACPI_STATUS(AE_BAD_PARAMETER);
282
283 /* make sure the consumer's not referencing anything right now */
284 if (TAILQ_FIRST(&pc->ac_references) != NULL)
285 return_ACPI_STATUS(AE_BAD_PARAMETER);

--- 16 unchanged lines hidden (view full) ---

302 struct acpi_powerreference *pr;
303 ACPI_HANDLE method_handle, reslist_handle, pr0_handle;
304 ACPI_BUFFER reslist_buffer;
305 ACPI_OBJECT *reslist_object;
306 ACPI_STATUS status;
307 char *method_name, *reslist_name;
308 int res_changed;
309
310 ACPI_FUNCTION_TRACE(__func__);
310 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
311
312 /* find the consumer */
313 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
314 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer)))
315 return_ACPI_STATUS(status);
316 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
317 return_ACPI_STATUS(AE_ERROR); /* something very wrong */
318 }

--- 158 unchanged lines hidden (view full) ---

477acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg)
478{
479 struct acpi_powerconsumer *pc = (struct acpi_powerconsumer *)arg;
480 struct acpi_powerreference *pr;
481 struct acpi_powerresource *rp;
482 ACPI_HANDLE res;
483 ACPI_STATUS status;
484
311
312 /* find the consumer */
313 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
314 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer)))
315 return_ACPI_STATUS(status);
316 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) {
317 return_ACPI_STATUS(AE_ERROR); /* something very wrong */
318 }

--- 158 unchanged lines hidden (view full) ---

477acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg)
478{
479 struct acpi_powerconsumer *pc = (struct acpi_powerconsumer *)arg;
480 struct acpi_powerreference *pr;
481 struct acpi_powerresource *rp;
482 ACPI_HANDLE res;
483 ACPI_STATUS status;
484
485 ACPI_FUNCTION_TRACE(__func__);
485 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
486
487 /* check the object type */
488 if (obj->Type != ACPI_TYPE_STRING) {
489 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "don't know how to create a power reference to object type %d\n",
490 obj->Type));
491 return_VOID;
492 }
493

--- 41 unchanged lines hidden (view full) ---

535 */
536static ACPI_STATUS
537acpi_pwr_switch_power(void)
538{
539 struct acpi_powerresource *rp;
540 ACPI_STATUS status;
541 int cur;
542
486
487 /* check the object type */
488 if (obj->Type != ACPI_TYPE_STRING) {
489 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "don't know how to create a power reference to object type %d\n",
490 obj->Type));
491 return_VOID;
492 }
493

--- 41 unchanged lines hidden (view full) ---

535 */
536static ACPI_STATUS
537acpi_pwr_switch_power(void)
538{
539 struct acpi_powerresource *rp;
540 ACPI_STATUS status;
541 int cur;
542
543 ACPI_FUNCTION_TRACE(__func__);
543 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
544
545 /*
546 * Sweep the list forwards turning things on.
547 */
548 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) {
549 if (TAILQ_FIRST(&rp->ap_references) == NULL) {
550 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s has no references, not turning on\n",
551 acpi_name(rp->ap_resource)));

--- 63 unchanged lines hidden (view full) ---

615/*
616 * Find a power resource's control structure.
617 */
618static struct acpi_powerresource *
619acpi_pwr_find_resource(ACPI_HANDLE res)
620{
621 struct acpi_powerresource *rp;
622
544
545 /*
546 * Sweep the list forwards turning things on.
547 */
548 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) {
549 if (TAILQ_FIRST(&rp->ap_references) == NULL) {
550 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s has no references, not turning on\n",
551 acpi_name(rp->ap_resource)));

--- 63 unchanged lines hidden (view full) ---

615/*
616 * Find a power resource's control structure.
617 */
618static struct acpi_powerresource *
619acpi_pwr_find_resource(ACPI_HANDLE res)
620{
621 struct acpi_powerresource *rp;
622
623 ACPI_FUNCTION_TRACE(__func__);
623 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
624
625 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link)
626 if (rp->ap_resource == res)
627 break;
628 return_PTR(rp);
629}
630
631/*
632 * Find a power consumer's control structure.
633 */
634static struct acpi_powerconsumer *
635acpi_pwr_find_consumer(ACPI_HANDLE consumer)
636{
637 struct acpi_powerconsumer *pc;
638
624
625 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link)
626 if (rp->ap_resource == res)
627 break;
628 return_PTR(rp);
629}
630
631/*
632 * Find a power consumer's control structure.
633 */
634static struct acpi_powerconsumer *
635acpi_pwr_find_consumer(ACPI_HANDLE consumer)
636{
637 struct acpi_powerconsumer *pc;
638
639 ACPI_FUNCTION_TRACE(__func__);
639 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
640
641 TAILQ_FOREACH(pc, &acpi_powerconsumers, ac_link)
642 if (pc->ac_consumer == consumer)
643 break;
644 return_PTR(pc);
645}
646
640
641 TAILQ_FOREACH(pc, &acpi_powerconsumers, ac_link)
642 if (pc->ac_consumer == consumer)
643 break;
644 return_PTR(pc);
645}
646