Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
PCI: fix reference leak in pci_get_dev_by_id()
PCI: shpchp: Rename duplicate slot name N as N-1, N-2, N-M...
PCI: pciehp: Rename duplicate slot name N as N-1, N-2, N-M...

+32 -37
-1
drivers/pci/hotplug/pciehp.h
··· 43 43 extern int pciehp_poll_time; 44 44 extern int pciehp_debug; 45 45 extern int pciehp_force; 46 - extern int pciehp_slot_with_bus; 47 46 extern struct workqueue_struct *pciehp_wq; 48 47 49 48 #define dbg(format, arg...) \
+14 -7
drivers/pci/hotplug/pciehp_core.c
··· 41 41 int pciehp_poll_mode; 42 42 int pciehp_poll_time; 43 43 int pciehp_force; 44 - int pciehp_slot_with_bus; 45 44 struct workqueue_struct *pciehp_wq; 46 45 47 46 #define DRIVER_VERSION "0.4" ··· 55 56 module_param(pciehp_poll_mode, bool, 0644); 56 57 module_param(pciehp_poll_time, int, 0644); 57 58 module_param(pciehp_force, bool, 0644); 58 - module_param(pciehp_slot_with_bus, bool, 0644); 59 59 MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not"); 60 60 MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not"); 61 61 MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds"); 62 62 MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing"); 63 - MODULE_PARM_DESC(pciehp_slot_with_bus, "Use bus number in the slot name"); 64 63 65 64 #define PCIE_MODULE_NAME "pciehp" 66 65 ··· 191 194 struct slot *slot; 192 195 struct hotplug_slot *hotplug_slot; 193 196 struct hotplug_slot_info *info; 197 + int len, dup = 1; 194 198 int retval = -ENOMEM; 195 199 196 200 list_for_each_entry(slot, &ctrl->slot_list, slot_list) { ··· 218 220 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " 219 221 "slot_device_offset=%x\n", slot->bus, slot->device, 220 222 slot->hp_slot, slot->number, ctrl->slot_device_offset); 223 + duplicate_name: 221 224 retval = pci_hp_register(hotplug_slot, 222 225 ctrl->pci_dev->subordinate, 223 226 slot->device); 224 227 if (retval) { 228 + /* 229 + * If slot N already exists, we'll try to create 230 + * slot N-1, N-2 ... N-M, until we overflow. 231 + */ 232 + if (retval == -EEXIST) { 233 + len = snprintf(slot->name, SLOT_NAME_SIZE, 234 + "%d-%d", slot->number, dup++); 235 + if (len < SLOT_NAME_SIZE) 236 + goto duplicate_name; 237 + else 238 + err("duplicate slot name overflow\n"); 239 + } 225 240 err("pci_hp_register failed with error %d\n", retval); 226 - if (retval == -EEXIST) 227 - err("Failed to register slot because of name " 228 - "collision. Try \'pciehp_slot_with_bus\' " 229 - "module option.\n"); 230 241 goto error_info; 231 242 } 232 243 /* create additional sysfs entries */
+1 -10
drivers/pci/hotplug/pciehp_hpc.c
··· 1030 1030 pciehp_free_irq(ctrl); 1031 1031 } 1032 1032 1033 - static void make_slot_name(struct slot *slot) 1034 - { 1035 - if (pciehp_slot_with_bus) 1036 - snprintf(slot->name, SLOT_NAME_SIZE, "%04d_%04d", 1037 - slot->bus, slot->number); 1038 - else 1039 - snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); 1040 - } 1041 - 1042 1033 static int pcie_init_slot(struct controller *ctrl) 1043 1034 { 1044 1035 struct slot *slot; ··· 1044 1053 slot->device = ctrl->slot_device_offset + slot->hp_slot; 1045 1054 slot->hpc_ops = ctrl->hpc_ops; 1046 1055 slot->number = ctrl->first_slot; 1047 - make_slot_name(slot); 1056 + snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); 1048 1057 mutex_init(&slot->lock); 1049 1058 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); 1050 1059 list_add(&slot->slot_list, &ctrl->slot_list);
+15 -19
drivers/pci/hotplug/shpchp_core.c
··· 39 39 int shpchp_debug; 40 40 int shpchp_poll_mode; 41 41 int shpchp_poll_time; 42 - static int shpchp_slot_with_bus; 43 42 struct workqueue_struct *shpchp_wq; 44 43 45 44 #define DRIVER_VERSION "0.4" ··· 52 53 module_param(shpchp_debug, bool, 0644); 53 54 module_param(shpchp_poll_mode, bool, 0644); 54 55 module_param(shpchp_poll_time, int, 0644); 55 - module_param(shpchp_slot_with_bus, bool, 0644); 56 56 MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not"); 57 57 MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not"); 58 58 MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds"); 59 - MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name"); 60 59 61 60 #define SHPC_MODULE_NAME "shpchp" 62 61 ··· 96 99 kfree(slot); 97 100 } 98 101 99 - static void make_slot_name(struct slot *slot) 100 - { 101 - if (shpchp_slot_with_bus) 102 - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", 103 - slot->bus, slot->number); 104 - else 105 - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", 106 - slot->number); 107 - } 108 - 109 102 static int init_slots(struct controller *ctrl) 110 103 { 111 104 struct slot *slot; 112 105 struct hotplug_slot *hotplug_slot; 113 106 struct hotplug_slot_info *info; 114 107 int retval = -ENOMEM; 115 - int i; 108 + int i, len, dup = 1; 116 109 117 110 for (i = 0; i < ctrl->num_slots; i++) { 118 111 slot = kzalloc(sizeof(*slot), GFP_KERNEL); ··· 133 146 /* register this slot with the hotplug pci core */ 134 147 hotplug_slot->private = slot; 135 148 hotplug_slot->release = &release_slot; 136 - make_slot_name(slot); 149 + snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); 137 150 hotplug_slot->ops = &shpchp_hotplug_slot_ops; 138 151 139 152 get_power_status(hotplug_slot, &info->power_status); ··· 144 157 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " 145 158 "slot_device_offset=%x\n", slot->bus, slot->device, 146 159 slot->hp_slot, slot->number, ctrl->slot_device_offset); 160 + duplicate_name: 147 161 retval = pci_hp_register(slot->hotplug_slot, 148 162 ctrl->pci_dev->subordinate, slot->device); 149 163 if (retval) { 164 + /* 165 + * If slot N already exists, we'll try to create 166 + * slot N-1, N-2 ... N-M, until we overflow. 167 + */ 168 + if (retval == -EEXIST) { 169 + len = snprintf(slot->name, SLOT_NAME_SIZE, 170 + "%d-%d", slot->number, dup++); 171 + if (len < SLOT_NAME_SIZE) 172 + goto duplicate_name; 173 + else 174 + err("duplicate slot name overflow\n"); 175 + } 150 176 err("pci_hp_register failed with error %d\n", retval); 151 - if (retval == -EEXIST) 152 - err("Failed to register slot because of name " 153 - "collision. Try \'shpchp_slot_with_bus\' " 154 - "module option.\n"); 155 177 goto error_info; 156 178 } 157 179
+2
drivers/pci/search.c
··· 280 280 match_pci_dev_by_id); 281 281 if (dev) 282 282 pdev = to_pci_dev(dev); 283 + if (from) 284 + pci_dev_put(from); 283 285 return pdev; 284 286 } 285 287