hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/pci/hotplug/ibmphp_ebda.c
....@@ -666,36 +666,8 @@
666666 struct slot *slot;
667667 int rc = 0;
668668
669
- if (!hotplug_slot || !hotplug_slot->private)
670
- return -EINVAL;
671
-
672
- slot = hotplug_slot->private;
669
+ slot = to_slot(hotplug_slot);
673670 rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL);
674
- if (rc)
675
- return rc;
676
-
677
- // power - enabled:1 not:0
678
- hotplug_slot->info->power_status = SLOT_POWER(slot->status);
679
-
680
- // attention - off:0, on:1, blinking:2
681
- hotplug_slot->info->attention_status = SLOT_ATTN(slot->status, slot->ext_status);
682
-
683
- // latch - open:1 closed:0
684
- hotplug_slot->info->latch_status = SLOT_LATCH(slot->status);
685
-
686
- // pci board - present:1 not:0
687
- if (SLOT_PRESENT(slot->status))
688
- hotplug_slot->info->adapter_status = 1;
689
- else
690
- hotplug_slot->info->adapter_status = 0;
691
-/*
692
- if (slot->bus_on->supported_bus_mode
693
- && (slot->bus_on->supported_speed == BUS_SPEED_66))
694
- hotplug_slot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
695
- else
696
- hotplug_slot->info->max_bus_speed_status = slot->bus_on->supported_speed;
697
-*/
698
-
699671 return rc;
700672 }
701673
....@@ -712,7 +684,6 @@
712684 u8 ctlr_id, temp, bus_index;
713685 u16 ctlr, slot, bus;
714686 u16 slot_num, bus_num, index;
715
- struct hotplug_slot *hp_slot_ptr;
716687 struct controller *hpc_ptr;
717688 struct ebda_hpc_bus *bus_ptr;
718689 struct ebda_hpc_slot *slot_ptr;
....@@ -743,8 +714,7 @@
743714 /* init hpc structure */
744715 hpc_ptr = alloc_ebda_hpc(slot_num, bus_num);
745716 if (!hpc_ptr) {
746
- rc = -ENOMEM;
747
- goto error_no_hpc;
717
+ return -ENOMEM;
748718 }
749719 hpc_ptr->ctlr_id = ctlr_id;
750720 hpc_ptr->ctlr_relative_id = ctlr;
....@@ -771,7 +741,7 @@
771741 bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
772742 if (!bus_info_ptr1) {
773743 rc = -ENOMEM;
774
- goto error_no_hp_slot;
744
+ goto error_no_slot;
775745 }
776746 bus_info_ptr1->slot_min = slot_ptr->slot_num;
777747 bus_info_ptr1->slot_max = slot_ptr->slot_num;
....@@ -842,7 +812,7 @@
842812 (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1),
843813 "ibmphp")) {
844814 rc = -ENODEV;
845
- goto error_no_hp_slot;
815
+ goto error_no_slot;
846816 }
847817 hpc_ptr->irq = readb(io_mem + addr + 4);
848818 addr += 5;
....@@ -857,7 +827,7 @@
857827 break;
858828 default:
859829 rc = -ENODEV;
860
- goto error_no_hp_slot;
830
+ goto error_no_slot;
861831 }
862832
863833 //reorganize chassis' linked list
....@@ -870,19 +840,6 @@
870840
871841 // register slots with hpc core as well as create linked list of ibm slot
872842 for (index = 0; index < hpc_ptr->slot_count; index++) {
873
-
874
- hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
875
- if (!hp_slot_ptr) {
876
- rc = -ENOMEM;
877
- goto error_no_hp_slot;
878
- }
879
-
880
- hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
881
- if (!hp_slot_ptr->info) {
882
- rc = -ENOMEM;
883
- goto error_no_hp_info;
884
- }
885
-
886843 tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
887844 if (!tmp_slot) {
888845 rc = -ENOMEM;
....@@ -909,7 +866,6 @@
909866
910867 bus_info_ptr1 = ibmphp_find_same_bus_num(hpc_ptr->slots[index].slot_bus_num);
911868 if (!bus_info_ptr1) {
912
- kfree(tmp_slot);
913869 rc = -ENODEV;
914870 goto error;
915871 }
....@@ -919,22 +875,19 @@
919875
920876 tmp_slot->ctlr_index = hpc_ptr->slots[index].ctl_index;
921877 tmp_slot->number = hpc_ptr->slots[index].slot_num;
922
- tmp_slot->hotplug_slot = hp_slot_ptr;
923878
924
- hp_slot_ptr->private = tmp_slot;
925
-
926
- rc = fillslotinfo(hp_slot_ptr);
879
+ rc = fillslotinfo(&tmp_slot->hotplug_slot);
927880 if (rc)
928881 goto error;
929882
930
- rc = ibmphp_init_devno((struct slot **) &hp_slot_ptr->private);
883
+ rc = ibmphp_init_devno(&tmp_slot);
931884 if (rc)
932885 goto error;
933
- hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops;
886
+ tmp_slot->hotplug_slot.ops = &ibmphp_hotplug_slot_ops;
934887
935888 // end of registering ibm slot with hotplug core
936889
937
- list_add(&((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head);
890
+ list_add(&tmp_slot->ibm_slot_list, &ibmphp_slot_head);
938891 }
939892
940893 print_bus_info();
....@@ -944,7 +897,7 @@
944897
945898 list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
946899 snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot));
947
- pci_hp_register(tmp_slot->hotplug_slot,
900
+ pci_hp_register(&tmp_slot->hotplug_slot,
948901 pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
949902 }
950903
....@@ -953,15 +906,9 @@
953906 return 0;
954907
955908 error:
956
- kfree(hp_slot_ptr->private);
909
+ kfree(tmp_slot);
957910 error_no_slot:
958
- kfree(hp_slot_ptr->info);
959
-error_no_hp_info:
960
- kfree(hp_slot_ptr);
961
-error_no_hp_slot:
962911 free_ebda_hpc(hpc_ptr);
963
-error_no_hpc:
964
- iounmap(io_mem);
965912 return rc;
966913 }
967914