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

PCI: pciehp: Inline the "handle event" functions into the ISR

The pciehp_handle_*() functions (pciehp_handle_attention_button(), etc.)
only contain a line or two of useful code, so it's clumsy to put
them in separate functions. All they so is add an event to a work queue,
and it's clearer to see that directly in the ISR.

Inline them directly into pcie_isr(). No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rajat Jain <rajatja@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>

+32 -118
+1 -5
drivers/pci/hotplug/pciehp.h
··· 132 132 133 133 int pciehp_sysfs_enable_slot(struct slot *slot); 134 134 int pciehp_sysfs_disable_slot(struct slot *slot); 135 - u8 pciehp_handle_attention_button(struct slot *p_slot); 136 - u8 pciehp_handle_switch_change(struct slot *p_slot); 137 - u8 pciehp_handle_presence_change(struct slot *p_slot); 138 - u8 pciehp_handle_power_fault(struct slot *p_slot); 139 - void pciehp_handle_linkstate_change(struct slot *p_slot); 135 + void pciehp_queue_interrupt_event(struct slot *slot, u32 event_type); 140 136 int pciehp_configure_device(struct slot *p_slot); 141 137 int pciehp_unconfigure_device(struct slot *p_slot); 142 138 void pciehp_queue_pushbutton_work(struct work_struct *work);
+1 -104
drivers/pci/hotplug/pciehp_ctrl.c
··· 37 37 38 38 static void interrupt_event_handler(struct work_struct *work); 39 39 40 - static void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type) 40 + void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type) 41 41 { 42 42 struct event_info *info; 43 43 ··· 51 51 info->event_type = event_type; 52 52 info->p_slot = p_slot; 53 53 queue_work(p_slot->wq, &info->work); 54 - } 55 - 56 - u8 pciehp_handle_attention_button(struct slot *p_slot) 57 - { 58 - u32 event_type; 59 - struct controller *ctrl = p_slot->ctrl; 60 - 61 - /* 62 - * Button pressed - See if need to TAKE ACTION!!! 63 - */ 64 - ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); 65 - event_type = INT_BUTTON_PRESS; 66 - 67 - pciehp_queue_interrupt_event(p_slot, event_type); 68 - 69 - return 0; 70 - } 71 - 72 - u8 pciehp_handle_switch_change(struct slot *p_slot) 73 - { 74 - u8 getstatus; 75 - u32 event_type; 76 - struct controller *ctrl = p_slot->ctrl; 77 - 78 - pciehp_get_latch_status(p_slot, &getstatus); 79 - if (getstatus) { 80 - /* 81 - * Switch opened 82 - */ 83 - ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot)); 84 - event_type = INT_SWITCH_OPEN; 85 - } else { 86 - /* 87 - * Switch closed 88 - */ 89 - ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot)); 90 - event_type = INT_SWITCH_CLOSE; 91 - } 92 - 93 - pciehp_queue_interrupt_event(p_slot, event_type); 94 - 95 - return 1; 96 - } 97 - 98 - u8 pciehp_handle_presence_change(struct slot *p_slot) 99 - { 100 - u32 event_type; 101 - u8 presence_save; 102 - struct controller *ctrl = p_slot->ctrl; 103 - 104 - /* Switch is open, assume a presence change 105 - * Save the presence state 106 - */ 107 - pciehp_get_adapter_status(p_slot, &presence_save); 108 - if (presence_save) { 109 - /* 110 - * Card Present 111 - */ 112 - ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot)); 113 - event_type = INT_PRESENCE_ON; 114 - } else { 115 - /* 116 - * Not Present 117 - */ 118 - ctrl_info(ctrl, "Card not present on Slot(%s)\n", 119 - slot_name(p_slot)); 120 - event_type = INT_PRESENCE_OFF; 121 - } 122 - 123 - pciehp_queue_interrupt_event(p_slot, event_type); 124 - 125 - return 1; 126 - } 127 - 128 - u8 pciehp_handle_power_fault(struct slot *p_slot) 129 - { 130 - u32 event_type; 131 - struct controller *ctrl = p_slot->ctrl; 132 - 133 - ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot)); 134 - event_type = INT_POWER_FAULT; 135 - ctrl_info(ctrl, "Power fault bit %x set\n", 0); 136 - pciehp_queue_interrupt_event(p_slot, event_type); 137 - 138 - return 1; 139 - } 140 - 141 - void pciehp_handle_linkstate_change(struct slot *p_slot) 142 - { 143 - u32 event_type; 144 - struct controller *ctrl = p_slot->ctrl; 145 - 146 - if (pciehp_check_link_active(ctrl)) { 147 - ctrl_info(ctrl, "slot(%s): Link Up event\n", 148 - slot_name(p_slot)); 149 - event_type = INT_LINK_UP; 150 - } else { 151 - ctrl_info(ctrl, "slot(%s): Link Down event\n", 152 - slot_name(p_slot)); 153 - event_type = INT_LINK_DOWN; 154 - } 155 - 156 - pciehp_queue_interrupt_event(p_slot, event_type); 157 54 } 158 55 159 56 /* The following routines constitute the bulk of the
+30 -9
drivers/pci/hotplug/pciehp_hpc.c
··· 535 535 struct pci_dev *dev; 536 536 struct slot *slot = ctrl->slot; 537 537 u16 detected, intr_loc; 538 + u8 open, present; 539 + bool link; 538 540 539 541 /* 540 542 * In order to guarantee that all interrupt events are ··· 582 580 return IRQ_HANDLED; 583 581 584 582 /* Check MRL Sensor Changed */ 585 - if (intr_loc & PCI_EXP_SLTSTA_MRLSC) 586 - pciehp_handle_switch_change(slot); 583 + if (intr_loc & PCI_EXP_SLTSTA_MRLSC) { 584 + pciehp_get_latch_status(slot, &open); 585 + ctrl_info(ctrl, "Latch %s on Slot(%s)\n", 586 + open ? "open" : "close", slot_name(slot)); 587 + pciehp_queue_interrupt_event(slot, open ? INT_SWITCH_OPEN : 588 + INT_SWITCH_CLOSE); 589 + } 587 590 588 591 /* Check Attention Button Pressed */ 589 - if (intr_loc & PCI_EXP_SLTSTA_ABP) 590 - pciehp_handle_attention_button(slot); 592 + if (intr_loc & PCI_EXP_SLTSTA_ABP) { 593 + ctrl_info(ctrl, "Button pressed on Slot(%s)\n", 594 + slot_name(slot)); 595 + pciehp_queue_interrupt_event(slot, INT_BUTTON_PRESS); 596 + } 591 597 592 598 /* Check Presence Detect Changed */ 593 - if (intr_loc & PCI_EXP_SLTSTA_PDC) 594 - pciehp_handle_presence_change(slot); 599 + if (intr_loc & PCI_EXP_SLTSTA_PDC) { 600 + pciehp_get_adapter_status(slot, &present); 601 + ctrl_info(ctrl, "Card %spresent on Slot(%s)\n", 602 + present ? "" : "not ", slot_name(slot)); 603 + pciehp_queue_interrupt_event(slot, present ? INT_PRESENCE_ON : 604 + INT_PRESENCE_OFF); 605 + } 595 606 596 607 /* Check Power Fault Detected */ 597 608 if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { 598 609 ctrl->power_fault_detected = 1; 599 - pciehp_handle_power_fault(slot); 610 + ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(slot)); 611 + pciehp_queue_interrupt_event(slot, INT_POWER_FAULT); 600 612 } 601 613 602 - if (intr_loc & PCI_EXP_SLTSTA_DLLSC) 603 - pciehp_handle_linkstate_change(slot); 614 + if (intr_loc & PCI_EXP_SLTSTA_DLLSC) { 615 + link = pciehp_check_link_active(ctrl); 616 + ctrl_info(ctrl, "slot(%s): Link %s event\n", 617 + slot_name(slot), link ? "Up" : "Down"); 618 + pciehp_queue_interrupt_event(slot, link ? INT_LINK_UP : 619 + INT_LINK_DOWN); 620 + } 604 621 605 622 return IRQ_HANDLED; 606 623 }