drivers/pci/hotplug/shpchp_ctrl.c
Source file repositories/reference/linux-study-clean/drivers/pci/hotplug/shpchp_ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/hotplug/shpchp_ctrl.c- Extension
.c- Size
- 17415 bytes
- Lines
- 705
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/types.hlinux/slab.hlinux/pci.h../pci.hshpchp.h
Detected Declarations
struct pushbutton_work_infofunction queue_interrupt_eventfunction shpchp_handle_attention_buttonfunction shpchp_handle_switch_changefunction shpchp_handle_presence_changefunction shpchp_handle_power_faultfunction change_bus_speedfunction fix_bus_speedfunction board_addedfunction remove_boardfunction shpchp_pushbutton_threadfunction shpchp_queue_pushbutton_workfunction update_slot_infofunction handle_button_press_eventfunction interrupt_event_handlerfunction shpchp_enable_slotfunction shpchp_disable_slotfunction shpchp_sysfs_enable_slotfunction shpchp_sysfs_disable_slot
Annotated Snippet
struct pushbutton_work_info {
struct slot *p_slot;
struct work_struct work;
};
/**
* shpchp_pushbutton_thread - handle pushbutton events
* @work: &struct work_struct to be handled
*
* Scheduled procedure to handle blocking stuff for the pushbuttons.
* Handles all pending events and exits.
*/
static void shpchp_pushbutton_thread(struct work_struct *work)
{
struct pushbutton_work_info *info =
container_of(work, struct pushbutton_work_info, work);
struct slot *p_slot = info->p_slot;
mutex_lock(&p_slot->lock);
switch (p_slot->state) {
case POWEROFF_STATE:
mutex_unlock(&p_slot->lock);
shpchp_disable_slot(p_slot);
mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE;
break;
case POWERON_STATE:
mutex_unlock(&p_slot->lock);
if (shpchp_enable_slot(p_slot))
shpchp_green_led_off(p_slot);
mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE;
break;
default:
break;
}
mutex_unlock(&p_slot->lock);
kfree(info);
}
void shpchp_queue_pushbutton_work(struct work_struct *work)
{
struct slot *p_slot = container_of(work, struct slot, work.work);
struct pushbutton_work_info *info;
info = kmalloc_obj(*info);
if (!info) {
ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
__func__);
return;
}
info->p_slot = p_slot;
INIT_WORK(&info->work, shpchp_pushbutton_thread);
mutex_lock(&p_slot->lock);
switch (p_slot->state) {
case BLINKINGOFF_STATE:
p_slot->state = POWEROFF_STATE;
break;
case BLINKINGON_STATE:
p_slot->state = POWERON_STATE;
break;
default:
kfree(info);
goto out;
}
queue_work(p_slot->wq, &info->work);
out:
mutex_unlock(&p_slot->lock);
}
static void update_slot_info(struct slot *slot)
{
shpchp_get_power_status(slot, &slot->pwr_save);
shpchp_get_attention_status(slot, &slot->attention_save);
shpchp_get_latch_status(slot, &slot->latch_save);
shpchp_get_adapter_status(slot, &slot->presence_save);
}
/*
* Note: This function must be called with slot->lock held
*/
static void handle_button_press_event(struct slot *p_slot)
{
u8 getstatus;
struct controller *ctrl = p_slot->ctrl;
switch (p_slot->state) {
case STATIC_STATE:
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/slab.h`, `linux/pci.h`, `../pci.h`, `shpchp.h`.
- Detected declarations: `struct pushbutton_work_info`, `function queue_interrupt_event`, `function shpchp_handle_attention_button`, `function shpchp_handle_switch_change`, `function shpchp_handle_presence_change`, `function shpchp_handle_power_fault`, `function change_bus_speed`, `function fix_bus_speed`, `function board_added`, `function remove_board`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.