power_suppl...by_reference(9)
β¨ power_supply_get_by_reference(9) β¨
okay bestie so we're in the Kernel API Manual today (yes, the Kernel API Manual, we're fancy) and the page name is literally truncated to power_suppl...by_reference(9) because the kernel is a drama queen who cannot fit her own function names π
anyway β welcome to the group chat, let's learn how to grab a power supply by reference π«Ά
πΈ NAME πΈ
power_supply_get_by_reference β searches for a power supply and returns its ref, no cap π₯
π SYNOPSIS π
struct power_supply * power_supply_get_by_reference (struct
fwnode_handle *fwnode , const char *property );
like, she takes two things and returns a pointer to a struct power_supply, that's the whole vibe π
π¦ ARGUMENTS π¦
fwnodeβ pointer to the fwnode holding the phandle property. iykyk, this is where the magic lives β¨propertyβ the name of the property holding a power supply name. yes bestie, a name inside a name, it's giving inception π
π DESCRIPTION π
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 holding onto that thing so it doesn't get yanked away from under you, lowkey iconic protective energy π
β οΈ bestie listen to me. the user should call power_supply_put after usage. this is not optional, this is a should with main character energy β you grabbed a reference, you give it back π
β RETURN β
on success, returns a reference to a power supply with matching name equal to the value under property π
otherwise? NULL or ERR_PTR. fr fr, that's it π
π§ SEE ALSO π§
- kernel file
./drivers/power/supply/power_supply_core.c(go read the source, it ate π₯) power_supply_get_by_name(9)power_supply_get_system_batteries(9)power_supply_put_system_batteries(9)power_supply_put(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)
that's a whole friend group right there, periodt π
and that's the page!! she lives in ./drivers/power/supply and dated October 2026, so mark your calendars bestie ππβ¨ bye ugh ily π
π¦ 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