power_suppl...em_batteries(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– power_supply_get_system_batteries πŸ’–

okay so real talk β€” this is a page from the Kernel API Manual, and it's about one very specific little helper: power_supply_get_system_batteries. she's giving "backstage pass to every battery in the system" energy and honestly? iconic. let's get into it 🫢


✨ NAME ✨

power_supply_get_system_batteries β€” fetches references to battery type power supplies in the system. literally that's her whole job πŸ’…


🌸 SYNOPSIS 🌸

int power_supply_get_system_batteries (struct device *dev , struct
power_supply ***psys );

look at that triple pointer bestie. *** β€” she SAID what she said πŸ’€


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” pointer to the device that's requesting the power supply refs. like, who's asking? it's dev. hi dev πŸ‘‹
  • psys β€” pointer to an array of power supply refs. that's where the goodies land ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a helper function whose whole moment is getting handles to battery type power supplies in the system. main character behavior fr fr πŸ‘‘

okay but here's the important part, no cap: if acquiring a ref to a power supply fails, then the search for battery type power supplies will abort, and the power supply references that were already acquired will be released. so she cleans up after herself if things go sideways β€” we love a responsible queen πŸ˜­πŸ’–

🚨 bestie please remember: call power_supply_put_system_batteries after use to cleanup resources. don't just leave the refs lying around, that's not the vibe πŸ™ˆ

⭐ RETURN ⭐

indicates the number of battery type power supplies returned on success πŸŽ‰ β€” or a negative error code on failure πŸ’€. that's it, that's the whole deal.


🌈 SEE ALSO 🌈

kernel file ./drivers/power/supply/power_supply_core.c β€” that's where she lives, go say hi 🧚

a whole friend group honestly. the way they all show up together πŸ₯Ή


and that's the page!! this one's from ./drivers/power/supply, dated October 2026, and yeah β€” that's the whole manual. now go put those batteries back when you're done πŸ“πŸ’œ

πŸ“¦ where this page comes from