power_supply_get_by_name(9)
β¨ power_supply_get_by_name β Kernel API Manual β¨
okay so bestie, welcome to the kernel API manual entry for power_supply_get_by_name(9) and honestly? it's giving "tiny function, big responsibility" π
like it's literally one call but the refcounting lore goes DEEP. buckle up π
πΈ NAME πΈ
power_supply_get_by_name β search for a power supply and returns its ref π«Ά
like yes, that's the whole vibe. you give it a name, it goes looking, and if it finds your girl it hands you back a reference. iconic behavior honestly β¨
π¦ SYNOPSIS π¦
struct power_supply * power_supply_get_by_name (const char *name );
that's it. that's the whole signature. no cap, that's the entire synopsis π
π ARGUMENTS π
nameβ the power supply name to fetch π― literally just the name of the power supply you're trying to find, nothing more, nothing mysterious. you say the name, it goes and gets her. iykyk π«
π§ DESCRIPTION π§
okay so here's the tea β β if the power supply was found, this function increases the reference count for the internal power supply's device π like it's picking her up and putting her in your arms, but with bookkeeping involved.
and because nothing in kernel land is free (π), the user should call power_supply_put after usage. periodt. like fr fr, don't just walk away holding the reference forever, that's not the move π
bestie pls don't forget the power_supply_put β the ref count went up, so it's gotta come back down. it's giving "borrow my hoodie and actually return it" energy π
β RETURN β
- On success: returns a reference to a power supply with matching name equals to
nameπ slay, you found her - Otherwise:
NULLπ the search came up empty, she's not here
π₯ SEE ALSO π₯
the whole friend group π«Ά go say hi:
- Kernel file
./drivers/power/supply/power_supply_core.c 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_vbat2ri(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)
and that's the page!! π this lil icon lives over in ./drivers/power/supply and the manual itself is dated October 2026 ποΈβ¨ so yeah, freshly stamped, main character energy, go forth and reference-count responsibly bestie ππ¦π
π¦ 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