class_to_subsys(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 the struct bus_type to 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 not NULL. you must call subsys_put when 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


⭐ 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