hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pci/hotplug/cpqphp_core.c
....@@ -121,7 +121,6 @@
121121 {
122122 u32 tempdword;
123123 u32 number_of_slots;
124
- u8 physical_slot;
125124
126125 if (!ctrl)
127126 return 1;
....@@ -131,7 +130,6 @@
131130 number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
132131 /* Loop through slots */
133132 while (number_of_slots) {
134
- physical_slot = tempdword;
135133 writeb(0, ctrl->hpc_reg + SLOT_SERR);
136134 tempdword++;
137135 number_of_slots--;
....@@ -175,7 +173,6 @@
175173 dbg("%d %d %d %d\n", tbus, tdevice >> 3, tdevice & 0x7, tslot);
176174
177175 }
178
- return;
179176 }
180177
181178
....@@ -275,9 +272,7 @@
275272
276273 while (old_slot) {
277274 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);
281276 kfree(old_slot);
282277 old_slot = next_slot;
283278 }
....@@ -419,7 +414,7 @@
419414 static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
420415 {
421416 struct pci_func *slot_func;
422
- struct slot *slot = hotplug_slot->private;
417
+ struct slot *slot = to_slot(hotplug_slot);
423418 struct controller *ctrl = slot->ctrl;
424419 u8 bus;
425420 u8 devfn;
....@@ -446,7 +441,7 @@
446441 static int process_SI(struct hotplug_slot *hotplug_slot)
447442 {
448443 struct pci_func *slot_func;
449
- struct slot *slot = hotplug_slot->private;
444
+ struct slot *slot = to_slot(hotplug_slot);
450445 struct controller *ctrl = slot->ctrl;
451446 u8 bus;
452447 u8 devfn;
....@@ -478,7 +473,7 @@
478473 static int process_SS(struct hotplug_slot *hotplug_slot)
479474 {
480475 struct pci_func *slot_func;
481
- struct slot *slot = hotplug_slot->private;
476
+ struct slot *slot = to_slot(hotplug_slot);
482477 struct controller *ctrl = slot->ctrl;
483478 u8 bus;
484479 u8 devfn;
....@@ -505,7 +500,7 @@
505500
506501 static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
507502 {
508
- struct slot *slot = hotplug_slot->private;
503
+ struct slot *slot = to_slot(hotplug_slot);
509504 struct controller *ctrl = slot->ctrl;
510505
511506 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
....@@ -516,7 +511,7 @@
516511
517512 static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
518513 {
519
- struct slot *slot = hotplug_slot->private;
514
+ struct slot *slot = to_slot(hotplug_slot);
520515 struct controller *ctrl = slot->ctrl;
521516
522517 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
....@@ -527,7 +522,7 @@
527522
528523 static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
529524 {
530
- struct slot *slot = hotplug_slot->private;
525
+ struct slot *slot = to_slot(hotplug_slot);
531526 struct controller *ctrl = slot->ctrl;
532527
533528 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
....@@ -538,7 +533,7 @@
538533
539534 static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
540535 {
541
- struct slot *slot = hotplug_slot->private;
536
+ struct slot *slot = to_slot(hotplug_slot);
542537 struct controller *ctrl = slot->ctrl;
543538
544539 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
....@@ -550,7 +545,7 @@
550545
551546 static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
552547 {
553
- struct slot *slot = hotplug_slot->private;
548
+ struct slot *slot = to_slot(hotplug_slot);
554549 struct controller *ctrl = slot->ctrl;
555550
556551 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
....@@ -560,7 +555,7 @@
560555 return 0;
561556 }
562557
563
-static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = {
558
+static const struct hotplug_slot_ops cpqphp_hotplug_slot_ops = {
564559 .set_attention_status = set_attention_status,
565560 .enable_slot = process_SI,
566561 .disable_slot = process_SS,
....@@ -578,8 +573,6 @@
578573 void __iomem *smbios_table)
579574 {
580575 struct slot *slot;
581
- struct hotplug_slot *hotplug_slot;
582
- struct hotplug_slot_info *hotplug_slot_info;
583576 struct pci_bus *bus = ctrl->pci_bus;
584577 u8 number_of_slots;
585578 u8 slot_device;
....@@ -604,22 +597,6 @@
604597 result = -ENOMEM;
605598 goto error;
606599 }
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;
623600
624601 slot->ctrl = ctrl;
625602 slot->bus = ctrl->bus;
....@@ -669,29 +646,20 @@
669646 ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
670647
671648 /* register this slot with the hotplug pci core */
672
- hotplug_slot->private = slot;
673649 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;
683651
684652 dbg("registering bus %d, dev %d, number %d, ctrl->slot_device_offset %d, slot %d\n",
685653 slot->bus, slot->device,
686654 slot->number, ctrl->slot_device_offset,
687655 slot_number);
688
- result = pci_hp_register(hotplug_slot,
656
+ result = pci_hp_register(&slot->hotplug_slot,
689657 ctrl->pci_dev->bus,
690658 slot->device,
691659 name);
692660 if (result) {
693661 err("pci_hp_register failed with error %d\n", result);
694
- goto error_info;
662
+ goto error_slot;
695663 }
696664
697665 slot->next = ctrl->slot;
....@@ -703,10 +671,6 @@
703671 }
704672
705673 return 0;
706
-error_info:
707
- kfree(hotplug_slot_info);
708
-error_hpslot:
709
- kfree(hotplug_slot);
710674 error_slot:
711675 kfree(slot);
712676 error: