class_create(9)
π class_create(9) π
okay so this is a page straight out of the Kernel API Manual and honestly? it's a little baby page but it's got main character energy. the whole thing lives in ./drivers/base and it's all about making one very specific thing: a struct class. let's get into it bestie β¨
πΈ NAME πΈ
class_create β create a struct class structure
like. that's it. that's the whole job. she makes a class. iconic behaviour tbh π
π SYNOPSIS π
struct class * class_create (const char *name );
one function, one argument, returns a pointer to a struct class. short and sweet, we love a low-effort queen π
π¦ ARGUMENTS π¦
nameβ pointer to a string for the name of this class. yeah that's it, just hand her a name and she'll do the rest π«Ά
β¨ DESCRIPTION β¨
so here's the vibe: this is used to create a struct class pointer that can then be used in calls to device_create. that's the whole pipeline β you make the class here, then you go make devices with it. slay π₯
Returns struct class pointer on success, or ERR_PTR on error. so like, check your return value babes, ERR_PTR is not a real class and she will not act like one π
no cap, important note: the pointer created here is to be destroyed when finished by making a call to class_destroy. you do NOT get to just walk away from her. clean up after yourself. she's not a ghost, she's a resource π
π SEE ALSO π
Kernel file ./drivers/base/class.c and honestly the whole friend group:
class_to_subsys(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)
go read all of them, they're all in ./drivers/base/class.c and they're all literally so good together π
and that's the page!! this little gem is from ./drivers/base, dated October 2026, and it'll see you in the Kernel API Manual. mwah, go destroy your classes responsibly ππ§
π¦ 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