| .. | .. |
|---|
| 121 | 121 | { |
|---|
| 122 | 122 | u32 tempdword; |
|---|
| 123 | 123 | u32 number_of_slots; |
|---|
| 124 | | - u8 physical_slot; |
|---|
| 125 | 124 | |
|---|
| 126 | 125 | if (!ctrl) |
|---|
| 127 | 126 | return 1; |
|---|
| .. | .. |
|---|
| 131 | 130 | number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; |
|---|
| 132 | 131 | /* Loop through slots */ |
|---|
| 133 | 132 | while (number_of_slots) { |
|---|
| 134 | | - physical_slot = tempdword; |
|---|
| 135 | 133 | writeb(0, ctrl->hpc_reg + SLOT_SERR); |
|---|
| 136 | 134 | tempdword++; |
|---|
| 137 | 135 | number_of_slots--; |
|---|
| .. | .. |
|---|
| 175 | 173 | dbg("%d %d %d %d\n", tbus, tdevice >> 3, tdevice & 0x7, tslot); |
|---|
| 176 | 174 | |
|---|
| 177 | 175 | } |
|---|
| 178 | | - return; |
|---|
| 179 | 176 | } |
|---|
| 180 | 177 | |
|---|
| 181 | 178 | |
|---|
| .. | .. |
|---|
| 275 | 272 | |
|---|
| 276 | 273 | while (old_slot) { |
|---|
| 277 | 274 | next_slot = old_slot->next; |
|---|
| 278 | | - pci_hp_deregister(old_slot->hotplug_slot); |
|---|
| 279 | | - kfree(old_slot->hotplug_slot->info); |
|---|
| 280 | | - kfree(old_slot->hotplug_slot); |
|---|
| 275 | + pci_hp_deregister(&old_slot->hotplug_slot); |
|---|
| 281 | 276 | kfree(old_slot); |
|---|
| 282 | 277 | old_slot = next_slot; |
|---|
| 283 | 278 | } |
|---|
| .. | .. |
|---|
| 419 | 414 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) |
|---|
| 420 | 415 | { |
|---|
| 421 | 416 | struct pci_func *slot_func; |
|---|
| 422 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 417 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 423 | 418 | struct controller *ctrl = slot->ctrl; |
|---|
| 424 | 419 | u8 bus; |
|---|
| 425 | 420 | u8 devfn; |
|---|
| .. | .. |
|---|
| 446 | 441 | static int process_SI(struct hotplug_slot *hotplug_slot) |
|---|
| 447 | 442 | { |
|---|
| 448 | 443 | struct pci_func *slot_func; |
|---|
| 449 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 444 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 450 | 445 | struct controller *ctrl = slot->ctrl; |
|---|
| 451 | 446 | u8 bus; |
|---|
| 452 | 447 | u8 devfn; |
|---|
| .. | .. |
|---|
| 478 | 473 | static int process_SS(struct hotplug_slot *hotplug_slot) |
|---|
| 479 | 474 | { |
|---|
| 480 | 475 | struct pci_func *slot_func; |
|---|
| 481 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 476 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 482 | 477 | struct controller *ctrl = slot->ctrl; |
|---|
| 483 | 478 | u8 bus; |
|---|
| 484 | 479 | u8 devfn; |
|---|
| .. | .. |
|---|
| 505 | 500 | |
|---|
| 506 | 501 | static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value) |
|---|
| 507 | 502 | { |
|---|
| 508 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 503 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 509 | 504 | struct controller *ctrl = slot->ctrl; |
|---|
| 510 | 505 | |
|---|
| 511 | 506 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
|---|
| .. | .. |
|---|
| 516 | 511 | |
|---|
| 517 | 512 | static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) |
|---|
| 518 | 513 | { |
|---|
| 519 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 514 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 520 | 515 | struct controller *ctrl = slot->ctrl; |
|---|
| 521 | 516 | |
|---|
| 522 | 517 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
|---|
| .. | .. |
|---|
| 527 | 522 | |
|---|
| 528 | 523 | static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) |
|---|
| 529 | 524 | { |
|---|
| 530 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 525 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 531 | 526 | struct controller *ctrl = slot->ctrl; |
|---|
| 532 | 527 | |
|---|
| 533 | 528 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
|---|
| .. | .. |
|---|
| 538 | 533 | |
|---|
| 539 | 534 | static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) |
|---|
| 540 | 535 | { |
|---|
| 541 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 536 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 542 | 537 | struct controller *ctrl = slot->ctrl; |
|---|
| 543 | 538 | |
|---|
| 544 | 539 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
|---|
| .. | .. |
|---|
| 550 | 545 | |
|---|
| 551 | 546 | static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) |
|---|
| 552 | 547 | { |
|---|
| 553 | | - struct slot *slot = hotplug_slot->private; |
|---|
| 548 | + struct slot *slot = to_slot(hotplug_slot); |
|---|
| 554 | 549 | struct controller *ctrl = slot->ctrl; |
|---|
| 555 | 550 | |
|---|
| 556 | 551 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
|---|
| .. | .. |
|---|
| 560 | 555 | return 0; |
|---|
| 561 | 556 | } |
|---|
| 562 | 557 | |
|---|
| 563 | | -static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { |
|---|
| 558 | +static const struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { |
|---|
| 564 | 559 | .set_attention_status = set_attention_status, |
|---|
| 565 | 560 | .enable_slot = process_SI, |
|---|
| 566 | 561 | .disable_slot = process_SS, |
|---|
| .. | .. |
|---|
| 578 | 573 | void __iomem *smbios_table) |
|---|
| 579 | 574 | { |
|---|
| 580 | 575 | struct slot *slot; |
|---|
| 581 | | - struct hotplug_slot *hotplug_slot; |
|---|
| 582 | | - struct hotplug_slot_info *hotplug_slot_info; |
|---|
| 583 | 576 | struct pci_bus *bus = ctrl->pci_bus; |
|---|
| 584 | 577 | u8 number_of_slots; |
|---|
| 585 | 578 | u8 slot_device; |
|---|
| .. | .. |
|---|
| 604 | 597 | result = -ENOMEM; |
|---|
| 605 | 598 | goto error; |
|---|
| 606 | 599 | } |
|---|
| 607 | | - |
|---|
| 608 | | - slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), |
|---|
| 609 | | - GFP_KERNEL); |
|---|
| 610 | | - if (!slot->hotplug_slot) { |
|---|
| 611 | | - result = -ENOMEM; |
|---|
| 612 | | - goto error_slot; |
|---|
| 613 | | - } |
|---|
| 614 | | - hotplug_slot = slot->hotplug_slot; |
|---|
| 615 | | - |
|---|
| 616 | | - hotplug_slot->info = kzalloc(sizeof(*(hotplug_slot->info)), |
|---|
| 617 | | - GFP_KERNEL); |
|---|
| 618 | | - if (!hotplug_slot->info) { |
|---|
| 619 | | - result = -ENOMEM; |
|---|
| 620 | | - goto error_hpslot; |
|---|
| 621 | | - } |
|---|
| 622 | | - hotplug_slot_info = hotplug_slot->info; |
|---|
| 623 | 600 | |
|---|
| 624 | 601 | slot->ctrl = ctrl; |
|---|
| 625 | 602 | slot->bus = ctrl->bus; |
|---|
| .. | .. |
|---|
| 669 | 646 | ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; |
|---|
| 670 | 647 | |
|---|
| 671 | 648 | /* register this slot with the hotplug pci core */ |
|---|
| 672 | | - hotplug_slot->private = slot; |
|---|
| 673 | 649 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); |
|---|
| 674 | | - hotplug_slot->ops = &cpqphp_hotplug_slot_ops; |
|---|
| 675 | | - |
|---|
| 676 | | - hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); |
|---|
| 677 | | - hotplug_slot_info->attention_status = |
|---|
| 678 | | - cpq_get_attention_status(ctrl, slot); |
|---|
| 679 | | - hotplug_slot_info->latch_status = |
|---|
| 680 | | - cpq_get_latch_status(ctrl, slot); |
|---|
| 681 | | - hotplug_slot_info->adapter_status = |
|---|
| 682 | | - get_presence_status(ctrl, slot); |
|---|
| 650 | + slot->hotplug_slot.ops = &cpqphp_hotplug_slot_ops; |
|---|
| 683 | 651 | |
|---|
| 684 | 652 | dbg("registering bus %d, dev %d, number %d, ctrl->slot_device_offset %d, slot %d\n", |
|---|
| 685 | 653 | slot->bus, slot->device, |
|---|
| 686 | 654 | slot->number, ctrl->slot_device_offset, |
|---|
| 687 | 655 | slot_number); |
|---|
| 688 | | - result = pci_hp_register(hotplug_slot, |
|---|
| 656 | + result = pci_hp_register(&slot->hotplug_slot, |
|---|
| 689 | 657 | ctrl->pci_dev->bus, |
|---|
| 690 | 658 | slot->device, |
|---|
| 691 | 659 | name); |
|---|
| 692 | 660 | if (result) { |
|---|
| 693 | 661 | err("pci_hp_register failed with error %d\n", result); |
|---|
| 694 | | - goto error_info; |
|---|
| 662 | + goto error_slot; |
|---|
| 695 | 663 | } |
|---|
| 696 | 664 | |
|---|
| 697 | 665 | slot->next = ctrl->slot; |
|---|
| .. | .. |
|---|
| 703 | 671 | } |
|---|
| 704 | 672 | |
|---|
| 705 | 673 | return 0; |
|---|
| 706 | | -error_info: |
|---|
| 707 | | - kfree(hotplug_slot_info); |
|---|
| 708 | | -error_hpslot: |
|---|
| 709 | | - kfree(hotplug_slot); |
|---|
| 710 | 674 | error_slot: |
|---|
| 711 | 675 | kfree(slot); |
|---|
| 712 | 676 | error: |
|---|