]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/pciehp_core.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireles...
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / pciehp_core.c
index 5fa4ba0d9934e42418eb5e07451685dc7ac5956a..48a2ed378914f383056d7e803ad4c58b044b3ec4 100644 (file)
@@ -41,6 +41,7 @@ int pciehp_debug;
 int pciehp_poll_mode;
 int pciehp_poll_time;
 int pciehp_force;
+int pciehp_slot_with_bus;
 struct workqueue_struct *pciehp_wq;
 
 #define DRIVER_VERSION "0.4"
@@ -55,10 +56,12 @@ module_param(pciehp_debug, bool, 0644);
 module_param(pciehp_poll_mode, bool, 0644);
 module_param(pciehp_poll_time, int, 0644);
 module_param(pciehp_force, bool, 0644);
+module_param(pciehp_slot_with_bus, bool, 0644);
 MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
 MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
+MODULE_PARM_DESC(pciehp_slot_with_bus, "Use bus number in the slot name");
 
 #define PCIE_MODULE_NAME "pciehp"
 
@@ -184,7 +187,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
        struct slot *slot = hotplug_slot->private;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        kfree(slot->hotplug_slot->info);
        kfree(slot->hotplug_slot);
@@ -193,8 +196,12 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 static void make_slot_name(struct slot *slot)
 {
-       snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
-                slot->bus, slot->number);
+       if (pciehp_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)
@@ -247,11 +254,15 @@ static int init_slots(struct controller *ctrl)
                    slot->hp_slot, slot->number, ctrl->slot_device_offset);
                retval = pci_hp_register(hotplug_slot);
                if (retval) {
-                       err ("pci_hp_register failed with error %d\n", retval);
+                       err("pci_hp_register failed with error %d\n", retval);
+                       if (retval == -EEXIST)
+                               err("Failed to register slot because of name "
+                                   "collision. Try \'pciehp_slot_with_bus\' "
+                                   "module option.\n");
                        goto error_info;
                }
                /* create additional sysfs entries */
-               if (EMI(ctrl->ctrlcap)) {
+               if (EMI(ctrl)) {
                        retval = sysfs_create_file(&hotplug_slot->kobj,
                                &hotplug_slot_attr_lock.attr);
                        if (retval) {
@@ -284,7 +295,7 @@ static void cleanup_slots(struct controller *ctrl)
        list_for_each_safe(tmp, next, &ctrl->slot_list) {
                slot = list_entry(tmp, struct slot, slot_list);
                list_del(&slot->slot_list);
-               if (EMI(ctrl->ctrlcap))
+               if (EMI(ctrl))
                        sysfs_remove_file(&slot->hotplug_slot->kobj,
                                &hotplug_slot_attr_lock.attr);
                cancel_delayed_work(&slot->work);
@@ -301,11 +312,11 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
 {
        struct slot *slot = hotplug_slot->private;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        hotplug_slot->info->attention_status = status;
 
-       if (ATTN_LED(slot->ctrl->ctrlcap))
+       if (ATTN_LED(slot->ctrl))
                slot->hpc_ops->set_attention_status(slot, status);
 
        return 0;
@@ -316,7 +327,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
        struct slot *slot = hotplug_slot->private;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        return pciehp_sysfs_enable_slot(slot);
 }
@@ -326,7 +337,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 {
        struct slot *slot = hotplug_slot->private;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        return pciehp_sysfs_disable_slot(slot);
 }
@@ -336,7 +347,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_power_status(slot, value);
        if (retval < 0)
@@ -350,7 +361,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_attention_status(slot, value);
        if (retval < 0)
@@ -364,7 +375,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_latch_status(slot, value);
        if (retval < 0)
@@ -378,7 +389,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_adapter_status(slot, value);
        if (retval < 0)
@@ -392,7 +403,7 @@ static int get_address(struct hotplug_slot *hotplug_slot, u32 *value)
        struct slot *slot = hotplug_slot->private;
        struct pci_bus *bus = slot->ctrl->pci_dev->subordinate;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device;
 
@@ -404,7 +415,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_max_bus_speed(slot, value);
        if (retval < 0)
@@ -418,7 +429,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        struct slot *slot = hotplug_slot->private;
        int retval;
 
-       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+       dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
        if (retval < 0)
@@ -437,7 +448,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
 
        ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
        if (!ctrl) {
-               err("%s : out of memory\n", __FUNCTION__);
+               err("%s : out of memory\n", __func__);
                goto err_out_none;
        }
        INIT_LIST_HEAD(&ctrl->slot_list);
@@ -454,7 +465,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        pci_set_drvdata(pdev, ctrl);
 
        dbg("%s: ctrl bus=0x%x, device=%x, function=%x, irq=%x\n",
-           __FUNCTION__, pdev->bus->number, PCI_SLOT(pdev->devfn),
+           __func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
            PCI_FUNC(pdev->devfn), pdev->irq);
 
        /* Setup the slot information structures */
@@ -472,7 +483,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
                if (rc) /* -ENODEV: shouldn't happen, but deal with it */
                        value = 0;
        }
-       if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
+       if ((POWER_CTRL(ctrl)) && !value) {
                rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
                if (rc)
                        goto err_out_free_ctrl_slot;
@@ -503,13 +514,13 @@ static void pciehp_remove (struct pcie_device *dev)
 #ifdef CONFIG_PM
 static int pciehp_suspend (struct pcie_device *dev, pm_message_t state)
 {
-       printk("%s ENTRY\n", __FUNCTION__);
+       printk("%s ENTRY\n", __func__);
        return 0;
 }
 
 static int pciehp_resume (struct pcie_device *dev)
 {
-       printk("%s ENTRY\n", __FUNCTION__);
+       printk("%s ENTRY\n", __func__);
        if (pciehp_force) {
                struct pci_dev *pdev = dev->port;
                struct controller *ctrl = pci_get_drvdata(pdev);
@@ -563,7 +574,7 @@ static int __init pcied_init(void)
        dbg("pcie_port_service_register = %d\n", retval);
        info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
        if (retval)
-               dbg("%s: Failure to register service\n", __FUNCTION__);
+               dbg("%s: Failure to register service\n", __func__);
        return retval;
 }