Author: avg
Date: Sat Sep 18 07:16:38 2010
New Revision: 212810
URL: http://svn.freebsd.org/changeset/base/212810

Log:
  MFC r212251,212457: make acpi_hp device a child of acpi_wmi
  
  PR:           kern/147858

Modified:
  stable/8/sys/dev/acpi_support/acpi_hp.c
  stable/8/sys/dev/acpi_support/acpi_wmi.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/acpi_support/acpi_hp.c
==============================================================================
--- stable/8/sys/dev/acpi_support/acpi_hp.c     Sat Sep 18 00:58:44 2010        
(r212809)
+++ stable/8/sys/dev/acpi_support/acpi_hp.c     Sat Sep 18 07:16:38 2010        
(r212810)
@@ -116,7 +116,6 @@ struct acpi_hp_inst_seq_pair {
 
 struct acpi_hp_softc {
        device_t        dev;
-       ACPI_HANDLE     handle;
        device_t        wmi_dev;
        int             has_notify;             /* notification GUID found */
        int             has_cmi;                /* CMI GUID found */
@@ -289,6 +288,7 @@ static struct {
 
 ACPI_SERIAL_DECL(hp, "HP ACPI-WMI Mapping");
 
+static void    acpi_hp_identify(driver_t *driver, device_t parent);
 static int     acpi_hp_probe(device_t dev);
 static int     acpi_hp_attach(device_t dev);
 static int     acpi_hp_detach(device_t dev);
@@ -320,6 +320,7 @@ static struct cdevsw hpcmi_cdevsw = {
 };
 
 static device_method_t acpi_hp_methods[] = {
+       DEVMETHOD(device_identify, acpi_hp_identify),
        DEVMETHOD(device_probe, acpi_hp_probe),
        DEVMETHOD(device_attach, acpi_hp_attach),
        DEVMETHOD(device_detach, acpi_hp_detach),
@@ -334,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);
@@ -405,7 +406,7 @@ acpi_hp_evaluate_auto_on_off(struct acpi
                                    "WLAN on air changed to %i "
                                    "(new_wlan_status is %i)\n",
                                    sc->was_wlan_on_air, new_wlan_status);
-                       acpi_UserNotify("HP", sc->handle,
+                       acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
                            0xc0+sc->was_wlan_on_air);
                }
        }
@@ -420,7 +421,7 @@ acpi_hp_evaluate_auto_on_off(struct acpi
                                    " to %i (new_bluetooth_status is %i)\n",
                                    sc->was_bluetooth_on_air,
                                    new_bluetooth_status);
-                       acpi_UserNotify("HP", sc->handle,
+                       acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
                            0xd0+sc->was_bluetooth_on_air);
                }
        }
@@ -433,19 +434,33 @@ acpi_hp_evaluate_auto_on_off(struct acpi
                                    "WWAN on air changed to %i"
                                    " (new_wwan_status is %i)\n",
                                    sc->was_wwan_on_air, new_wwan_status);
-                       acpi_UserNotify("HP", sc->handle,
+                       acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
                            0xe0+sc->was_wwan_on_air);
                }
        }
 }
 
+static void
+acpi_hp_identify(driver_t *driver, device_t parent)
+{
+
+       /* Don't do anything if driver is disabled. */
+       if (acpi_disabled("hp"))
+               return;
+
+       /* Add only a single device instance. */
+       if (device_find_child(parent, "acpi_hp", -1) != NULL)
+               return;
+
+       if (BUS_ADD_CHILD(parent, 0, "acpi_hp", -1) == NULL)
+               device_printf(parent, "add acpi_hp child failed\n");
+}
+
 static int
 acpi_hp_probe(device_t dev)
 {
-       if (acpi_disabled("hp") || device_get_unit(dev) != 0)
-               return (ENXIO);
-       device_set_desc(dev, "HP ACPI-WMI Mapping");
 
+       device_set_desc(dev, "HP ACPI-WMI Mapping");
        return (0);
 }
 
@@ -453,14 +468,12 @@ 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__);
 
        sc = device_get_softc(dev);
        sc->dev = dev;
-       sc->handle = acpi_get_handle(dev);
        sc->has_notify = 0;
        sc->has_cmi = 0;
        sc->bluetooth_enable_if_radio_on = 0;
@@ -477,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: stable/8/sys/dev/acpi_support/acpi_wmi.c
==============================================================================
--- stable/8/sys/dev/acpi_support/acpi_wmi.c    Sat Sep 18 00:58:44 2010        
(r212809)
+++ stable/8/sys/dev/acpi_support/acpi_wmi.c    Sat Sep 18 07:16:38 2010        
(r212810)
@@ -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);
 }
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to