drivers/opp/cpu.c
Source file repositories/reference/linux-study-clean/drivers/opp/cpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/opp/cpu.c- Extension
.c- Size
- 5945 bytes
- Lines
- 229
- Domain
- Driver Families
- Bucket
- drivers/opp
- 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/cpu.hlinux/cpufreq.hlinux/err.hlinux/errno.hlinux/export.hlinux/slab.hopp.h
Detected Declarations
function Copyrightfunction dev_pm_opp_free_cpufreq_tablefunction _dev_pm_opp_cpumask_remove_tablefunction for_each_cpufunction dev_pm_opp_cpumask_remove_tablefunction dev_pm_opp_set_sharing_cpusfunction for_each_cpufunction dev_pm_opp_get_sharing_cpusexport dev_pm_opp_init_cpufreq_tableexport dev_pm_opp_free_cpufreq_tableexport dev_pm_opp_cpumask_remove_tableexport dev_pm_opp_set_sharing_cpusexport dev_pm_opp_get_sharing_cpus
Annotated Snippet
if (IS_ERR(opp)) {
ret = PTR_ERR(opp);
goto out;
}
freq_table[i].driver_data = i;
freq_table[i].frequency = rate / 1000;
/* Is Boost/turbo opp ? */
if (dev_pm_opp_is_turbo(opp))
freq_table[i].flags = CPUFREQ_BOOST_FREQ;
}
freq_table[i].driver_data = i;
freq_table[i].frequency = CPUFREQ_TABLE_END;
*opp_table = &freq_table[0];
out:
if (ret)
kfree(freq_table);
return ret;
}
EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table);
/**
* dev_pm_opp_free_cpufreq_table() - free the cpufreq table
* @dev: device for which we do this operation
* @opp_table: table to free
*
* Free up the table allocated by dev_pm_opp_init_cpufreq_table
*/
void dev_pm_opp_free_cpufreq_table(struct device *dev,
struct cpufreq_frequency_table **opp_table)
{
if (!opp_table)
return;
kfree(*opp_table);
*opp_table = NULL;
}
EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
#endif /* CONFIG_CPU_FREQ */
void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask,
int last_cpu)
{
struct device *cpu_dev;
int cpu;
WARN_ON(cpumask_empty(cpumask));
for_each_cpu(cpu, cpumask) {
if (cpu == last_cpu)
break;
cpu_dev = get_cpu_device(cpu);
if (!cpu_dev) {
pr_err("%s: failed to get cpu%d device\n", __func__,
cpu);
continue;
}
dev_pm_opp_remove_table(cpu_dev);
}
}
/**
* dev_pm_opp_cpumask_remove_table() - Removes OPP table for @cpumask
* @cpumask: cpumask for which OPP table needs to be removed
*
* This removes the OPP tables for CPUs present in the @cpumask.
* This should be used to remove all the OPPs entries associated with
* the cpus in @cpumask.
*/
void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
{
_dev_pm_opp_cpumask_remove_table(cpumask, -1);
}
EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
/**
* dev_pm_opp_set_sharing_cpus() - Mark OPP table as shared by few CPUs
* @cpu_dev: CPU device for which we do this operation
* @cpumask: cpumask of the CPUs which share the OPP table with @cpu_dev
*
* This marks OPP table of the @cpu_dev as shared by the CPUs present in
* @cpumask.
*
* Returns -ENODEV if OPP table isn't already present.
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/cpufreq.h`, `linux/err.h`, `linux/errno.h`, `linux/export.h`, `linux/slab.h`, `opp.h`.
- Detected declarations: `function Copyright`, `function dev_pm_opp_free_cpufreq_table`, `function _dev_pm_opp_cpumask_remove_table`, `function for_each_cpu`, `function dev_pm_opp_cpumask_remove_table`, `function dev_pm_opp_set_sharing_cpus`, `function for_each_cpu`, `function dev_pm_opp_get_sharing_cpus`, `export dev_pm_opp_init_cpufreq_table`, `export dev_pm_opp_free_cpufreq_table`.
- Atlas domain: Driver Families / drivers/opp.
- 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.