Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: pciehp: remove 'name' parameter

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from pciehp's version of struct slot, and remove
unused 'task_list' as well.

Cc: kristen.c.accardi@intel.com
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

authored by

Alex Chiang and committed by
Jesse Barnes
e1acb24f a32615a1

+52 -44
+6 -3
drivers/pci/hotplug/pciehp.h
··· 74 74 struct slot { 75 75 u8 bus; 76 76 u8 device; 77 - u32 number; 78 77 u8 state; 79 - struct timer_list task_event; 80 78 u8 hp_slot; 79 + u32 number; 81 80 struct controller *ctrl; 82 81 struct hpc_ops *hpc_ops; 83 82 struct hotplug_slot *hotplug_slot; 84 83 struct list_head slot_list; 85 - char name[SLOT_NAME_SIZE]; 86 84 unsigned long last_emi_toggle; 87 85 struct delayed_work work; /* work for button event */ 88 86 struct mutex lock; ··· 172 174 int pciehp_enable_slot(struct slot *p_slot); 173 175 int pciehp_disable_slot(struct slot *p_slot); 174 176 int pcie_enable_notification(struct controller *ctrl); 177 + 178 + static inline const char *slot_name(struct slot *slot) 179 + { 180 + return hotplug_slot_name(slot->hotplug_slot); 181 + } 175 182 176 183 static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) 177 184 {
+17 -16
drivers/pci/hotplug/pciehp_core.c
··· 185 185 struct slot *slot = hotplug_slot->private; 186 186 187 187 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 188 - __func__, hotplug_slot->name); 188 + __func__, hotplug_slot_name(hotplug_slot)); 189 189 190 190 kfree(hotplug_slot->info); 191 191 kfree(hotplug_slot); ··· 196 196 struct slot *slot; 197 197 struct hotplug_slot *hotplug_slot; 198 198 struct hotplug_slot_info *info; 199 + char name[SLOT_NAME_SIZE]; 199 200 int retval = -ENOMEM; 200 201 201 202 list_for_each_entry(slot, &ctrl->slot_list, slot_list) { ··· 210 209 211 210 /* register this slot with the hotplug pci core */ 212 211 hotplug_slot->info = info; 213 - hotplug_slot->name = slot->name; 214 212 hotplug_slot->private = slot; 215 213 hotplug_slot->release = &release_slot; 216 214 hotplug_slot->ops = &pciehp_hotplug_slot_ops; 217 - get_power_status(hotplug_slot, &info->power_status); 218 - get_attention_status(hotplug_slot, &info->attention_status); 219 - get_latch_status(hotplug_slot, &info->latch_status); 220 - get_adapter_status(hotplug_slot, &info->adapter_status); 221 215 slot->hotplug_slot = hotplug_slot; 216 + snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); 222 217 223 218 ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x " 224 219 "slot_device_offset=%x\n", slot->bus, slot->device, ··· 222 225 retval = pci_hp_register(hotplug_slot, 223 226 ctrl->pci_dev->subordinate, 224 227 slot->device, 225 - slot->name); 228 + name); 226 229 if (retval) { 227 230 ctrl_err(ctrl, "pci_hp_register failed with error %d\n", 228 231 retval); 229 232 goto error_info; 230 233 } 234 + get_power_status(hotplug_slot, &info->power_status); 235 + get_attention_status(hotplug_slot, &info->attention_status); 236 + get_latch_status(hotplug_slot, &info->latch_status); 237 + get_adapter_status(hotplug_slot, &info->adapter_status); 231 238 /* create additional sysfs entries */ 232 239 if (EMI(ctrl)) { 233 240 retval = sysfs_create_file(&hotplug_slot->pci_slot->kobj, ··· 274 273 struct slot *slot = hotplug_slot->private; 275 274 276 275 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 277 - __func__, hotplug_slot->name); 276 + __func__, slot_name(slot)); 278 277 279 278 hotplug_slot->info->attention_status = status; 280 279 ··· 290 289 struct slot *slot = hotplug_slot->private; 291 290 292 291 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 293 - __func__, hotplug_slot->name); 292 + __func__, slot_name(slot)); 294 293 295 294 return pciehp_sysfs_enable_slot(slot); 296 295 } ··· 301 300 struct slot *slot = hotplug_slot->private; 302 301 303 302 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 304 - __func__, hotplug_slot->name); 303 + __func__, slot_name(slot)); 305 304 306 305 return pciehp_sysfs_disable_slot(slot); 307 306 } ··· 312 311 int retval; 313 312 314 313 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 315 - __func__, hotplug_slot->name); 314 + __func__, slot_name(slot)); 316 315 317 316 retval = slot->hpc_ops->get_power_status(slot, value); 318 317 if (retval < 0) ··· 327 326 int retval; 328 327 329 328 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 330 - __func__, hotplug_slot->name); 329 + __func__, slot_name(slot)); 331 330 332 331 retval = slot->hpc_ops->get_attention_status(slot, value); 333 332 if (retval < 0) ··· 342 341 int retval; 343 342 344 343 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 345 - __func__, hotplug_slot->name); 344 + __func__, slot_name(slot)); 346 345 347 346 retval = slot->hpc_ops->get_latch_status(slot, value); 348 347 if (retval < 0) ··· 357 356 int retval; 358 357 359 358 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 360 - __func__, hotplug_slot->name); 359 + __func__, slot_name(slot)); 361 360 362 361 retval = slot->hpc_ops->get_adapter_status(slot, value); 363 362 if (retval < 0) ··· 373 372 int retval; 374 373 375 374 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 376 - __func__, hotplug_slot->name); 375 + __func__, slot_name(slot)); 377 376 378 377 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 379 378 if (retval < 0) ··· 388 387 int retval; 389 388 390 389 ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 391 - __func__, hotplug_slot->name); 390 + __func__, slot_name(slot)); 392 391 393 392 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 394 393 if (retval < 0)
+29 -24
drivers/pci/hotplug/pciehp_ctrl.c
··· 66 66 /* 67 67 * Button pressed - See if need to TAKE ACTION!!! 68 68 */ 69 - ctrl_info(ctrl, "Button pressed on Slot(%s)\n", p_slot->name); 69 + ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); 70 70 event_type = INT_BUTTON_PRESS; 71 71 72 72 queue_interrupt_event(p_slot, event_type); ··· 88 88 /* 89 89 * Switch opened 90 90 */ 91 - ctrl_info(ctrl, "Latch open on Slot(%s)\n", p_slot->name); 91 + ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot)); 92 92 event_type = INT_SWITCH_OPEN; 93 93 } else { 94 94 /* 95 95 * Switch closed 96 96 */ 97 - ctrl_info(ctrl, "Latch close on Slot(%s)\n", p_slot->name); 97 + ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot)); 98 98 event_type = INT_SWITCH_CLOSE; 99 99 } 100 100 ··· 120 120 /* 121 121 * Card Present 122 122 */ 123 - ctrl_info(ctrl, "Card present on Slot(%s)\n", p_slot->name); 123 + ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot)); 124 124 event_type = INT_PRESENCE_ON; 125 125 } else { 126 126 /* 127 127 * Not Present 128 128 */ 129 - ctrl_info(ctrl, "Card not present on Slot(%s)\n", p_slot->name); 129 + ctrl_info(ctrl, "Card not present on Slot(%s)\n", 130 + slot_name(p_slot)); 130 131 event_type = INT_PRESENCE_OFF; 131 132 } 132 133 ··· 149 148 * power fault Cleared 150 149 */ 151 150 ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n", 152 - p_slot->name); 151 + slot_name(p_slot)); 153 152 event_type = INT_POWER_FAULT_CLEAR; 154 153 } else { 155 154 /* 156 155 * power fault 157 156 */ 158 - ctrl_info(ctrl, "Power fault on Slot(%s)\n", p_slot->name); 157 + ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); 159 158 event_type = INT_POWER_FAULT; 160 159 ctrl_info(ctrl, "power fault bit %x set\n", 0); 161 160 } ··· 413 412 p_slot->state = BLINKINGOFF_STATE; 414 413 ctrl_info(ctrl, 415 414 "PCI slot #%s - powering off due to button " 416 - "press.\n", p_slot->name); 415 + "press.\n", slot_name(p_slot)); 417 416 } else { 418 417 p_slot->state = BLINKINGON_STATE; 419 418 ctrl_info(ctrl, 420 419 "PCI slot #%s - powering on due to button " 421 - "press.\n", p_slot->name); 420 + "press.\n", slot_name(p_slot)); 422 421 } 423 422 /* blink green LED and turn off amber */ 424 423 if (PWR_LED(ctrl)) ··· 435 434 * press the attention again before the 5 sec. limit 436 435 * expires to cancel hot-add or hot-remove 437 436 */ 438 - ctrl_info(ctrl, "Button cancel on Slot(%s)\n", p_slot->name); 437 + ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); 439 438 ctrl_dbg(ctrl, "%s: button cancel\n", __func__); 440 439 cancel_delayed_work(&p_slot->work); 441 440 if (p_slot->state == BLINKINGOFF_STATE) { ··· 448 447 if (ATTN_LED(ctrl)) 449 448 p_slot->hpc_ops->set_attention_status(p_slot, 0); 450 449 ctrl_info(ctrl, "PCI slot #%s - action canceled " 451 - "due to button press\n", p_slot->name); 450 + "due to button press\n", slot_name(p_slot)); 452 451 p_slot->state = STATIC_STATE; 453 452 break; 454 453 case POWEROFF_STATE: ··· 458 457 * this means that the previous attention button action 459 458 * to hot-add or hot-remove is undergoing 460 459 */ 461 - ctrl_info(ctrl, "Button ignore on Slot(%s)\n", p_slot->name); 460 + ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot)); 462 461 update_slot_info(p_slot); 463 462 break; 464 463 default: ··· 541 540 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 542 541 if (rc || !getstatus) { 543 542 ctrl_info(ctrl, "%s: no adapter on slot(%s)\n", 544 - __func__, p_slot->name); 543 + __func__, slot_name(p_slot)); 545 544 mutex_unlock(&p_slot->ctrl->crit_sect); 546 545 return -ENODEV; 547 546 } ··· 549 548 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 550 549 if (rc || getstatus) { 551 550 ctrl_info(ctrl, "%s: latch open on slot(%s)\n", 552 - __func__, p_slot->name); 551 + __func__, slot_name(p_slot)); 553 552 mutex_unlock(&p_slot->ctrl->crit_sect); 554 553 return -ENODEV; 555 554 } ··· 559 558 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 560 559 if (rc || getstatus) { 561 560 ctrl_info(ctrl, "%s: already enabled on slot(%s)\n", 562 - __func__, p_slot->name); 561 + __func__, slot_name(p_slot)); 563 562 mutex_unlock(&p_slot->ctrl->crit_sect); 564 563 return -EINVAL; 565 564 } ··· 595 594 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 596 595 if (ret || !getstatus) { 597 596 ctrl_info(ctrl, "%s: no adapter on slot(%s)\n", 598 - __func__, p_slot->name); 597 + __func__, slot_name(p_slot)); 599 598 mutex_unlock(&p_slot->ctrl->crit_sect); 600 599 return -ENODEV; 601 600 } ··· 605 604 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 606 605 if (ret || getstatus) { 607 606 ctrl_info(ctrl, "%s: latch open on slot(%s)\n", 608 - __func__, p_slot->name); 607 + __func__, slot_name(p_slot)); 609 608 mutex_unlock(&p_slot->ctrl->crit_sect); 610 609 return -ENODEV; 611 610 } ··· 615 614 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 616 615 if (ret || !getstatus) { 617 616 ctrl_info(ctrl, "%s: already disabled slot(%s)\n", 618 - __func__, p_slot->name); 617 + __func__, slot_name(p_slot)); 619 618 mutex_unlock(&p_slot->ctrl->crit_sect); 620 619 return -EINVAL; 621 620 } ··· 646 645 break; 647 646 case POWERON_STATE: 648 647 ctrl_info(ctrl, "Slot %s is already in powering on state\n", 649 - p_slot->name); 648 + slot_name(p_slot)); 650 649 break; 651 650 case BLINKINGOFF_STATE: 652 651 case POWEROFF_STATE: 653 - ctrl_info(ctrl, "Already enabled on slot %s\n", p_slot->name); 652 + ctrl_info(ctrl, "Already enabled on slot %s\n", 653 + slot_name(p_slot)); 654 654 break; 655 655 default: 656 - ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name); 656 + ctrl_err(ctrl, "Not a valid state on slot %s\n", 657 + slot_name(p_slot)); 657 658 break; 658 659 } 659 660 mutex_unlock(&p_slot->lock); ··· 681 678 break; 682 679 case POWEROFF_STATE: 683 680 ctrl_info(ctrl, "Slot %s is already in powering off state\n", 684 - p_slot->name); 681 + slot_name(p_slot)); 685 682 break; 686 683 case BLINKINGON_STATE: 687 684 case POWERON_STATE: 688 - ctrl_info(ctrl, "Already disabled on slot %s\n", p_slot->name); 685 + ctrl_info(ctrl, "Already disabled on slot %s\n", 686 + slot_name(p_slot)); 689 687 break; 690 688 default: 691 - ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name); 689 + ctrl_err(ctrl, "Not a valid state on slot %s\n", 690 + slot_name(p_slot)); 692 691 break; 693 692 } 694 693 mutex_unlock(&p_slot->lock);
-1
drivers/pci/hotplug/pciehp_hpc.c
··· 1061 1061 slot->device = ctrl->slot_device_offset + slot->hp_slot; 1062 1062 slot->hpc_ops = ctrl->hpc_ops; 1063 1063 slot->number = ctrl->first_slot; 1064 - snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); 1065 1064 mutex_init(&slot->lock); 1066 1065 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); 1067 1066 list_add(&slot->slot_list, &ctrl->slot_list);