Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi kern/55206: acpibat reporting broken by acpi_ec...



details:   https://anonhg.NetBSD.org/src/rev/1fdb46a15afc
branches:  trunk
changeset: 931640:1fdb46a15afc
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Apr 28 10:04:32 2020 +0000

description:
kern/55206: acpibat reporting broken by acpi_ec.c r1.81

Assume byte instead of qword alignment of the buffer passed to the EC
space handler.

diffstat:

 sys/dev/acpi/acpi_ec.c |  20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diffs (58 lines):

diff -r af77f8ec4bcf -r 1fdb46a15afc sys/dev/acpi/acpi_ec.c
--- a/sys/dev/acpi/acpi_ec.c    Tue Apr 28 07:47:54 2020 +0000
+++ b/sys/dev/acpi/acpi_ec.c    Tue Apr 28 10:04:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_ec.c,v 1.81 2020/04/12 01:12:03 riastradh Exp $   */
+/*     $NetBSD: acpi_ec.c,v 1.82 2020/04/28 10:04:32 jmcneill 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.81 2020/04/12 01:12:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.82 2020/04/28 10:04:32 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -659,32 +659,30 @@
 {
        device_t dv;
        ACPI_STATUS rv;
-       uint8_t addr, reg;
+       uint8_t addr, *buf;
        unsigned int i;
 
-       if (paddr > 0xff || width % 8 != 0 || width > sizeof(ACPI_INTEGER)*8 ||
+       if (paddr > 0xff || width % 8 != 0 ||
            value == NULL || arg == NULL || paddr + width / 8 > 0x100)
                return AE_BAD_PARAMETER;
 
        addr = paddr;
        dv = arg;
+       buf = (uint8_t *)value;
 
        rv = AE_OK;
 
        switch (func) {
        case ACPI_READ:
-               *value = 0;
-               for (i = 0; i < width; i += 8, ++addr) {
-                       rv = acpiec_read(dv, addr, &reg);
+               for (i = 0; i < width; i += 8, ++addr, ++buf) {
+                       rv = acpiec_read(dv, addr, buf);
                        if (rv != AE_OK)
                                break;
-                       *value |= (ACPI_INTEGER)reg << i;
                }
                break;
        case ACPI_WRITE:
-               for (i = 0; i < width; i += 8, ++addr) {
-                       reg = (*value >> i) & 0xff;
-                       rv = acpiec_write(dv, addr, reg);
+               for (i = 0; i < width; i += 8, ++addr, ++buf) {
+                       rv = acpiec_write(dv, addr, *buf);
                        if (rv != AE_OK)
                                break;
                }



Home | Main Index | Thread Index | Old Index