Deleted Added
full compact
acpi_powerres.c (128252) acpi_powerres.c (130208)
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

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

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
27#include <sys/cdefs.h>
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

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

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
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 128252 2004-04-14 17:58:19Z njl $");
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 130208 2004-06-07 21:39:15Z njl $");
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35
36#include "acpi.h"

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

321 }
322 }
323
324 /* Check for valid transitions */
325 if (pc->ac_state == ACPI_STATE_D3 && state != ACPI_STATE_D0)
326 return_ACPI_STATUS (AE_BAD_PARAMETER); /* can only go to D0 from D3 */
327
328 /* Find transition mechanism(s) */
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35
36#include "acpi.h"

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

321 }
322 }
323
324 /* Check for valid transitions */
325 if (pc->ac_state == ACPI_STATE_D3 && state != ACPI_STATE_D0)
326 return_ACPI_STATUS (AE_BAD_PARAMETER); /* can only go to D0 from D3 */
327
328 /* Find transition mechanism(s) */
329 switch(state) {
329 switch (state) {
330 case ACPI_STATE_D0:
331 method_name = "_PS0";
332 reslist_name = "_PR0";
333 break;
334 case ACPI_STATE_D1:
335 method_name = "_PS1";
336 reslist_name = "_PR1";
337 break;

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

354 * reslist must be present. We need to do this before we go
355 * dereferencing resources (since we might be trying to go to
356 * a state we don't support).
357 *
358 * Note that if any states are supported, the device has to
359 * support D0 and D3. It's never an error to try to go to
360 * D0.
361 */
330 case ACPI_STATE_D0:
331 method_name = "_PS0";
332 reslist_name = "_PR0";
333 break;
334 case ACPI_STATE_D1:
335 method_name = "_PS1";
336 reslist_name = "_PR1";
337 break;

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

354 * reslist must be present. We need to do this before we go
355 * dereferencing resources (since we might be trying to go to
356 * a state we don't support).
357 *
358 * Note that if any states are supported, the device has to
359 * support D0 and D3. It's never an error to try to go to
360 * D0.
361 */
362 status = AE_BAD_PARAMETER;
362 reslist_buffer.Pointer = NULL;
363 reslist_object = NULL;
364 if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle)))
365 method_handle = NULL;
366 if (ACPI_FAILURE(AcpiGetHandle(consumer, reslist_name, &reslist_handle)))
367 reslist_handle = NULL;
368 if (reslist_handle == NULL && method_handle == NULL) {
369 if (state == ACPI_STATE_D0) {
370 pc->ac_state = ACPI_STATE_D0;
371 return_ACPI_STATUS (AE_OK);
372 }
373 if (state != ACPI_STATE_D3)
374 goto bad;
375
363 reslist_buffer.Pointer = NULL;
364 reslist_object = NULL;
365 if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle)))
366 method_handle = NULL;
367 if (ACPI_FAILURE(AcpiGetHandle(consumer, reslist_name, &reslist_handle)))
368 reslist_handle = NULL;
369 if (reslist_handle == NULL && method_handle == NULL) {
370 if (state == ACPI_STATE_D0) {
371 pc->ac_state = ACPI_STATE_D0;
372 return_ACPI_STATUS (AE_OK);
373 }
374 if (state != ACPI_STATE_D3)
375 goto bad;
376
376 /* Turn off the resources listed in _PR0 to go to D3. */
377 if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle)))
377 /*
378 * Turn off the resources listed in _PR0 to go to D3. If there is
379 * no _PR0 method, this object doesn't support ACPI power states.
380 */
381 if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle))) {
382 status = AE_NOT_FOUND;
378 goto bad;
383 goto bad;
384 }
379 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER;
380 status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer);
381 if (ACPI_FAILURE(status))
382 goto bad;
383 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer;
384 if (reslist_object->Type != ACPI_TYPE_PACKAGE ||
385 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER;
386 status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer);
387 if (ACPI_FAILURE(status))
388 goto bad;
389 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer;
390 if (reslist_object->Type != ACPI_TYPE_PACKAGE ||
385 reslist_object->Package.Count == 0) {
386
391 reslist_object->Package.Count == 0)
387 goto bad;
392 goto bad;
388 }
389 AcpiOsFree(reslist_buffer.Pointer);
390 reslist_buffer.Pointer = NULL;
391 reslist_object = NULL;
392 }
393
394 /*
395 * Check that we can actually fetch the list of power resources
396 */

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

414 }
415 }
416
417 /*
418 * Now we are ready to switch, so kill off any current power
419 * resource references.
420 */
421 res_changed = 0;
393 AcpiOsFree(reslist_buffer.Pointer);
394 reslist_buffer.Pointer = NULL;
395 reslist_object = NULL;
396 }
397
398 /*
399 * Check that we can actually fetch the list of power resources
400 */

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

418 }
419 }
420
421 /*
422 * Now we are ready to switch, so kill off any current power
423 * resource references.
424 */
425 res_changed = 0;
422 while((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
426 while ((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
423 res_changed = 1;
424 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n",
425 acpi_name(pr->ar_resource->ap_resource)));
426 TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink);
427 TAILQ_REMOVE(&pc->ac_references, pr, ar_clink);
428 free(pr, M_ACPIPWR);
429 }
430

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

472
473 /* Transition was successful */
474 pc->ac_state = state;
475 return_ACPI_STATUS (AE_OK);
476
477 bad:
478 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
479 "attempt to set unsupported state D%d\n", state));
427 res_changed = 1;
428 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n",
429 acpi_name(pr->ar_resource->ap_resource)));
430 TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink);
431 TAILQ_REMOVE(&pc->ac_references, pr, ar_clink);
432 free(pr, M_ACPIPWR);
433 }
434

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

476
477 /* Transition was successful */
478 pc->ac_state = state;
479 return_ACPI_STATUS (AE_OK);
480
481 bad:
482 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
483 "attempt to set unsupported state D%d\n", state));
480 status = AE_BAD_PARAMETER;
481
482 out:
483 if (reslist_buffer.Pointer != NULL)
484 AcpiOsFree(reslist_buffer.Pointer);
485 return_ACPI_STATUS (status);
486}
487
488/*

--- 189 unchanged lines hidden ---
484
485 out:
486 if (reslist_buffer.Pointer != NULL)
487 AcpiOsFree(reslist_buffer.Pointer);
488 return_ACPI_STATUS (status);
489}
490
491/*

--- 189 unchanged lines hidden ---