device_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ device_create(9) β€” Kernel API Manual, but make it make sense πŸŽ€

okay bestie, welcome to device_create(9) from the Kernel API Manual πŸ’… this is the one that makes a device exist in sysfs. main character energy fr.


✨ NAME ✨

device_create β€” creates a device and registers it with sysfs πŸ¦‹


🌸 SYNOPSIS 🌸

struct device * device_create (const struct class *class , struct device
*parent , dev_t devt , void *drvdata , const char *fmt , ... );

like, look at her go πŸ’–


πŸ‘‘ ARGUMENTS πŸ‘‘

  • class β€” pointer to the struct class that this device should be registered to ✨
  • parent β€” pointer to the parent struct device of this new device, if any 🫢
  • devt β€” the dev_t for the char device to be added πŸ’«
  • drvdata β€” the data to be added to the device for callbacks πŸ“
  • fmt β€” string for the device's name πŸŽ€
  • ... β€” variable arguments 🌈

πŸ’œ DESCRIPTION πŸ’œ

so here's the vibe: this function can be used by char device classes. a struct device will be created in sysfs, registered to the specified class. iconic behaviour, no cap ✨

a "dev" file will be created, showing the dev_t for the device, if the dev_t is not 0,0. like, zero-zero? no file for you πŸ™ˆ

if a pointer to a parent struct device is passed in, the newly created struct device will be a child of that device in sysfs β€” literal family tree 🧚

the pointer to the struct device will be returned from the call, and any further sysfs files that might be required can be created using this pointer. so keep her safe πŸ’…

Returns struct device pointer on success, or ERR_PTR on error 😭 so please, please check her before you dereference her.

ngl the ERR_PTR bit is the part everyone forgets and then spends three hours debugging. don't be that girl πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

literally the whole neighborhood, bestie β€” kernel file ./drivers/base/core.c and all of these:


okay that's the whole page, go forth and register your devices responsibly 🫢✨

and finally, the cute little sign-off: this icon lives in ./drivers/base, dated October 2026, and she's filed under device_create(9) πŸ’– bye bestie, slay your sysfs 🌸

πŸ“¦ where this page comes from