]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/pciehp_pci.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6
[linux-2.6] / drivers / pci / hotplug / pciehp_pci.c
index 922b1831c6801ed0f92791770633c9d8a0ab3c28..c424aded13fb43fb108d41870d1c4f46c207de28 100644 (file)
@@ -225,6 +225,7 @@ int pciehp_configure_device(struct slot *p_slot)
                if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
                        err("Cannot hot-add display device %s\n",
                                        pci_name(dev));
+                       pci_dev_put(dev);
                        continue;
                }
                if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
@@ -232,6 +233,7 @@ int pciehp_configure_device(struct slot *p_slot)
                        pciehp_add_bridge(dev);
                }
                program_fw_provided_values(dev);
+               pci_dev_put(dev);
        }
 
        pci_bus_assign_resources(parent);
@@ -241,9 +243,10 @@ int pciehp_configure_device(struct slot *p_slot)
 
 int pciehp_unconfigure_device(struct slot *p_slot)
 {
-       int rc = 0;
+       int ret, rc = 0;
        int j;
        u8 bctl = 0;
+       u8 presence = 0;
        struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
 
        dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus,
@@ -261,23 +264,28 @@ int pciehp_unconfigure_device(struct slot *p_slot)
                        continue;
                }
                if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
-                       pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
-                       if (bctl & PCI_BRIDGE_CTL_VGA) {
-                               err("Cannot remove display device %s\n",
+                       ret = p_slot->hpc_ops->get_adapter_status(p_slot,
+                                                               &presence);
+                       if (!ret && presence) {
+                               pci_read_config_byte(temp, PCI_BRIDGE_CONTROL,
+                                       &bctl);
+                               if (bctl & PCI_BRIDGE_CTL_VGA) {
+                                       err("Cannot remove display device %s\n",
                                                pci_name(temp));
-                               pci_dev_put(temp);
-                               continue;
+                                       pci_dev_put(temp);
+                                       continue;
+                               }
                        }
                }
                pci_remove_bus_device(temp);
                pci_dev_put(temp);
        }
-       /* 
+       /*
         * Some PCI Express root ports require fixup after hot-plug operation.
         */
-       if (pcie_mch_quirk) 
+       if (pcie_mch_quirk)
                pci_fixup_device(pci_fixup_final, p_slot->ctrl->pci_dev);
-       
+
        return rc;
 }