class_to_subsys(9)
β¨ class_to_subsys(9) β¨
okay so bestie, welcome to the kernel API manual, section 9 β we're getting into the driver core internals today and honestly? it's giving backstage pass energy π
πΈ NAME πΈ
class_to_subsys β turn a struct class into a struct subsys_private
π¦ SYNOPSIS π¦
struct subsys_private * class_to_subsys (const struct class *class );
π ARGUMENTS π
classβ pointer to thestruct bus_typeto look up
π DESCRIPTION π
so here's the tea π΅ β the driver core internals need to work on the subsys_private structure, not on the external struct class pointer. like, that's just not the vibe they operate on, y'know?
so what this function does is it walks the list of registered classes in the system, finds the matching one, and returns the internal struct subsys_private that relates to that class. it's literally matchmaking for structs π«Άβ¨
β οΈ IMPORTANT NOTE, bestie, do not skip this one: the reference count of the return value is INCREMENTED if it is notNULL. you must callsubsys_putwhen you're finished with the pointer so it gets properly freed. no cap β if you don't, that memory is gonna be sitting there forever and the kernel will be looking at you like π
π₯ SEE ALSO π₯
Kernel file ./drivers/base/class.c
class_create(9)class_destroy(9)class_dev_iter_init(9)class_dev_iter_next(9)class_dev_iter_exit(9)class_for_each_device(9)class_find_device(9)class_compat_register(9)class_compat_unregister(9)class_compat_create_link(9)class_compat_remove_link(9)class_is_registered(9)
β sign-off β
and that's the whole page, bestie! this one lives over in ./drivers/base, it's the October 2026 edition of the kernel API manual, and it's literally titled class_to_subsys(9) β go forth and remember to subsys_put πππ§ββοΈ
π¦ 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