dev_pm_opp_calc_power(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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:


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