]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/shpchp_core.c
Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / shpchp_core.c
index 97848654652a1d2e03e6f648c268012f9b0711d9..cc38615395f1087f10a07764fe8d402524a9830b 100644 (file)
@@ -39,7 +39,6 @@
 int shpchp_debug;
 int shpchp_poll_mode;
 int shpchp_poll_time;
-int shpchp_slot_with_bus;
 struct workqueue_struct *shpchp_wq;
 
 #define DRIVER_VERSION "0.4"
@@ -53,11 +52,9 @@ MODULE_LICENSE("GPL");
 module_param(shpchp_debug, bool, 0644);
 module_param(shpchp_poll_mode, bool, 0644);
 module_param(shpchp_poll_time, int, 0644);
-module_param(shpchp_slot_with_bus, bool, 0644);
 MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
-MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name");
 
 #define SHPC_MODULE_NAME "shpchp"
 
@@ -68,7 +65,6 @@ static int get_power_status   (struct hotplug_slot *slot, u8 *value);
 static int get_attention_status        (struct hotplug_slot *slot, u8 *value);
 static int get_latch_status    (struct hotplug_slot *slot, u8 *value);
 static int get_adapter_status  (struct hotplug_slot *slot, u8 *value);
-static int get_address         (struct hotplug_slot *slot, u32 *value);
 static int get_max_bus_speed   (struct hotplug_slot *slot, enum pci_bus_speed *value);
 static int get_cur_bus_speed   (struct hotplug_slot *slot, enum pci_bus_speed *value);
 
@@ -81,7 +77,6 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
        .get_attention_status = get_attention_status,
        .get_latch_status =     get_latch_status,
        .get_adapter_status =   get_adapter_status,
-       .get_address =          get_address,
        .get_max_bus_speed =    get_max_bus_speed,
        .get_cur_bus_speed =    get_cur_bus_speed,
 };
@@ -101,23 +96,13 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
        kfree(slot);
 }
 
-static void make_slot_name(struct slot *slot)
-{
-       if (shpchp_slot_with_bus)
-               snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
-                        slot->bus, slot->number);
-       else
-               snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d",
-                        slot->number);
-}
-
 static int init_slots(struct controller *ctrl)
 {
        struct slot *slot;
        struct hotplug_slot *hotplug_slot;
        struct hotplug_slot_info *info;
        int retval = -ENOMEM;
-       int i;
+       int i, len, dup = 1;
 
        for (i = 0; i < ctrl->num_slots; i++) {
                slot = kzalloc(sizeof(*slot), GFP_KERNEL);
@@ -148,7 +133,7 @@ static int init_slots(struct controller *ctrl)
                /* register this slot with the hotplug pci core */
                hotplug_slot->private = slot;
                hotplug_slot->release = &release_slot;
-               make_slot_name(slot);
+               snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
                hotplug_slot->ops = &shpchp_hotplug_slot_ops;
 
                get_power_status(hotplug_slot, &info->power_status);
@@ -159,13 +144,23 @@ static int init_slots(struct controller *ctrl)
                dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
                    "slot_device_offset=%x\n", slot->bus, slot->device,
                    slot->hp_slot, slot->number, ctrl->slot_device_offset);
-               retval = pci_hp_register(slot->hotplug_slot);
+duplicate_name:
+               retval = pci_hp_register(slot->hotplug_slot,
+                               ctrl->pci_dev->subordinate, slot->device);
                if (retval) {
+                       /*
+                        * If slot N already exists, we'll try to create
+                        * slot N-1, N-2 ... N-M, until we overflow.
+                        */
+                       if (retval == -EEXIST) {
+                               len = snprintf(slot->name, SLOT_NAME_SIZE,
+                                              "%d-%d", slot->number, dup++);
+                               if (len < SLOT_NAME_SIZE)
+                                       goto duplicate_name;
+                               else
+                                       err("duplicate slot name overflow\n");
+                       }
                        err("pci_hp_register failed with error %d\n", retval);
-                       if (retval == -EEXIST)
-                               err("Failed to register slot because of name "
-                                    "collision. Try \'shpchp_slot_with_bus\' "
-                                   "module option.\n");
                        goto error_info;
                }
 
@@ -288,19 +283,8 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
        return 0;
 }
 
-static int get_address (struct hotplug_slot *hotplug_slot, u32 *value)
-{
-       struct slot *slot = get_slot(hotplug_slot);
-       struct pci_bus *bus = slot->ctrl->pci_dev->subordinate;
-
-       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
-
-       *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device;
-
-       return 0;
-}
-
-static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
+static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
+                               enum pci_bus_speed *value)
 {
        struct slot *slot = get_slot(hotplug_slot);
        int retval;
@@ -330,13 +314,14 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 
 static int is_shpc_capable(struct pci_dev *dev)
 {
-       if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device ==
-                               PCI_DEVICE_ID_AMD_GOLAM_7450))
-               return 1;
-       if (pci_find_capability(dev, PCI_CAP_ID_SHPC))
-               return 1;
-
-       return 0;
+       if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device ==
+                                               PCI_DEVICE_ID_AMD_GOLAM_7450))
+               return 1;
+       if (!pci_find_capability(dev, PCI_CAP_ID_SHPC))
+               return 0;
+       if (get_hp_hw_control_from_firmware(dev))
+               return 0;
+       return 1;
 }
 
 static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)