Deleted Added
full compact
26c26
< * $FreeBSD: head/sys/dev/acpica/acpi_powerres.c 78993 2001-06-29 20:32:29Z msmith $
---
> * $FreeBSD: head/sys/dev/acpica/acpi_powerres.c 79357 2001-07-06 09:00:07Z msmith $
79a80,83
> /* return values from _STA on a power resource */
> #define ACPI_PWR_OFF 0
> #define ACPI_PWR_ON 1
>
109,111d112
< int ap_state;
< #define ACPI_PWR_OFF 0
< #define ACPI_PWR_ON 1
174,176c175,181
< DEBUG_PRINT(TRACE_OBJECTS, ("bad power resource object\n"));
< status = AE_TYPE;
< goto out;
---
> DEBUG_PRINT(TRACE_OBJECTS, ("questionable power resource object %s\n", acpi_name(res)));
> /* XXX ACPI CA seems to return ACPI_TYPE_ANY, needs to be fixed */
> rp->ap_systemlevel = 0;
> rp->ap_order = 0;
> } else {
> rp->ap_systemlevel = obj->PowerResource.SystemLevel;
> rp->ap_order = obj->PowerResource.ResourceOrder;
178,179d182
< rp->ap_systemlevel = obj->PowerResource.SystemLevel;
< rp->ap_order = obj->PowerResource.ResourceOrder;
181,187d183
< /* get the current state of the resource */
< if ((status = acpi_EvaluateInteger(rp->ap_resource, "_STA", &rp->ap_state)) != AE_OK) {
< /* XXX is this an error? */
< DEBUG_PRINT(TRACE_OBJECTS, ("can't get current power resource state\n"));
< goto out;
< }
<
193c189
< goto out;
---
> goto done;
198c194
< goto out;
---
> goto done;
201d196
< DEBUG_PRINT(TRACE_OBJECTS, ("registered power resource %s\n", acpi_name(res)));
202a198,199
> done:
> DEBUG_PRINT(TRACE_OBJECTS, ("registered power resource %s\n", acpi_name(res)));
400,401c397
< TAILQ_FOREACH(pr, &pc->ac_references, ar_clink) {
< TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink);
---
> while((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
402a399,402
> DEBUG_PRINT(TRACE_OBJECTS, ("removing reference to %s\n", acpi_name(pr->ar_resource->ap_resource)));
> TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink);
> TAILQ_REMOVE(&pc->ac_references, pr, ar_clink);
> free(pr, M_ACPIPWR);
448a449,452
> struct acpi_powerreference *pr;
> struct acpi_powerresource *rp;
> ACPI_HANDLE res;
> ACPI_STATUS status;
452,453c456,461
< DEBUG_PRINT(TRACE_OBJECTS, ("called to create a reference using object type %d\n",
< obj->Type));
---
> /* check the object type */
> if (obj->Type != ACPI_TYPE_STRING) {
> DEBUG_PRINT(TRACE_OBJECTS, ("don't know how to create a power reference to object type %d\n",
> obj->Type));
> return_VOID;
> }
454a463,494
> DEBUG_PRINT(TRACE_OBJECTS, ("building reference from %s to %s\n",
> acpi_name(pc->ac_consumer), obj->String.Pointer));
>
> /* get the handle of the resource */
> if (ACPI_FAILURE(status = AcpiGetHandle(NULL, obj->String.Pointer, &res))) {
> DEBUG_PRINT(TRACE_OBJECTS, ("couldn't find power resource %s\n",
> obj->String.Pointer));
> return_VOID;
> }
>
> /* create/look up the resource */
> if (ACPI_FAILURE(status = acpi_pwr_register_resource(res))) {
> DEBUG_PRINT(TRACE_OBJECTS, ("couldn't register power resource %s - %s\n",
> obj->String.Pointer, acpi_strerror(status)));
> return_VOID;
> }
> if ((rp = acpi_pwr_find_resource(res)) == NULL) {
> DEBUG_PRINT(TRACE_OBJECTS, ("power resource list corrupted\n"));
> return_VOID;
> }
> DEBUG_PRINT(TRACE_OBJECTS, ("found power resource %s\n", acpi_name(rp->ap_resource)));
>
> /* create a reference between the consumer and resource */
> if ((pr = malloc(sizeof(*pr), M_ACPIPWR, M_NOWAIT | M_ZERO)) == NULL) {
> DEBUG_PRINT(TRACE_OBJECTS, ("couldn't allocate memory for a power consumer reference\n"));
> return_VOID;
> }
> pr->ar_consumer = pc;
> pr->ar_resource = rp;
> TAILQ_INSERT_TAIL(&pc->ac_references, pr, ar_clink);
> TAILQ_INSERT_TAIL(&rp->ap_references, pr, ar_rlink);
>
478,479c518,522
< if (rp->ap_state != ACPI_PWR_ON)
< continue; /* not turning this one on */
---
> if (TAILQ_FIRST(&rp->ap_references) == NULL) {
> DEBUG_PRINT(TRACE_OBJECTS, ("%s has no references, not turning on\n",
> acpi_name(rp->ap_resource)));
> continue;
> }
493,494c536,545
< if (cur != ACPI_PWR_ON)
< AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL);
---
> if (cur != ACPI_PWR_ON) {
> if (ACPI_FAILURE(status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL))) {
> DEBUG_PRINT(TRACE_OBJECTS, ("failed to switch %s on - %s\n",
> acpi_name(rp->ap_resource), acpi_strerror(status)));
> } else {
> DEBUG_PRINT(TRACE_OBJECTS, ("switched %s on\n", acpi_name(rp->ap_resource)));
> }
> } else {
> DEBUG_PRINT(TRACE_OBJECTS, ("%s is already on\n", acpi_name(rp->ap_resource)));
> }
501,502c552,556
< if (rp->ap_state != ACPI_PWR_OFF)
< continue; /* not turning this one off */
---
> if (TAILQ_FIRST(&rp->ap_references) != NULL) {
> DEBUG_PRINT(TRACE_OBJECTS, ("%s has references, not turning off\n",
> acpi_name(rp->ap_resource)));
> continue;
> }
516,517c570,579
< if (cur != ACPI_PWR_OFF)
< AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL);
---
> if (cur != ACPI_PWR_OFF) {
> if (ACPI_FAILURE(status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL))) {
> DEBUG_PRINT(TRACE_OBJECTS, ("failed to switch %s off - %s\n",
> acpi_name(rp->ap_resource), acpi_strerror(status)));
> } else {
> DEBUG_PRINT(TRACE_OBJECTS, ("switched %s off\n", acpi_name(rp->ap_resource)));
> }
> } else {
> DEBUG_PRINT(TRACE_OBJECTS, ("%s is already off\n", acpi_name(rp->ap_resource)));
> }