Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Dec 2024 04:57:49 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 165e8ecbea01 - stable/13 - legacy cpu: Add proper device_probe and device_attach routines
Message-ID:  <202412010457.4B14vnt1097041@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=165e8ecbea011e7661dd48c67579304daa570270

commit 165e8ecbea011e7661dd48c67579304daa570270
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-10-21 14:24:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 21:34:50 +0000

    legacy cpu: Add proper device_probe and device_attach routines
    
    Set a device description in probe and handle both adding and attaching
    children in attach.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D47185
    
    (cherry picked from commit ab4f969f8d305665c478b25d4268501445fa5ba6)
---
 sys/x86/x86/legacy.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/sys/x86/x86/legacy.c b/sys/x86/x86/legacy.c
index 3a5e878be7ed..1bbaf31af0ee 100644
--- a/sys/x86/x86/legacy.c
+++ b/sys/x86/x86/legacy.c
@@ -268,6 +268,8 @@ legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
  * cpufreq(4) hang off this.
  */
 static void	cpu_identify(driver_t *driver, device_t parent);
+static device_probe_t cpu_probe;
+static device_attach_t cpu_attach;
 static int	cpu_read_ivar(device_t dev, device_t child, int index,
 		    uintptr_t *result);
 static device_t cpu_add_child(device_t bus, u_int order, const char *name,
@@ -282,8 +284,8 @@ struct cpu_device {
 static device_method_t cpu_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_identify,	cpu_identify),
-	DEVMETHOD(device_probe,		bus_generic_probe),
-	DEVMETHOD(device_attach,	bus_generic_attach),
+	DEVMETHOD(device_probe,		cpu_probe),
+	DEVMETHOD(device_attach,	cpu_attach),
 	DEVMETHOD(device_detach,	bus_generic_detach),
 	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
 	DEVMETHOD(device_suspend,	bus_generic_suspend),
@@ -331,6 +333,21 @@ cpu_identify(driver_t *driver, device_t parent)
 	}
 }
 
+static int
+cpu_probe(device_t dev)
+{
+	device_set_desc(dev, "legacy CPU");
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+cpu_attach(device_t dev)
+{
+	bus_generic_probe(dev);
+	bus_generic_attach(dev);
+	return (0);
+}
+
 static device_t
 cpu_add_child(device_t bus, u_int order, const char *name, int unit)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412010457.4B14vnt1097041>