]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/pci_hotplug_core.c
pciehp: use get_service_data
[linux-2.6] / drivers / pci / hotplug / pci_hotplug_core.c
index 4df31f375197a0466b4523a24cd305f054429fc5..5f85b1b120e3ddc12c350e2b821c18946ec90e27 100644 (file)
@@ -544,7 +544,9 @@ out:
 
 /**
  * pci_hp_register - register a hotplug_slot with the PCI hotplug subsystem
+ * @bus: bus this slot is on
  * @slot: pointer to the &struct hotplug_slot to register
+ * @slot_nr: slot number
  *
  * Registers a hotplug slot with the pci hotplug subsystem, which will allow
  * userspace interaction to the slot.
@@ -555,7 +557,6 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 {
        int result;
        struct pci_slot *pci_slot;
-       struct hotplug_slot *tmp;
 
        if (slot == NULL)
                return -ENODEV;
@@ -568,10 +569,14 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
        }
 
        /* Check if we have already registered a slot with the same name. */
-       tmp = get_slot_from_name(slot->name);
-       if (tmp)
+       if (get_slot_from_name(slot->name))
                return -EEXIST;
 
+       /*
+        * No problems if we call this interface from both ACPI_PCI_SLOT
+        * driver and call it here again. If we've already created the
+        * pci_slot, the interface will simply bump the refcount.
+        */
        pci_slot = pci_create_slot(bus, slot_nr, slot->name);
        if (IS_ERR(pci_slot))
                return PTR_ERR(pci_slot);
@@ -585,6 +590,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
        slot->pci_slot = pci_slot;
        pci_slot->hotplug = slot;
 
+       /*
+        * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
+        */
+       if (strcmp(kobject_name(&pci_slot->kobj), slot->name)) {
+               result = kobject_rename(&pci_slot->kobj, slot->name);
+               if (result) {
+                       pci_destroy_slot(pci_slot);
+                       return result;
+               }
+       }
+
        spin_lock(&pci_hotplug_slot_list_lock);
        list_add(&slot->slot_list, &pci_hotplug_slot_list);
        spin_unlock(&pci_hotplug_slot_list_lock);
@@ -599,7 +615,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 
 /**
  * pci_hp_deregister - deregister a hotplug_slot with the PCI hotplug subsystem
- * @slot: pointer to the &struct hotplug_slot to deregister
+ * @hotplug: pointer to the &struct hotplug_slot to deregister
  *
  * The @slot must have been registered with the pci hotplug subsystem
  * previously with a call to pci_hp_register().
@@ -635,7 +651,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 
 /**
  * pci_hp_change_slot_info - changes the slot's information structure in the core
- * @slot: pointer to the slot whose info has changed
+ * @hotplug: pointer to the slot whose info has changed
  * @info: pointer to the info copy into the slot's info structure
  *
  * @slot must have been registered with the pci