bus_to_subsys(9)
πΈ bus_to_subsys β like, the whole vibe π
okay so real talk, this is a page from the Kernel API Manual (yes bestie, the kernel has lore) and it's about one little function that's lowkey doing a very specific glow-up: bus_to_subsys. Let's get into it β¨
π NAME π
bus_to_subsys β turns a struct bus_type into a struct subsys_private, and honestly? iconic behavior π«Ά
β SYNOPSIS β
struct subsys_private * bus_to_subsys (const struct bus_type *bus );
like, that's the whole signature. no cap. π¦
π ARGUMENTS π
busβ pointer to thestruct bus_typeyou're trying to look up π that's the one thing you hand it.
β¨ DESCRIPTION β¨
so the driver core internals are obsessed with working on the subsys_private structure β like, they literally cannot function on the external struct bus_type pointer. it's giving main character energy but for the internal struct, periodt. π
what this function does is walk the list of registered busses in the system, find the matching one, and return the internal struct subsys_private that relates to that bus. it's a whole matching game, and yes, it slays. π
β οΈ okay bestie, important caveat time β the reference count of the return value is INCREMENTED if it is notNULL. so when you're done with the pointer you must callsubsys_putin order for it to be properly freed. not me forgetting this and leaking memory π don't be like me fr fr.
π SEE ALSO π
the kernel file ./drivers/base/bus.c is where it all lives, and there's a whole friend group of related functions β all of these made the list, every single one, no skips:
bus_for_each_dev(9), bus_find_device(9), bus_for_each_drv(9), bus_add_device(9), bus_probe_device(9), bus_remove_device(9), bus_add_driver(9), bus_remove_driver(9), bus_rescan_devices(9), device_reprobe(9), bus_register(9), bus_unregister(9), subsys_dev_iter_init(9), subsys_dev_iter_next(9), subsys_dev_iter_exit(9), subsys_system_register(9), subsys_virtual_register(9), driver_find(9), bus_get_dev_root(9) π§
and that's the whole page, bestie β stay hydrated, release your refcounts, and remember: this one's coming at you from ./drivers/base, dated October 2026. mwah πππ
π¦ 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