subsys_system_register(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ subsys_system_register(9) πŸŽ€

okay bestie, welcome to the Kernel API Manual β€” today's episode: subsys_system_register, aka the function that registers a subsystem at /sys/devices/system/. yes it's a whole vibe. let's get into it ✨


✨ NAME ✨

subsys_system_register β€” register a subsystem at /sys/devices/system/ πŸ’…


🌸 SYNOPSIS 🌸

int subsys_system_register (const struct bus_type *subsys , const struct
       attribute_group **groups );

like, that's the whole signature. no cap. 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • subsys β€” the system subsystem itself. yep, that's the whole description, it's giving minimalism πŸ’€
  • groups β€” the default attributes for the root device πŸŽ€

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” every 'system' subsystem gets a root device at /sys/devices/system/<name>, and <name> is literally just the name of the subsystem. iconic. that root device is allowed to carry subsystem-wide attributes.

all the registered devices live below this single root device πŸ‘‘, and they're named after the subsystem with a simple enumeration number tacked on the end. and get this β€” the registered devices are not explicitly named. the only thing you need to set is 'id' in the device. that's it. that's the whole assignment bestie πŸ“

⚠️ okay this is the important part, pay attention ⚠️ Do not use this interface for anything new. it exists purely for compatibility with bad ideas only. fr fr, don't do it 😭 new subsystems should use plain subsystems instead. and if you gotta add subsystem-wide attributes, add them to the subsystem directory itself β€” not to some fake root-device you created and dropped into /sys/devices/system/<name>. we do not stan fake root devices in this house πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯

also check out the kernel file ./drivers/base/bus.c and honestly the whole friend group:


that's the whole page bestie, you ate that πŸ’…βœ¨

this cutie lives over in ./drivers/base, dropped October 2026 β€” mwah, bye πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from