pci: Bring back 72876ce0680bbb61ce6bedfb36f18004c36e99fc
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 4 Jul 2009 07:06:20 +0000 (15:06 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 8 Jul 2009 10:50:37 +0000 (18:50 +0800)
sys/bus/pci/pci.c

index a98576c..c84d1b6 100644 (file)
@@ -85,6 +85,7 @@ static int            pci_add_map(device_t pcib, device_t bus, device_t dev,
                            struct resource_list *rl, int force, int prefetch);
 static int             pci_probe(device_t dev);
 static int             pci_attach(device_t dev);
+static void            pci_child_detached(device_t, device_t);
 static void            pci_load_vendor_data(void);
 static int             pci_describe_parse_line(char **ptr, int *vendor,
                            int *device, char **desc);
@@ -126,6 +127,7 @@ static device_method_t pci_methods[] = {
        DEVMETHOD(bus_read_ivar,        pci_read_ivar),
        DEVMETHOD(bus_write_ivar,       pci_write_ivar),
        DEVMETHOD(bus_driver_added,     pci_driver_added),
+       DEVMETHOD(bus_child_detached,   pci_child_detached),
        DEVMETHOD(bus_setup_intr,       pci_setup_intr),
        DEVMETHOD(bus_teardown_intr,    pci_teardown_intr),
 
@@ -2838,6 +2840,13 @@ pci_driver_added(device_t dev, driver_t *driver)
        kfree(devlist, M_TEMP);
 }
 
+static void
+pci_child_detached(device_t parent __unused, device_t child)
+{
+       /* Turn child's power off */
+       pci_cfg_save(child, device_get_ivars(child), 1);
+}
+
 int
 pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags,
     driver_intr_t *intr, void *arg, void **cookiep, lwkt_serialize_t serializer)