devm_power_s...by_reference(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ devm_power_s...by_reference(9) ✨

okay so this is a page from the Kernel API Manual, and honestly? it's a little baddie of a function πŸ’… it's the resource-managed glow-up of power_supply_get_by_reference(), and yes that's the whole personality. it grabs you a power supply reference and then cleans up after itself like a responsible main character. we love to see it 🫢


🌸 SYNOPSIS 🌸

struct power_supply * devm_power_supply_get_by_reference (struct device
*dev , const char *property );

like literally that's the whole call bestie, go off πŸ”₯


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” pointer to the device that's holding the phandle property. it's the device doing the holding, okay? 🫢
  • property β€” the name of the property that holds a power supply phandle. so like, the property name string, and inside it lives a phandle pointing at a power supply ✨

πŸ’– RETURN πŸ’–

on success you get a reference to a power supply whose name equals the value under property β€” slay πŸ’…

otherwise? you get NULL or ERR_PTR. so yeah, check your returns, no cap 😭 (and if it's an ERR_PTR don't go dereferencing it, that's not the vibe, that's undefined behaviour territory fr fr πŸ’€)


πŸ¦‹ SEE ALSO πŸ¦‹

the kernel file lives at ./drivers/power/supply/power_supply_core.c β€” that's the source of truth, iykyk πŸ‘‘

and the whole friend group of related calls, all iconic, all listed here:

ngl, power_supply_put(9) is right there in the list for a reason β€” a reference you got is a reference you eventually give back. the devm_ prefix just means the cleanup is handled for you when the device goes away 🧚

and that's the page!! it came from ./drivers/power/supply, dated October 2026, and it's filed under the devm_power_s...by_reference(9) name πŸ’œ mwah, go read power_supply_core.c bestie, it's giving source-of-truth energy 🌈⭐

πŸ“¦ where this page comes from