STRUCT SUBSYS_PRIVATE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct subsys_private πŸ’… (from the Kernel API Manual, bestie)

okay so like… this page is literally about struct subsys_private, and yes it's exactly what it sounds like: it's the structure that holds all the private-to-the-driver-core bits of the bus_type/class structure. no cap, that's the whole vibe ✨


🌸 NAME 🌸

struct subsys_private β€” the structure that holds the private, driver-core-only portions of the bus_type/class structure. it's giving "backstage pass, not for public consumption" πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

struct subsys_private {
    struct kset subsys;
    struct kset *devices_kset;
    struct list_head interfaces;
    struct mutex mutex;
    struct kset *drivers_kset;
    struct klist klist_devices;
    struct klist klist_drivers;
    struct blocking_notifier_head bus_notifier;
    unsigned int drivers_autoprobe:1;
    const struct bus_type *bus;
    struct device *dev_root;
    struct kset glue_dirs;
    const struct class *class;
    struct lock_class_key lock_key;
 };

like, look at her. iconic. absolutely ate that struct definition πŸ‘‘


🧚 Members (the whole cast, no skips) 🧚

  • subsys β€” the struct kset that defines this subsystem. it's the main character of the whole operation tbh.
  • devices_kset β€” the subsystem's 'devices' directory. like, where the devices live 🏠
  • interfaces β€” the list of subsystem interfaces associated. lowkey just a list of who's hanging out here.
  • mutex β€” protects the devices and interfaces lists. do not skip the lock, bestie, fr fr 😭
  • drivers_kset β€” the list of drivers associated. the driver squad πŸš—
  • klist_devices β€” the klist you use to iterate over the devices_kset. that's the whole job. iykyk.
  • klist_drivers β€” the klist to iterate over the drivers_kset. same energy, different list πŸ’«
  • bus_notifier β€” the bus notifier list, for anything that cares about things on this bus. and yes, some things really do care πŸ‘€
  • drivers_autoprobe β€” the gate that decides whether new devices automatically get attached to registered drivers, or new drivers automatically attach to existing devices. it's literally a unsigned int drivers_autoprobe:1 bitfield. one single bit running the whole show πŸ’€
  • bus β€” pointer back to the struct bus_type that this structure is associated with. a little "take me home" pointer 🫢
  • dev_root β€” the default device to use as the parent. every icon needs a parent, periodt.
  • glue_dirs β€” the "glue" directory that goes in-between the parent device so you avoid namespace conflicts. it's the buffer friend at the party πŸŽ€
  • class β€” pointer back to the struct class that this structure is associated with. matching set with bus, obviously ✨
  • lock_key β€” the lock class key, for use by the lock validator. very responsible of her ngl πŸ”

πŸ’– Description πŸ’–

so here's the tea: this structure is the one β€” it's the actual kobject that lets struct bus_type/class be statically allocated safely. that's the flex. πŸ†

⚠️ real talk: nothing outside of the driver core should ever touch these fields. not you, not your friend, not your friend's friend. hands off, bestie πŸ™ˆ

🌈 SEE ALSO 🌈

  • Kernel file ./drivers/base/base.h
  • struct device_private(9) β€” go read that one next, it's connected, trust πŸ¦‹

and that's the page! 🫢 shoutout to ./drivers/base for hosting this one, this is the Kernel API Manual, dated October 2026, and this has been your girl explaining struct subsys_private(9) β€” stay safe, lock your mutexes, and don't touch driver-core fields πŸ’…βœ¨πŸ‘‘

πŸ“¦ where this page comes from