svn commit: r212457 - head/sys/dev/acpi_support

Andriy Gapon avg at FreeBSD.org
Sat Sep 11 08:09:14 UTC 2010


Author: avg
Date: Sat Sep 11 08:09:14 2010
New Revision: 212457
URL: http://svn.freebsd.org/changeset/base/212457

Log:
  make acpi_hp device a child of acpi_wmi
  
  to properly reflect dependency between the devices/drivers
  
  PR:		kern/147858
  Suggested by:	jhb
  Tested by:	Maciej Suszko <maciej at suszko.eu>
  MFC after:	1 week

Modified:
  head/sys/dev/acpi_support/acpi_hp.c
  head/sys/dev/acpi_support/acpi_wmi.c

Modified: head/sys/dev/acpi_support/acpi_hp.c
==============================================================================
--- head/sys/dev/acpi_support/acpi_hp.c	Sat Sep 11 07:24:10 2010	(r212456)
+++ head/sys/dev/acpi_support/acpi_hp.c	Sat Sep 11 08:09:14 2010	(r212457)
@@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/uio.h>
 #include <sys/proc.h>
 #include <sys/kernel.h>
-#include <sys/limits.h>
 #include <sys/bus.h>
 #include <sys/sbuf.h>
 #include <sys/module.h>
@@ -336,7 +335,7 @@ static driver_t	acpi_hp_driver = {
 
 static devclass_t acpi_hp_devclass;
 
-DRIVER_MODULE(acpi_hp, acpi, acpi_hp_driver, acpi_hp_devclass,
+DRIVER_MODULE(acpi_hp, acpi_wmi, acpi_hp_driver, acpi_hp_devclass,
 		0, 0);
 MODULE_DEPEND(acpi_hp, acpi_wmi, 1, 1, 1);
 MODULE_DEPEND(acpi_hp, acpi, 1, 1, 1);
@@ -453,16 +452,7 @@ acpi_hp_identify(driver_t *driver, devic
 	if (device_find_child(parent, "acpi_hp", -1) != NULL)
 		return;
 
-	/* Make sure acpi_wmi driver is present. */
-	if (devclass_find("acpi_wmi") == NULL)
-		return;
-
-	/*
-	 * Add our device with late order, so that it is hopefully
-	 * probed after acpi_wmi.
-	 * XXX User proper constant instead of UINT_MAX for order.
-	 */
-	if (BUS_ADD_CHILD(parent, UINT_MAX, "acpi_hp", -1) == NULL)
+	if (BUS_ADD_CHILD(parent, 0, "acpi_hp", -1) == NULL)
 		device_printf(parent, "add acpi_hp child failed\n");
 }
 
@@ -470,11 +460,7 @@ static int
 acpi_hp_probe(device_t dev)
 {
 
-	/* Skip auto-enumerated devices from ACPI namespace. */
-	if (acpi_get_handle(dev) != NULL)
-		return (ENXIO);
 	device_set_desc(dev, "HP ACPI-WMI Mapping");
-
 	return (0);
 }
 
@@ -482,7 +468,6 @@ static int
 acpi_hp_attach(device_t dev)
 {
 	struct acpi_hp_softc	*sc;
-	devclass_t		wmi_devclass;
 	int			arg;
 
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
@@ -505,14 +490,7 @@ acpi_hp_attach(device_t dev)
 	sc->verbose = 0;
 	memset(sc->cmi_order, 0, sizeof(sc->cmi_order));
 
-	if (!(wmi_devclass = devclass_find("acpi_wmi"))) {
-		device_printf(dev, "Couldn't find acpi_wmi devclass\n");
-		return (EINVAL);
-	}
-	if (!(sc->wmi_dev = devclass_get_device(wmi_devclass, 0))) {
-		device_printf(dev, "Couldn't find acpi_wmi device\n");
-		return (EINVAL);
-	}
+	sc->wmi_dev = device_get_parent(dev);
 	if (!ACPI_WMI_PROVIDES_GUID_STRING(sc->wmi_dev,
 	    ACPI_HP_WMI_BIOS_GUID)) {
 		device_printf(dev,

Modified: head/sys/dev/acpi_support/acpi_wmi.c
==============================================================================
--- head/sys/dev/acpi_support/acpi_wmi.c	Sat Sep 11 07:24:10 2010	(r212456)
+++ head/sys/dev/acpi_support/acpi_wmi.c	Sat Sep 11 08:09:14 2010	(r212457)
@@ -173,6 +173,10 @@ static device_method_t acpi_wmi_methods[
 	DEVMETHOD(device_attach, acpi_wmi_attach),
 	DEVMETHOD(device_detach, acpi_wmi_detach),
 
+	/* bus interface */
+	DEVMETHOD(bus_add_child,	bus_generic_add_child),
+	DEVMETHOD(bus_print_child,	bus_generic_print_child),
+
 	/* acpi_wmi interface */
 	DEVMETHOD(acpi_wmi_provides_guid_string,
 		    acpi_wmi_provides_guid_string_method),
@@ -269,6 +273,11 @@ acpi_wmi_attach(device_t dev)
 	}
 	ACPI_SERIAL_END(acpi_wmi);
 
+	if (ret == 0) {
+		bus_generic_probe(dev);
+		ret = bus_generic_attach(dev);
+	}
+
 	return (ret);
 }
 


More information about the svn-src-head mailing list