Lines Matching full:ctrl
51 static int init_slot(struct controller *ctrl) in init_slot() argument
67 if (MRL_SENS(ctrl)) in init_slot()
69 if (ATTN_LED(ctrl)) { in init_slot()
72 } else if (ctrl->pcie->port->hotplug_user_indicators) { in init_slot()
78 ctrl->hotplug_slot.ops = ops; in init_slot()
79 snprintf(name, SLOT_NAME_SIZE, "%u", PSN(ctrl)); in init_slot()
81 retval = pci_hp_initialize(&ctrl->hotplug_slot, in init_slot()
82 ctrl->pcie->port->subordinate, 0, name); in init_slot()
84 ctrl_err(ctrl, "pci_hp_initialize failed: error %d\n", retval); in init_slot()
90 static void cleanup_slot(struct controller *ctrl) in cleanup_slot() argument
92 struct hotplug_slot *hotplug_slot = &ctrl->hotplug_slot; in cleanup_slot()
103 struct controller *ctrl = to_ctrl(hotplug_slot); in set_attention_status() local
104 struct pci_dev *pdev = ctrl->pcie->port; in set_attention_status()
112 pciehp_set_indicators(ctrl, INDICATOR_NOOP, status); in set_attention_status()
119 struct controller *ctrl = to_ctrl(hotplug_slot); in get_power_status() local
120 struct pci_dev *pdev = ctrl->pcie->port; in get_power_status()
123 pciehp_get_power_status(ctrl, value); in get_power_status()
130 struct controller *ctrl = to_ctrl(hotplug_slot); in get_latch_status() local
131 struct pci_dev *pdev = ctrl->pcie->port; in get_latch_status()
134 pciehp_get_latch_status(ctrl, value); in get_latch_status()
141 struct controller *ctrl = to_ctrl(hotplug_slot); in get_adapter_status() local
142 struct pci_dev *pdev = ctrl->pcie->port; in get_adapter_status()
146 ret = pciehp_card_present_or_link_active(ctrl); in get_adapter_status()
157 * @ctrl: controller to check
166 static void pciehp_check_presence(struct controller *ctrl) in pciehp_check_presence() argument
170 down_read_nested(&ctrl->reset_lock, ctrl->depth); in pciehp_check_presence()
171 mutex_lock(&ctrl->state_lock); in pciehp_check_presence()
173 occupied = pciehp_card_present_or_link_active(ctrl); in pciehp_check_presence()
174 if ((occupied > 0 && (ctrl->state == OFF_STATE || in pciehp_check_presence()
175 ctrl->state == BLINKINGON_STATE)) || in pciehp_check_presence()
176 (!occupied && (ctrl->state == ON_STATE || in pciehp_check_presence()
177 ctrl->state == BLINKINGOFF_STATE))) in pciehp_check_presence()
178 pciehp_request(ctrl, PCI_EXP_SLTSTA_PDC); in pciehp_check_presence()
180 mutex_unlock(&ctrl->state_lock); in pciehp_check_presence()
181 up_read(&ctrl->reset_lock); in pciehp_check_presence()
187 struct controller *ctrl; in pciehp_probe() local
200 ctrl = pcie_init(dev); in pciehp_probe()
201 if (!ctrl) { in pciehp_probe()
205 set_service_data(dev, ctrl); in pciehp_probe()
208 rc = init_slot(ctrl); in pciehp_probe()
211 ctrl_warn(ctrl, "Slot already registered by another hotplug driver\n"); in pciehp_probe()
213 ctrl_err(ctrl, "Slot initialization failed (%d)\n", rc); in pciehp_probe()
218 rc = pcie_init_notification(ctrl); in pciehp_probe()
220 ctrl_err(ctrl, "Notification initialization failed (%d)\n", rc); in pciehp_probe()
225 rc = pci_hp_add(&ctrl->hotplug_slot); in pciehp_probe()
227 ctrl_err(ctrl, "Publication to user space failed (%d)\n", rc); in pciehp_probe()
231 pciehp_check_presence(ctrl); in pciehp_probe()
236 pcie_shutdown_notification(ctrl); in pciehp_probe()
238 cleanup_slot(ctrl); in pciehp_probe()
240 pciehp_release_ctrl(ctrl); in pciehp_probe()
246 struct controller *ctrl = get_service_data(dev); in pciehp_remove() local
248 pci_hp_del(&ctrl->hotplug_slot); in pciehp_remove()
249 pcie_shutdown_notification(ctrl); in pciehp_remove()
250 cleanup_slot(ctrl); in pciehp_remove()
251 pciehp_release_ctrl(ctrl); in pciehp_remove()
287 static bool pciehp_device_replaced(struct controller *ctrl) in pciehp_device_replaced() argument
292 pdev = pci_get_slot(ctrl->pcie->port->subordinate, PCI_DEVFN(0, 0)); in pciehp_device_replaced()
307 if (pci_get_dsn(pdev) != ctrl->dsn) in pciehp_device_replaced()
315 struct controller *ctrl = get_service_data(dev); in pciehp_resume_noirq() local
318 ctrl->cmd_started = jiffies; in pciehp_resume_noirq()
319 ctrl->cmd_busy = true; in pciehp_resume_noirq()
322 if (ctrl->state == ON_STATE || ctrl->state == BLINKINGOFF_STATE) { in pciehp_resume_noirq()
323 pcie_clear_hotplug_events(ctrl); in pciehp_resume_noirq()
331 if (pciehp_device_replaced(ctrl)) { in pciehp_resume_noirq()
332 ctrl_dbg(ctrl, "device replaced during system sleep\n"); in pciehp_resume_noirq()
333 pci_walk_bus(ctrl->pcie->port->subordinate, in pciehp_resume_noirq()
335 pciehp_request(ctrl, PCI_EXP_SLTSTA_PDC); in pciehp_resume_noirq()
345 struct controller *ctrl = get_service_data(dev); in pciehp_resume() local
348 pcie_enable_interrupt(ctrl); in pciehp_resume()
350 pciehp_check_presence(ctrl); in pciehp_resume()
363 struct controller *ctrl = get_service_data(dev); in pciehp_runtime_resume() local
366 ctrl->cmd_started = jiffies; in pciehp_runtime_resume()
367 ctrl->cmd_busy = true; in pciehp_runtime_resume()
370 if ((ctrl->state == ON_STATE || ctrl->state == BLINKINGOFF_STATE) && in pciehp_runtime_resume()
372 pcie_clear_hotplug_events(ctrl); in pciehp_runtime_resume()