dev_pm_opp_calc_power(9)
π dev_pm_opp_calc_power(9) π
okay bestie, welcome to the Kernel API Manual β¨ this one is a little function from dev_pm_opp_calc_power(9) land and it's literally about figuring out how much power your device is slurping. very energy model, very main character. let's go π«Ά
β¨ NAME β¨
dev_pm_opp_calc_power β calculate the power value for a device that has an Energy Model π
πΈ SYNOPSIS πΈ
int dev_pm_opp_calc_power (struct device *dev , unsigned long *uW ,
unsigned long *kHz );
π ARGUMENTS π
devβ the device whose Energy Model is gonna get registered. it's the whole reason we're here, no cap π¦uWβ this is a pointer to the brand-new power value that gets calculated. it's an output, so it comes back all filled in β¨kHzβ the frequency we're calculating the new power for. also gets updated in place, iykyk
π DESCRIPTION π
so here's the tea β: this computes the power estimated by dev at kHz β if kHz happens to be the frequency of an existing OPP. but if it's not? then it just uses the frequency of the first OPP above kHz instead (that's the dev_pm_opp_find_freq_ceil situation, and yes it's exactly what it sounds like π).
after it does that, the function updates kHz to the ceiled frequency and uW to the associated power. so both of your pointers come back changed. lowercase iconic.
the power itself is estimated as:
P = C * V^2 * f
where C is the device's capacitance, and V and f are respectively the voltage and frequency of the OPP. like, physics but make it kernel π§π
it's also used as a callback function that gets provided to the Energy Model framework when you register β so not just a one-trick pony, she's got range π
Returns: -EINVAL if the power calculation failed because of missing parameters, 0 otherwise. that's it, that's the contract fr fr π
ngl if you get -EINVAL back just know something was missing, don't go blaming the math π
π SEE ALSO π
kernel file ./drivers/opp/of.c π and the whole friend group:
dev_pm_opp_of_remove_table(9)_opp_add_static_v2(9)devm_pm_opp_of_add_table(9)dev_pm_opp_of_add_table(9)dev_pm_opp_of_add_table_indexed(9)devm_pm_opp_of_add_table_indexed(9)dev_pm_opp_of_cpumask_remove_table(9)dev_pm_opp_of_cpumask_add_table(9)dev_pm_opp_of_get_sharing_cpus(9)of_get_required_opp_performance_state(9)dev_pm_opp_of_has_required_opp(9)dev_pm_opp_get_of_node(9)dev_pm_opp_of_register_em(9)
and that's the page bestie!! π this fine piece of documentation lives in ./drivers/opp and was dated October 2026 β go read the actual source, it's serving β mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms