summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2022-01-22 11:49:16 +0000
committerthorpej <thorpej@NetBSD.org>2022-01-22 11:49:16 +0000
commit09eb5c43f131a6790fa9b46f440dd5a2d4ae03ae (patch)
treeffdfd13d89a9bfa56433c400ad83033887f60a5f /sys/dev/acpi
parent1c2752a686271470f2f20bdba60a27d2b6d5b8a8 (diff)
Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation. The root implementation for a new handle type is used if an invalid "super handle" is passed.
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpi.c10
-rw-r--r--sys/dev/acpi/acpi_pci.c6
-rw-r--r--sys/dev/acpi/acpi_util.c23
-rw-r--r--sys/dev/acpi/acpi_util.h4
4 files changed, 26 insertions, 17 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index d018fdda109..3d955d536d4 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.295 2021/12/31 14:22:42 riastradh Exp $ */
+/* $NetBSD: acpi.c,v 1.296 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.295 2021/12/31 14:22:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.296 2022/01/22 11:49:17 thorpej Exp $");
#include "pci.h"
#include "opt_acpi.h"
@@ -962,7 +962,8 @@ acpi_rescan_early(struct acpi_softc *sc)
ad->ad_device = config_found(sc->sc_dev, &aa, acpi_print,
CFARGS(.iattr = "acpinodebus",
- .devhandle = devhandle_from_acpi(ad->ad_handle)));
+ .devhandle = devhandle_from_acpi(devhandle_invalid(),
+ ad->ad_handle)));
}
}
@@ -1029,7 +1030,8 @@ acpi_rescan_nodes(struct acpi_softc *sc)
ad->ad_device = config_found(sc->sc_dev, &aa, acpi_print,
CFARGS(.iattr = "acpinodebus",
- .devhandle = devhandle_from_acpi(ad->ad_handle)));
+ .devhandle = devhandle_from_acpi(devhandle_invalid(),
+ ad->ad_handle)));
}
}
diff --git a/sys/dev/acpi/acpi_pci.c b/sys/dev/acpi/acpi_pci.c
index e8be8114d58..83a2e152afd 100644
--- a/sys/dev/acpi/acpi_pci.c
+++ b/sys/dev/acpi/acpi_pci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.33 2021/12/20 11:17:40 skrll Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.34 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.33 2021/12/20 11:17:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.34 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -572,7 +572,7 @@ acpi_pci_bus_get_child_devhandle(device_t dev, devhandle_t call_handle, void *v)
if (ad != NULL && (hdl = ad->ad_handle) != NULL) {
/* Found it! */
- args->devhandle = devhandle_from_acpi(hdl);
+ args->devhandle = devhandle_from_acpi(call_handle, hdl);
return 0;
}
diff --git a/sys/dev/acpi/acpi_util.c b/sys/dev/acpi/acpi_util.c
index a1087fbcfce..674d9f9132c 100644
--- a/sys/dev/acpi/acpi_util.c
+++ b/sys/dev/acpi/acpi_util.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $ */
+/* $NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -121,12 +121,18 @@ static const struct devhandle_impl acpi_devhandle_impl = {
};
devhandle_t
-devhandle_from_acpi(ACPI_HANDLE const hdl)
+devhandle_from_acpi(devhandle_t super_handle, ACPI_HANDLE const hdl)
{
- devhandle_t handle = {
- .impl = &acpi_devhandle_impl,
- .pointer = hdl,
- };
+ devhandle_type_t super_type = devhandle_type(super_handle);
+ devhandle_t handle = { 0 };
+
+ if (super_type == DEVHANDLE_TYPE_ACPI) {
+ handle.impl = super_handle.impl;
+ } else {
+ KASSERT(super_type == DEVHANDLE_TYPE_INVALID);
+ handle.impl = &acpi_devhandle_impl;
+ }
+ handle.pointer = hdl;
return handle;
}
@@ -154,7 +160,8 @@ acpi_device_enumerate_children(device_t dev, devhandle_t call_handle, void *v)
!acpi_device_present(ad->ad_handle)) {
continue;
}
- if (!args->callback(dev, devhandle_from_acpi(ad->ad_handle),
+ if (!args->callback(dev, devhandle_from_acpi(call_handle,
+ ad->ad_handle),
args->callback_arg)) {
break;
}
diff --git a/sys/dev/acpi/acpi_util.h b/sys/dev/acpi/acpi_util.h
index 74b8db97bbf..0659d21299c 100644
--- a/sys/dev/acpi/acpi_util.h
+++ b/sys/dev/acpi/acpi_util.h
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.h,v 1.13 2022/01/15 14:40:33 jmcneill Exp $ */
+/* $NetBSD: acpi_util.h,v 1.14 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
#ifndef _SYS_DEV_ACPI_ACPI_UTIL_H
#define _SYS_DEV_ACPI_ACPI_UTIL_H
-devhandle_t devhandle_from_acpi(ACPI_HANDLE);
+devhandle_t devhandle_from_acpi(devhandle_t, ACPI_HANDLE);
ACPI_HANDLE devhandle_to_acpi(devhandle_t);
#define ACPI_DEVICE_CALL_REGISTER(_n_, _c_) \