drivers/cpuidle/driver.c
Source file repositories/reference/linux-study-clean/drivers/cpuidle/driver.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpuidle/driver.c- Extension
.c- Size
- 10347 bytes
- Lines
- 403
- Domain
- Driver Families
- Bucket
- drivers/cpuidle
- 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/mutex.hlinux/module.hlinux/sched.hlinux/sched/idle.hlinux/cpuidle.hlinux/cpumask.hlinux/tick.hlinux/cpu.hlinux/math64.hcpuidle.h
Detected Declarations
function __cpuidle_unset_driverfunction for_each_cpufunction __cpuidle_set_driverfunction for_each_cpufunction __cpuidle_set_driverfunction __cpuidle_unset_driverfunction cpuidle_setup_broadcast_timerfunction __cpuidle_driver_initfunction variablefunction variablefunction __cpuidle_register_driverfunction cpuidle_unregister_driverfunction cpuidle_driver_state_disabledfunction for_each_cpuexport cpuidle_register_driverexport cpuidle_unregister_driverexport cpuidle_get_driverexport cpuidle_get_cpu_driver
Annotated Snippet
if (gov) {
cpuidle_prev_governor = cpuidle_curr_governor;
if (cpuidle_switch_governor(gov) < 0)
cpuidle_prev_governor = NULL;
}
mutex_unlock(&cpuidle_lock);
}
return ret;
}
EXPORT_SYMBOL_GPL(cpuidle_register_driver);
/**
* cpuidle_unregister_driver - unregisters a driver
* @drv: a pointer to a valid struct cpuidle_driver
*
* Unregisters the cpuidle driver under a lock to prevent concurrent attempts
* to [un]register the driver from occurring at the same time. @drv has to
* match the currently registered driver.
*/
void cpuidle_unregister_driver(struct cpuidle_driver *drv)
{
bool enabled = (cpuidle_get_driver() == drv);
spin_lock(&cpuidle_driver_lock);
__cpuidle_unregister_driver(drv);
spin_unlock(&cpuidle_driver_lock);
if (!enabled)
return;
mutex_lock(&cpuidle_lock);
if (cpuidle_prev_governor) {
if (!cpuidle_switch_governor(cpuidle_prev_governor))
cpuidle_prev_governor = NULL;
}
mutex_unlock(&cpuidle_lock);
}
EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);
/**
* cpuidle_get_driver - return the driver tied to the current CPU.
*
* Returns a struct cpuidle_driver pointer, or NULL if no driver is registered.
*/
struct cpuidle_driver *cpuidle_get_driver(void)
{
struct cpuidle_driver *drv;
int cpu;
cpu = get_cpu();
drv = __cpuidle_get_cpu_driver(cpu);
put_cpu();
return drv;
}
EXPORT_SYMBOL_GPL(cpuidle_get_driver);
/**
* cpuidle_get_cpu_driver - return the driver registered for a CPU.
* @dev: a valid pointer to a struct cpuidle_device
*
* Returns a struct cpuidle_driver pointer, or NULL if no driver is registered
* for the CPU associated with @dev.
*/
struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev)
{
if (!dev)
return NULL;
return __cpuidle_get_cpu_driver(dev->cpu);
}
EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver);
/**
* cpuidle_driver_state_disabled - Disable or enable an idle state
* @drv: cpuidle driver owning the state
* @idx: State index
* @disable: Whether or not to disable the state
*/
void cpuidle_driver_state_disabled(struct cpuidle_driver *drv, int idx,
bool disable)
{
unsigned int cpu;
mutex_lock(&cpuidle_lock);
spin_lock(&cpuidle_driver_lock);
if (!drv->cpumask) {
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/module.h`, `linux/sched.h`, `linux/sched/idle.h`, `linux/cpuidle.h`, `linux/cpumask.h`, `linux/tick.h`, `linux/cpu.h`.
- Detected declarations: `function __cpuidle_unset_driver`, `function for_each_cpu`, `function __cpuidle_set_driver`, `function for_each_cpu`, `function __cpuidle_set_driver`, `function __cpuidle_unset_driver`, `function cpuidle_setup_broadcast_timer`, `function __cpuidle_driver_init`, `function variable`, `function variable`.
- Atlas domain: Driver Families / drivers/cpuidle.
- 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.