drivers/base/power/wakeirq.c
Source file repositories/reference/linux-study-clean/drivers/base/power/wakeirq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/power/wakeirq.c- Extension
.c- Size
- 10494 bytes
- Lines
- 395
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/interrupt.hlinux/irq.hlinux/slab.hlinux/pm_runtime.hlinux/pm_wakeirq.hpower.h
Detected Declarations
function dev_pm_attach_wake_irqfunction device_init_wakeupfunction dev_pm_set_wake_irqfunction devm_pm_clear_wake_irqfunction devm_pm_set_wake_irqfunction handle_threaded_wake_irqfunction __dev_pm_set_dedicated_wake_irqfunction dev_pm_set_dedicated_wake_irqfunction rpm_suspendfunction rpm_suspendfunction rpm_suspendfunction rpm_suspendfunction device_may_wakefunction device_may_wakeexport dev_pm_set_wake_irqexport dev_pm_clear_wake_irqexport devm_pm_set_wake_irqexport dev_pm_set_dedicated_wake_irqexport dev_pm_set_dedicated_wake_irq_reverse
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Device wakeirq helper functions */
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeirq.h>
#include "power.h"
/**
* dev_pm_attach_wake_irq - Attach device interrupt as a wake IRQ
* @dev: Device entry
* @wirq: Wake irq specific data
*
* Internal function to attach a dedicated wake-up interrupt as a wake IRQ.
*/
static int dev_pm_attach_wake_irq(struct device *dev, struct wake_irq *wirq)
{
unsigned long flags;
if (!dev || !wirq)
return -EINVAL;
spin_lock_irqsave(&dev->power.lock, flags);
if (dev_WARN_ONCE(dev, dev->power.wakeirq,
"wake irq already initialized\n")) {
spin_unlock_irqrestore(&dev->power.lock, flags);
return -EEXIST;
}
dev->power.wakeirq = wirq;
device_wakeup_attach_irq(dev, wirq);
spin_unlock_irqrestore(&dev->power.lock, flags);
return 0;
}
/**
* dev_pm_set_wake_irq - Attach device IO interrupt as wake IRQ
* @dev: Device entry
* @irq: Device IO interrupt
*
* Attach a device IO interrupt as a wake IRQ. The wake IRQ gets
* automatically configured for wake-up from suspend based
* on the device specific sysfs wakeup entry. Typically called
* during driver probe after calling device_init_wakeup().
*/
int dev_pm_set_wake_irq(struct device *dev, int irq)
{
struct wake_irq *wirq;
int err;
if (irq < 0)
return -EINVAL;
wirq = kzalloc_obj(*wirq);
if (!wirq)
return -ENOMEM;
wirq->dev = dev;
wirq->irq = irq;
err = dev_pm_attach_wake_irq(dev, wirq);
if (err)
kfree(wirq);
return err;
}
EXPORT_SYMBOL_GPL(dev_pm_set_wake_irq);
/**
* dev_pm_clear_wake_irq - Detach a device IO interrupt wake IRQ
* @dev: Device entry
*
* Detach a device wake IRQ and free resources.
*
* Note that it's OK for drivers to call this without calling
* dev_pm_set_wake_irq() as all the driver instances may not have
* a wake IRQ configured. This avoid adding wake IRQ specific
* checks into the drivers.
*/
void dev_pm_clear_wake_irq(struct device *dev)
{
struct wake_irq *wirq;
unsigned long flags;
spin_lock_irqsave(&dev->power.lock, flags);
wirq = dev->power.wakeirq;
Annotation
- Immediate include surface: `linux/device.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/slab.h`, `linux/pm_runtime.h`, `linux/pm_wakeirq.h`, `power.h`.
- Detected declarations: `function dev_pm_attach_wake_irq`, `function device_init_wakeup`, `function dev_pm_set_wake_irq`, `function devm_pm_clear_wake_irq`, `function devm_pm_set_wake_irq`, `function handle_threaded_wake_irq`, `function __dev_pm_set_dedicated_wake_irq`, `function dev_pm_set_dedicated_wake_irq`, `function rpm_suspend`, `function rpm_suspend`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.