Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Revert acpi_ec.c 1.76.



details:   https://anonhg.NetBSD.org/src/rev/a066c13567cf
branches:  trunk
changeset: 1009075:a066c13567cf
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Apr 12 01:11:43 2020 +0000

description:
Revert acpi_ec.c 1.76.

We will do this another way, and separate KNF fixes from the critical
functional change.

ok msaitoh

diffstat:

 sys/dev/acpi/acpi_ec.c |  79 ++++++++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 44 deletions(-)

diffs (177 lines):

diff -r 51abc9b2824c -r a066c13567cf sys/dev/acpi/acpi_ec.c
--- a/sys/dev/acpi/acpi_ec.c    Sun Apr 12 01:11:23 2020 +0000
+++ b/sys/dev/acpi/acpi_ec.c    Sun Apr 12 01:11:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_ec.c,v 1.78 2020/04/12 01:11:23 riastradh Exp $   */
+/*     $NetBSD: acpi_ec.c,v 1.79 2020/04/12 01:11:43 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.78 2020/04/12 01:11:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.79 2020/04/12 01:11:43 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -404,7 +404,6 @@
 static bool
 acpiec_suspend(device_t dv, const pmf_qual_t *qual)
 {
-
        acpiec_cold = true;
 
        return true;
@@ -413,7 +412,6 @@
 static bool
 acpiec_resume(device_t dv, const pmf_qual_t *qual)
 {
-
        acpiec_cold = false;
 
        return true;
@@ -456,10 +454,9 @@
                ACPI_FREE(p);
                return false;
        }
-
+       
        if (p->Package.Count != 2) {
-               aprint_error_dev(self,
-                   "_GPE package does not contain 2 elements\n");
+               aprint_error_dev(self, "_GPE package does not contain 2 elements\n");
                ACPI_FREE(p);
                return false;
        }
@@ -514,7 +511,6 @@
 acpiec_space_setup(ACPI_HANDLE region, uint32_t func, void *arg,
     void **region_arg)
 {
-
        if (func == ACPI_REGION_DEACTIVATE)
                *region_arg = NULL;
        else
@@ -532,11 +528,9 @@
        mutex_enter(&sc->sc_access_mtx);
 
        if (sc->sc_need_global_lock) {
-               rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT,
-                   &sc->sc_global_lock);
+               rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, &sc->sc_global_lock);
                if (rv != AE_OK) {
-                       aprint_error_dev(dv,
-                           "failed to acquire global lock: %s\n",
+                       aprint_error_dev(dv, "failed to acquire global lock: %s\n",
                            AcpiFormatException(rv));
                        return;
                }
@@ -552,8 +546,7 @@
        if (sc->sc_need_global_lock) {
                rv = AcpiReleaseGlobalLock(sc->sc_global_lock);
                if (rv != AE_OK) {
-                       aprint_error_dev(dv,
-                           "failed to release global lock: %s\n",
+                       aprint_error_dev(dv, "failed to release global lock: %s\n",
                            AcpiFormatException(rv));
                }
        }
@@ -594,8 +587,7 @@
        } else if (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, EC_CMD_TIMEOUT * hz)) {
                mutex_exit(&sc->sc_mtx);
                acpiec_unlock(dv);
-               aprint_error_dev(dv,
-                   "command takes over %d sec...\n", EC_CMD_TIMEOUT);
+               aprint_error_dev(dv, "command takes over %d sec...\n", EC_CMD_TIMEOUT);
                return AE_ERROR;
        }
 
@@ -642,8 +634,7 @@
        } else if (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, EC_CMD_TIMEOUT * hz)) {
                mutex_exit(&sc->sc_mtx);
                acpiec_unlock(dv);
-               aprint_error_dev(dv,
-                   "command takes over %d sec...\n", EC_CMD_TIMEOUT);
+               aprint_error_dev(dv, "command takes over %d sec...\n", EC_CMD_TIMEOUT);
                return AE_ERROR;
        }
 
@@ -657,42 +648,43 @@
 acpiec_space_handler(uint32_t func, ACPI_PHYSICAL_ADDRESS paddr,
     uint32_t width, ACPI_INTEGER *value, void *arg, void *region_arg)
 {
-       device_t dv = arg;
+       device_t dv;
        ACPI_STATUS rv;
-       uint8_t addr;
-       uint8_t *reg;
+       uint8_t addr, reg;
+       unsigned int i;
 
-       if ((func != ACPI_READ) && (func != ACPI_WRITE)) {
-               aprint_error("%s: invalid Address Space function called: %x\n",
-                   device_xname(dv), (unsigned int)func);
-               return AE_BAD_PARAMETER;
-       }
        if (paddr > 0xff || width % 8 != 0 || value == NULL || arg == NULL ||
            paddr + width / 8 > 0x100)
                return AE_BAD_PARAMETER;
 
        addr = paddr;
-       reg = (uint8_t *)value;
+       dv = arg;
 
        rv = AE_OK;
 
-       if (func == ACPI_READ)
+       switch (func) {
+       case ACPI_READ:
                *value = 0;
-
-       do {
-               switch (func) {
-               case ACPI_READ:
-                       rv = acpiec_read(dv, addr, reg);
-                       break;
-               case ACPI_WRITE:
-                       rv = acpiec_write(dv, addr, *reg);
-                       break;
+               for (i = 0; i < width; i += 8, ++addr) {
+                       rv = acpiec_read(dv, addr, &reg);
+                       if (rv != AE_OK)
+                               break;
+                       *value |= (ACPI_INTEGER)reg << i;
                }
-               if (rv != AE_OK)
-                       break;
-               addr++;
-               reg++;
-       } while (addr < (paddr + width / 8));
+               break;
+       case ACPI_WRITE:
+               for (i = 0; i < width; i += 8, ++addr) {
+                       reg = (*value >>i) & 0xff;
+                       rv = acpiec_write(dv, addr, reg);
+                       if (rv != AE_OK)
+                               break;
+               }
+               break;
+       default:
+               aprint_error("%s: invalid Address Space function called: %x\n",
+                   device_xname(dv), (unsigned int)func);
+               return AE_BAD_PARAMETER;
+       }
 
        return rv;
 }
@@ -875,8 +867,7 @@
 ACPI_STATUS
 acpiec_bus_write(device_t dv, u_int addr, ACPI_INTEGER val, int width)
 {
-       return acpiec_space_handler(ACPI_WRITE, addr, width * 8, &val, dv,
-           NULL);
+       return acpiec_space_handler(ACPI_WRITE, addr, width * 8, &val, dv, NULL);
 }
 
 ACPI_HANDLE



Home | Main Index | Thread Index | Old Index