subsys_system_register(9)
π 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:
bus_to_subsys(9)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_virtual_register(9)driver_find(9)bus_get_dev_root(9)
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
- 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