Deleted Added
full compact
27c27
< * $FreeBSD: head/sys/dev/acpica/acpi_ec.c 107328 2002-11-27 18:09:20Z iwasaki $
---
> * $FreeBSD: head/sys/dev/acpica/acpi_ec.c 116927 2003-06-27 21:57:42Z njl $
247c247
< static int acpi_ec_event_driven = 0;
---
> static int acpi_ec_event_driven = 0;
258,259c258,260
< if (ACPI_SUCCESS(status = AcpiAcquireGlobalLock(ACPI_WAIT_FOREVER, &sc->ec_lockhandle)))
< (sc)->ec_locked = 1;
---
> status = AcpiAcquireGlobalLock(ACPI_WAIT_FOREVER, &sc->ec_lockhandle);
> if (ACPI_SUCCESS(status))
> sc->ec_locked = 1;
261c262
< return(status);
---
> return (status);
267c268
< (sc)->ec_locked = 0;
---
> sc->ec_locked = 0;
274c275
< return((sc)->ec_locked != 0);
---
> return (sc->ec_locked != 0);
279,281c280,282
< EC_COMMAND Command;
< UINT8 Address;
< UINT8 Data;
---
> EC_COMMAND Command;
> UINT8 Address;
> UINT8 Data;
286,289c287,291
< void *Context, void **return_Context);
< static ACPI_STATUS EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, ACPI_INTEGER *Value,
< void *Context, void *RegionContext);
<
---
> void *Context, void **return_Context);
> static ACPI_STATUS EcSpaceHandler(UINT32 Function,
> ACPI_PHYSICAL_ADDRESS Address,
> UINT32 width, ACPI_INTEGER *Value,
> void *Context, void *RegionContext);
292,295c294,299
< static ACPI_STATUS EcTransaction(struct acpi_ec_softc *sc, EC_REQUEST *EcRequest);
< static ACPI_STATUS EcRead(struct acpi_ec_softc *sc, UINT8 Address, UINT8 *Data);
< static ACPI_STATUS EcWrite(struct acpi_ec_softc *sc, UINT8 Address, UINT8 *Data);
<
---
> static ACPI_STATUS EcTransaction(struct acpi_ec_softc *sc,
> EC_REQUEST *EcRequest);
> static ACPI_STATUS EcRead(struct acpi_ec_softc *sc, UINT8 Address,
> UINT8 *Data);
> static ACPI_STATUS EcWrite(struct acpi_ec_softc *sc, UINT8 Address,
> UINT8 *Data);
331,332d334
<
< return_VOID;
343,344c345
< if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) &&
< !acpi_disabled("ec") &&
---
> if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("ec") &&
351,352c352
<
< return(0);
---
> return (0);
354c354
< return(ENXIO);
---
> return (ENXIO);
362c362
< int errval = 0;
---
> int errval = 0;
378,379c378,380
< if ((sc->ec_data_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_data_rid,
< 0, ~0, 1, RF_ACTIVE)) == NULL) {
---
> sc->ec_data_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT,
> &sc->ec_data_rid, 0, ~0, 1, RF_ACTIVE);
> if (sc->ec_data_res == NULL) {
388,389c389,391
< if ((sc->ec_csr_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_csr_rid,
< 0, ~0, 1, RF_ACTIVE)) == NULL) {
---
> sc->ec_csr_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT,
> &sc->ec_csr_rid, 0, ~0, 1, RF_ACTIVE);
> if (sc->ec_csr_res == NULL) {
404,406c406,410
< if (ACPI_FAILURE(Status = acpi_EvaluateInteger(sc->ec_handle, "_GPE", &sc->ec_gpebit))) {
< device_printf(dev, "can't evaluate _GPE - %s\n", AcpiFormatException(Status));
< errval =ENXIO;
---
> Status = acpi_EvaluateInteger(sc->ec_handle, "_GPE", &sc->ec_gpebit);
> if (ACPI_FAILURE(Status)) {
> device_printf(dev, "can't evaluate _GPE - %s\n",
> AcpiFormatException(Status));
> errval = ENXIO;
418,421c422,425
< if (ACPI_FAILURE(Status = AcpiInstallGpeHandler(sc->ec_gpebit,
< ACPI_EVENT_LEVEL_TRIGGERED |
< ACPI_EVENT_EDGE_TRIGGERED,
< EcGpeHandler, sc))) {
---
> Status = AcpiInstallGpeHandler(sc->ec_gpebit,
> ACPI_EVENT_LEVEL_TRIGGERED | ACPI_EVENT_EDGE_TRIGGERED,
> EcGpeHandler, sc);
> if (ACPI_FAILURE(Status)) {
432,436c436,438
< if (ACPI_FAILURE(Status = AcpiInstallAddressSpaceHandler(sc->ec_handle,
< ACPI_ADR_SPACE_EC,
< EcSpaceHandler,
< EcSpaceSetup,
< sc))) {
---
> Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ACPI_ADR_SPACE_EC,
> EcSpaceHandler, EcSpaceSetup, sc);
> if (ACPI_FAILURE(Status)) {
444c446,447
< return_VALUE(0);
---
> return_VALUE (0);
>
446c449
< if(sc->ec_csr_res)
---
> if (sc->ec_csr_res)
449c452
< if(sc->ec_data_res)
---
> if (sc->ec_data_res)
452c455
< return_VALUE(errval);
---
> return_VALUE (errval);
478c481
< if (!(EC_GET_CSR(sc) & EC_EVENT_SCI))
---
> if ((EC_GET_CSR(sc) & EC_EVENT_SCI) == 0)
507c510
< qxx, AcpiFormatException(Status));
---
> qxx, AcpiFormatException(Status));
512c515
< printf("EcGpeQueryHandler:ClearEvent Failed\n");
---
> printf("EcGpeQueryHandler:ClearEvent Failed\n");
514,515c517
< printf("EcGpeQueryHandler:EnableEvent Failed\n");
< return_VOID;
---
> printf("EcGpeQueryHandler:EnableEvent Failed\n");
531c533
< if (EcIsLocked(sc)){
---
> if (EcIsLocked(sc)) {
535,536c537,538
< if ((csrvalue & EC_FLAG_OUTPUT_BUFFER)
< || !(csrvalue & EC_FLAG_INPUT_BUFFER)) {
---
> if ((csrvalue & EC_FLAG_OUTPUT_BUFFER) != 0 ||
> (csrvalue & EC_FLAG_INPUT_BUFFER) == 0) {
538c540
< wakeup((void *)&sc->ec_csrvalue);
---
> wakeup(&sc->ec_csrvalue);
540c542
< }else{
---
> } else {
547d548
< return;
551c552,553
< EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context, void **RegionContext)
---
> EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context,
> void **RegionContext)
561c563
< return_ACPI_STATUS(AE_OK);
---
> return_ACPI_STATUS (AE_OK);
565,566c567,568
< EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, ACPI_INTEGER *Value,
< void *Context, void *RegionContext)
---
> EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width,
> ACPI_INTEGER *Value, void *Context, void *RegionContext)
575,576c577,578
< if ((Address > 0xFF) || (width % 8 != 0) || (Value == NULL) || (Context == NULL))
< return_ACPI_STATUS(AE_BAD_PARAMETER);
---
> if (Address > 0xFF || width % 8 != 0 || Value == NULL || Context == NULL)
> return_ACPI_STATUS (AE_BAD_PARAMETER);
584d585
<
589d589
<
591,592c591,593
< device_printf(sc->ec_dev, "invalid Address Space function %d\n", Function);
< return_ACPI_STATUS(AE_BAD_PARAMETER);
---
> device_printf(sc->ec_dev, "invalid Address Space function %d\n",
> Function);
> return_ACPI_STATUS (AE_BAD_PARAMETER);
603c604,605
< if (ACPI_FAILURE(Status = EcTransaction(sc, &EcRequest)))
---
> Status = EcTransaction(sc, &EcRequest);
> if (ACPI_FAILURE(Status))
605c607
< (*Value) |= (ACPI_INTEGER)EcRequest.Data << i;
---
> *Value |= (ACPI_INTEGER)EcRequest.Data << i;
607c609
< return_ACPI_STATUS(AE_BAD_PARAMETER);
---
> return_ACPI_STATUS (AE_BAD_PARAMETER);
609c611
< return_ACPI_STATUS(Status);
---
> return_ACPI_STATUS (Status);
625c627
< return_ACPI_STATUS(EcWaitEvent(sc, Event));
---
> return_ACPI_STATUS (EcWaitEvent(sc, Event));
627c629
< if (!EcIsLocked(sc))
---
> if (!EcIsLocked(sc)) {
629a632
> }
634c637
< for(i = 0; i < 10; i++){
---
> for (i = 0; i < 10; i++) {
639,640c642,643
< (EcStatus & EC_FLAG_OUTPUT_BUFFER))
< return_ACPI_STATUS(AE_OK);
---
> (EcStatus & EC_FLAG_OUTPUT_BUFFER) != 0)
> return_ACPI_STATUS (AE_OK);
643,644c646,647
< !(EcStatus & EC_FLAG_INPUT_BUFFER))
< return_ACPI_STATUS(AE_OK);
---
> (EcStatus & EC_FLAG_INPUT_BUFFER) == 0)
> return_ACPI_STATUS (AE_OK);
647c650,651
< if (ACPI_MSLEEP(&sc->ec_csrvalue, &acpi_mutex, PZERO, "EcWait", 1) != EWOULDBLOCK){
---
> /* XXX sleeping with Acpi Global Lock held */
> if (tsleep(&sc->ec_csrvalue, PZERO, "EcWait", 1) != EWOULDBLOCK) {
649c653
< }else{
---
> } else {
653c657
< return_ACPI_STATUS(AE_ERROR);
---
> return_ACPI_STATUS (AE_ERROR);
662c666
< if (!EcIsLocked(sc))
---
> if (!EcIsLocked(sc)) {
664a669
> }
687,689c692,694
< if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) &&
< (EcStatus & EC_FLAG_OUTPUT_BUFFER))
< return(AE_OK);
---
> if (Event == EC_EVENT_OUTPUT_BUFFER_FULL &&
> (EcStatus & EC_FLAG_OUTPUT_BUFFER) != 0)
> return (AE_OK);
691,692c696,697
< if ((Event == EC_EVENT_INPUT_BUFFER_EMPTY) &&
< !(EcStatus & EC_FLAG_INPUT_BUFFER))
---
> if (Event == EC_EVENT_INPUT_BUFFER_EMPTY &&
> (EcStatus & EC_FLAG_INPUT_BUFFER) == 0)
698c703
< return(AE_ERROR);
---
> return (AE_ERROR);
706,707c711,713
< if (ACPI_FAILURE(Status = EcLock(sc)))
< return(Status);
---
> Status = EcLock(sc);
> if (ACPI_FAILURE(Status))
> return (Status);
710c716,717
< if (ACPI_SUCCESS(Status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL)))
---
> Status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL);
> if (ACPI_SUCCESS(Status))
715c722
< if (ACPI_FAILURE(Status))
---
> if (ACPI_FAILURE(Status)) {
718c725,726
< return(Status);
---
> }
> return (Status);
726,730c734,736
< /*
< * Lock the EC
< */
< if (ACPI_FAILURE(Status = EcLock(sc)))
< return(Status);
---
> Status = EcLock(sc);
> if (ACPI_FAILURE(Status))
> return (Status);
737c743
< Status = EcRead(sc, EcRequest->Address, &(EcRequest->Data));
---
> Status = EcRead(sc, EcRequest->Address, &EcRequest->Data);
739d744
<
741c746
< Status = EcWrite(sc, EcRequest->Address, &(EcRequest->Data));
---
> Status = EcWrite(sc, EcRequest->Address, &EcRequest->Data);
743d747
<
749,751d752
< /*
< * Unlock the EC
< */
763c764
< if (sc->ec_pendquery){
---
> if (sc->ec_pendquery) {
770c771
< if (ACPI_FAILURE(AcpiClearEvent(sc->ec_gpebit, ACPI_EVENT_GPE)))
---
> if (ACPI_FAILURE(AcpiClearEvent(sc->ec_gpebit, ACPI_EVENT_GPE))) {
773c774,775
< if (ACPI_FAILURE(AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE, 0)))
---
> }
> if (ACPI_FAILURE(AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE, 0))) {
775a778
> }
777c780
< return(Status);
---
> return (Status);
786c789
< if (!EcIsLocked(sc))
---
> if (!EcIsLocked(sc)) {
788a792
> }
793c797,798
< if (ACPI_FAILURE(Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY))) {
---
> Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY);
> if (ACPI_FAILURE(Status)) {
796c801
< return(Status);
---
> return (Status);
800c805,806
< if (ACPI_FAILURE(Status = EcWaitEventIntr(sc, EC_EVENT_OUTPUT_BUFFER_FULL))) {
---
> Status = EcWaitEventIntr(sc, EC_EVENT_OUTPUT_BUFFER_FULL);
> if (ACPI_FAILURE(Status)) {
803c809
< return(Status);
---
> return (Status);
806c812
< (*Data) = EC_GET_DATA(sc);
---
> *Data = EC_GET_DATA(sc);
810c816
< return(AE_OK);
---
> return (AE_OK);
818c824
< if (!EcIsLocked(sc))
---
> if (!EcIsLocked(sc)) {
820a827
> }
825c832,833
< if (ACPI_FAILURE(Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY))) {
---
> Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY);
> if (ACPI_FAILURE(Status)) {
828c836
< return(Status);
---
> return (Status);
832c840,841
< if (ACPI_FAILURE(Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY))) {
---
> Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY);
> if (ACPI_FAILURE(Status)) {
835c844
< return(Status);
---
> return (Status);
839c848,849
< if (ACPI_FAILURE(Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY))) {
---
> Status = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY);
> if (ACPI_FAILURE(Status)) {
842c852
< return(Status);
---
> return (Status);
847c857
< return(AE_OK);
---
> return (AE_OK);