diff options
author | njl <njl@FreeBSD.org> | 2003-12-23 18:26:53 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2003-12-23 18:26:53 +0000 |
commit | 891932b7f3ada94905ef6cc670008b2cb0e17441 (patch) | |
tree | 4e9612d54c8f5e3be4352a3406793ac7016e1c19 /sys | |
parent | 29de6d4f904c6f1388be9629cf9eba37fc24277e (diff) | |
download | FreeBSD-src-891932b7f3ada94905ef6cc670008b2cb0e17441.zip FreeBSD-src-891932b7f3ada94905ef6cc670008b2cb0e17441.tar.gz |
Remove the device_t parameter from package routines that only used it to
print an error message. Update all callers of the package routines.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpica/acpi_cpu.c | 14 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_package.c | 54 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 9 |
3 files changed, 28 insertions, 49 deletions
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 9824afb..8ef9655 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -516,12 +516,11 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc) /* _CST is a package with a count and at least one Cx package. */ top = (ACPI_OBJECT *)buf.Pointer; - if (!ACPI_PKG_VALID(top, 2)) { + if (!ACPI_PKG_VALID(top, 2) || acpi_PkgInt32(top, 0, &count) != 0) { device_printf(sc->cpu_dev, "Invalid _CST package\n"); AcpiOsFree(buf.Pointer); return (ENXIO); } - acpi_PkgInt32(sc->cpu_dev, top, 0, &count); if (count != top->Package.Count - 1) { device_printf(sc->cpu_dev, "Invalid _CST state count (%d != %d)\n", count, top->Package.Count - 1); @@ -537,16 +536,15 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc) cx_ptr = sc->cpu_cx_states; for (i = 0; i < count; i++) { pkg = &top->Package.Elements[i + 1]; - if (!ACPI_PKG_VALID(pkg, 4)) { + if (!ACPI_PKG_VALID(pkg, 4) || + acpi_PkgInt32(pkg, 1, &cx_ptr->type) != 0 || + acpi_PkgInt32(pkg, 2, &cx_ptr->trans_lat) != 0 || + acpi_PkgInt32(pkg, 3, &cx_ptr->power) != 0) { + device_printf(sc->cpu_dev, "Skipping invalid Cx state package\n"); continue; } - /* Cx type, transition latency, power consumed. */ - acpi_PkgInt32(sc->cpu_dev, pkg, 1, &cx_ptr->type); - acpi_PkgInt32(sc->cpu_dev, pkg, 2, &cx_ptr->trans_lat); - acpi_PkgInt32(sc->cpu_dev, pkg, 3, &cx_ptr->power); - /* Validate the state to see if we should use it. */ switch (cx_ptr->type) { case ACPI_STATE_C1: diff --git a/sys/dev/acpica/acpi_package.c b/sys/dev/acpica/acpi_package.c index d1d1448..0011308 100644 --- a/sys/dev/acpica/acpi_package.c +++ b/sys/dev/acpica/acpi_package.c @@ -44,47 +44,41 @@ */ int -acpi_PkgInt(device_t dev, ACPI_OBJECT *res, int idx, ACPI_INTEGER *dst) +acpi_PkgInt(ACPI_OBJECT *res, int idx, ACPI_INTEGER *dst) { ACPI_OBJECT *obj; obj = &res->Package.Elements[idx]; - if (obj == NULL || obj->Type != ACPI_TYPE_INTEGER) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgInt error, pkg[%d] at %d %p\n", - res->Package.Count, idx, obj); - return (-1); - } - + if (obj == NULL || obj->Type != ACPI_TYPE_INTEGER) + return (EINVAL); *dst = obj->Integer.Value; + return (0); } int -acpi_PkgInt32(device_t dev, ACPI_OBJECT *res, int idx, uint32_t *dst) +acpi_PkgInt32(ACPI_OBJECT *res, int idx, uint32_t *dst) { - ACPI_INTEGER tmp; - int error; + ACPI_INTEGER tmp; + int error; - error = acpi_PkgInt(dev, res, idx, &tmp); + error = acpi_PkgInt(res, idx, &tmp); if (error == 0) *dst = (uint32_t)tmp; + return (error); } int -acpi_PkgStr(device_t dev, ACPI_OBJECT *res, int idx, void *dst, size_t size) +acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size) { ACPI_OBJECT *obj; void *ptr; size_t length; obj = &res->Package.Elements[idx]; - if (obj == NULL) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgStr NULL object at %d\n", idx); - return (-1); - } + if (obj == NULL) + return (EINVAL); bzero(dst, sizeof(dst)); switch (obj->Type) { @@ -97,17 +91,12 @@ acpi_PkgStr(device_t dev, ACPI_OBJECT *res, int idx, void *dst, size_t size) length = obj->Buffer.Length; break; default: - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgStr: invalid object type %d at %d\n", obj->Type, idx); - return (-1); + return (EINVAL); } /* Make sure string will fit, including terminating NUL */ - if (++length > size) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgStr string too long (%zu bytes) at %d\n", length, idx); - return (-1); - } + if (++length > size) + return (E2BIG); strlcpy(dst, ptr, length); return (0); @@ -115,7 +104,7 @@ acpi_PkgStr(device_t dev, ACPI_OBJECT *res, int idx, void *dst, size_t size) int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, - struct resource **dst) + struct resource **dst) { ACPI_GENERIC_ADDRESS gas; ACPI_OBJECT *obj; @@ -124,18 +113,13 @@ acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, if (obj == NULL || obj->Type != ACPI_TYPE_BUFFER || obj->Buffer.Length < sizeof(ACPI_GENERIC_ADDRESS) + 3) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgGas error at %d\n", idx); - return (-1); + return (EINVAL); } memcpy(&gas, obj->Buffer.Pointer + 3, sizeof(gas)); *dst = acpi_bus_alloc_gas(dev, rid, &gas); - if (*dst == NULL) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "PkgGas error at %d\n", idx); - return (-1); - } + if (*dst == NULL) + return (ENXIO); return (0); } diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index b913625..f9f7c71 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -292,12 +292,9 @@ extern int acpi_acad_get_acline(int *); #define ACPI_PKG_VALID(pkg, size) \ ((pkg) != NULL && (pkg)->Type == ACPI_TYPE_PACKAGE && \ (pkg)->Package.Count >= (size)) -int acpi_PkgInt(device_t dev, ACPI_OBJECT *res, int idx, - ACPI_INTEGER *dst); -int acpi_PkgInt32(device_t dev, ACPI_OBJECT *res, int idx, - uint32_t *dst); -int acpi_PkgStr(device_t dev, ACPI_OBJECT *res, int idx, void *dst, - size_t size); +int acpi_PkgInt(ACPI_OBJECT *res, int idx, ACPI_INTEGER *dst); +int acpi_PkgInt32(ACPI_OBJECT *res, int idx, uint32_t *dst); +int acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size); int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, struct resource **dst); |