power_supply_vbat2ri(9)
π
power_supply_vbat2ri β the kernel API manual, bestie edition β¨
Okay so picture this: you're deep in the power_supply subsystem (iconic of you, honestly), and you need to know how much resistance the battery is giving you at its current voltage. That's literally this function. It's from the Kernel API Manual, and it's here to slay. π«Ά
πΈ NAME πΈ
power_supply_vbat2ri β find the battery internal resistance from the battery voltage. That's the whole gig. No cap. π
π¦ SYNOPSIS π¦
int power_supply_vbat2ri (struct power_supply_battery_info *info , int
vbat_uv , bool charging );
Like I said. Three args, one int coming back at you. Clean. β¨
π ARGUMENTS π
infoβ the battery information container. It's giving "everything you ever wanted to know about this battery." πvbat_uvβ the battery voltage, in microvolt. Yes, *micro*volt. Little tiny volts. πchargingβ are we charging (true) or not (false)? Binary queen behavior, honestly. β‘
π DESCRIPTION π
So here's the vibe: this helper function is used to look up battery internal resistance according to current battery voltage. That's it, that's the function. π
And the cute part β depending on whether the battery is currently charging or not, different resistance will be returned. So that charging bool is not just decoration, bestie, it actually matters. π§
Returns the internal resistance in microohm or a negative error code. So if you get a negative number back, don't panic, that's not a resistance, that's the universe telling you something went wrong. π
Heads up: microvolt in, microohm out. Keep your units straight or the vibe check will fail you. π
β SEE ALSO β
Kernel file ./drivers/power/supply/power_supply_core.c β literally where the magic lives, go read it.
And the whole friend group:
power_supply_get_by_name(9)power_supply_get_system_batteries(9)power_supply_put_system_batteries(9)power_supply_put(9)power_supply_get_by_reference(9)devm_power_supply_get_by_reference(9)power_supply_temp2resist_simple(9)power_supply_ocv2cap_simple(9)power_supply_get_property_direct(9)power_supply_set_property_direct(9)power_supply_register(9)devm_power_supply_register(9)power_supply_unregister(9)
All of them. Every single one. Go follow them, they're all baddies. π
That's the whole page, bestie! This one's filed under ./drivers/power/supply, dated October 2026, and it's part of the Kernel API Manual. Now go forth and compute some resistances. Slay. πβ¨π
π¦ 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