drivers/base/syscore.c
Source file repositories/reference/linux-study-clean/drivers/base/syscore.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/syscore.c- Extension
.c- Size
- 3413 bytes
- Lines
- 133
- Domain
- Driver Families
- Bucket
- drivers/base
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/syscore_ops.hlinux/mutex.hlinux/module.hlinux/suspend.htrace/events/power.h
Detected Declarations
function register_syscorefunction unregister_syscorefunction syscore_suspendfunction list_for_each_entry_reversefunction syscore_resumefunction list_for_each_entryfunction syscore_shutdownfunction list_for_each_entry_reverseexport register_syscoreexport unregister_syscoreexport syscore_suspendexport syscore_resume
Annotated Snippet
if (syscore->ops->suspend) {
pm_pr_dbg("Calling %pS\n", syscore->ops->suspend);
ret = syscore->ops->suspend(syscore->data);
if (ret)
goto err_out;
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pS\n",
syscore->ops->suspend);
}
trace_suspend_resume(TPS("syscore_suspend"), 0, false);
return 0;
err_out:
pr_err("PM: System core suspend callback %pS failed.\n",
syscore->ops->suspend);
list_for_each_entry_continue(syscore, &syscore_list, node)
if (syscore->ops->resume)
syscore->ops->resume(syscore->data);
return ret;
}
EXPORT_SYMBOL_GPL(syscore_suspend);
/**
* syscore_resume - Execute all the registered system core resume callbacks.
*
* This function is executed with one CPU on-line and disabled interrupts.
*/
void syscore_resume(void)
{
struct syscore *syscore;
trace_suspend_resume(TPS("syscore_resume"), 0, true);
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled before system core resume.\n");
list_for_each_entry(syscore, &syscore_list, node)
if (syscore->ops->resume) {
pm_pr_dbg("Calling %pS\n", syscore->ops->resume);
syscore->ops->resume(syscore->data);
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pS\n",
syscore->ops->resume);
}
trace_suspend_resume(TPS("syscore_resume"), 0, false);
}
EXPORT_SYMBOL_GPL(syscore_resume);
#endif /* CONFIG_PM_SLEEP */
/**
* syscore_shutdown - Execute all the registered system core shutdown callbacks.
*/
void syscore_shutdown(void)
{
struct syscore *syscore;
mutex_lock(&syscore_lock);
list_for_each_entry_reverse(syscore, &syscore_list, node)
if (syscore->ops->shutdown) {
if (initcall_debug)
pr_info("PM: Calling %pS\n",
syscore->ops->shutdown);
syscore->ops->shutdown(syscore->data);
}
mutex_unlock(&syscore_lock);
}
Annotation
- Immediate include surface: `linux/syscore_ops.h`, `linux/mutex.h`, `linux/module.h`, `linux/suspend.h`, `trace/events/power.h`.
- Detected declarations: `function register_syscore`, `function unregister_syscore`, `function syscore_suspend`, `function list_for_each_entry_reverse`, `function syscore_resume`, `function list_for_each_entry`, `function syscore_shutdown`, `function list_for_each_entry_reverse`, `export register_syscore`, `export unregister_syscore`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration 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.