drivers/base/power/wakeup_stats.c
Source file repositories/reference/linux-study-clean/drivers/base/power/wakeup_stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/power/wakeup_stats.c- Extension
.c- Size
- 5490 bytes
- Lines
- 220
- 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.
- 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/device.hlinux/idr.hlinux/init.hlinux/kdev_t.hlinux/kernel.hlinux/kobject.hlinux/slab.hlinux/timekeeping.hpower.h
Detected Declarations
function active_time_ms_showfunction total_time_ms_showfunction max_time_ms_showfunction last_change_ms_showfunction name_showfunction prevent_suspend_time_ms_showfunction device_create_releasefunction wakeup_source_sysfs_addfunction pm_wakeup_source_sysfs_addfunction wakeup_source_sysfs_removefunction wakeup_sources_sysfs_init
Annotated Snippet
retval = device_add(dev);
if (retval)
goto error;
return dev;
error:
put_device(dev);
return ERR_PTR(retval);
}
/**
* wakeup_source_sysfs_add - Add wakeup_source attributes to sysfs.
* @parent: Device given wakeup source is associated with (or NULL if virtual).
* @ws: Wakeup source to be added in sysfs.
*/
int wakeup_source_sysfs_add(struct device *parent, struct wakeup_source *ws)
{
struct device *dev;
dev = wakeup_source_device_create(parent, ws);
if (IS_ERR(dev))
return PTR_ERR(dev);
ws->dev = dev;
return 0;
}
/**
* pm_wakeup_source_sysfs_add - Add wakeup_source attributes to sysfs
* for a device if they're missing.
* @parent: Device given wakeup source is associated with
*/
int pm_wakeup_source_sysfs_add(struct device *parent)
{
if (!parent->power.wakeup || parent->power.wakeup->dev)
return 0;
return wakeup_source_sysfs_add(parent, parent->power.wakeup);
}
/**
* wakeup_source_sysfs_remove - Remove wakeup_source attributes from sysfs.
* @ws: Wakeup source to be removed from sysfs.
*/
void wakeup_source_sysfs_remove(struct wakeup_source *ws)
{
device_unregister(ws->dev);
}
static int __init wakeup_sources_sysfs_init(void)
{
wakeup_class = class_create("wakeup");
return PTR_ERR_OR_ZERO(wakeup_class);
}
postcore_initcall(wakeup_sources_sysfs_init);
Annotation
- Immediate include surface: `linux/device.h`, `linux/idr.h`, `linux/init.h`, `linux/kdev_t.h`, `linux/kernel.h`, `linux/kobject.h`, `linux/slab.h`, `linux/timekeeping.h`.
- Detected declarations: `function active_time_ms_show`, `function total_time_ms_show`, `function max_time_ms_show`, `function last_change_ms_show`, `function name_show`, `function prevent_suspend_time_ms_show`, `function device_create_release`, `function wakeup_source_sysfs_add`, `function pm_wakeup_source_sysfs_add`, `function wakeup_source_sysfs_remove`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration implementation candidate.
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.