summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/acpica/acpi.c12
-rw-r--r--sys/dev/acpica/acpivar.h9
2 files changed, 21 insertions, 0 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 2bfc27c..4f88cd5 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -1125,7 +1125,10 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
child = BUS_ADD_CHILD(bus, level * 10, NULL, -1);
if (child == NULL)
break;
+
+ /* Associate the handle with the device_t and vice versa. */
acpi_set_handle(child, handle);
+ AcpiAttachData(handle, acpi_fake_objhandler, child);
/* Check if the device can generate wake events. */
if (ACPI_SUCCESS(AcpiEvaluateObject(handle, "_PRW", NULL, NULL)))
@@ -1159,6 +1162,15 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
return_ACPI_STATUS (AE_OK);
}
+/*
+ * AcpiAttachData() requires an object handler but never uses it. This is a
+ * placeholder object handler so we can store a device_t in an ACPI_HANDLE.
+ */
+void
+acpi_fake_objhandler(ACPI_HANDLE h, UINT32 fn, void *data)
+{
+}
+
static void
acpi_shutdown_pre_sync(void *arg, int howto)
{
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 9120216..69b84af 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -174,6 +174,15 @@ __ACPI_BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE)
__ACPI_BUS_ACCESSOR(acpi, magic, ACPI, MAGIC, int)
__ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *)
+void acpi_fake_objhandler(ACPI_HANDLE h, UINT32 fn, void *data);
+static __inline device_t
+acpi_get_device(ACPI_HANDLE handle)
+{
+ void *dev = NULL;
+ AcpiGetData(handle, acpi_fake_objhandler, &dev);
+ return ((device_t)dev);
+}
+
static __inline ACPI_OBJECT_TYPE
acpi_get_type(device_t dev)
{
OpenPOWER on IntegriCloud