diff options
author | njl <njl@FreeBSD.org> | 2004-05-22 17:19:59 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-05-22 17:19:59 +0000 |
commit | 19157eae74697b85446841d8b4c7f8fa3e8c4276 (patch) | |
tree | d5729c3c37634d46262fe431e11823d0ecd74880 /sys/dev/acpica/acpivar.h | |
parent | ea21822dcb2732765ada68f038683c26955b95de (diff) | |
download | FreeBSD-src-19157eae74697b85446841d8b4c7f8fa3e8c4276.zip FreeBSD-src-19157eae74697b85446841d8b4c7f8fa3e8c4276.tar.gz |
Revert the previous commit. The bus accessor macros do not check the
return value for BUS_READ_IVAR and thus don't generate the proper NULL
in cases where a device (i.e. on PCI) does not have a handle.
Found by: peadar, tjr
Diffstat (limited to 'sys/dev/acpica/acpivar.h')
-rw-r--r-- | sys/dev/acpica/acpivar.h | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 4ff2565..4961935 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -139,9 +139,62 @@ struct acpi_device { #define ACPI_IVAR_MAGIC 0x101 #define ACPI_IVAR_PRIVATE 0x102 -__BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE); -__BUS_ACCESSOR(acpi, magic, ACPI, MAGIC, int); -__BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *); +static __inline ACPI_HANDLE +acpi_get_handle(device_t dev) +{ + uintptr_t up; + + if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, &up)) + return (NULL); + return ((ACPI_HANDLE)up); +} + +static __inline int +acpi_set_handle(device_t dev, ACPI_HANDLE h) +{ + uintptr_t up; + + up = (uintptr_t)h; + return (BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_HANDLE, up)); +} + +static __inline int +acpi_get_magic(device_t dev) +{ + uintptr_t up; + + if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, &up)) + return(0); + return ((int)up); +} + +static __inline int +acpi_set_magic(device_t dev, int m) +{ + uintptr_t up; + + up = (uintptr_t)m; + return (BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_MAGIC, up)); +} + +static __inline void * +acpi_get_private(device_t dev) +{ + uintptr_t up; + + if (BUS_READ_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, &up)) + return (NULL); + return ((void *)up); +} + +static __inline int +acpi_set_private(device_t dev, void *p) +{ + uintptr_t up; + + up = (uintptr_t)p; + return (BUS_WRITE_IVAR(device_get_parent(dev), dev, ACPI_IVAR_PRIVATE, up)); +} static __inline ACPI_OBJECT_TYPE acpi_get_type(device_t dev) |