device_register(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ device_register(9) ✨

okay so this is the device_register page from the Kernel API Manual, and bestie it's a short one but the NOTE at the bottom is load-bearing, so don't scroll past it πŸ’…


🌸 NAME 🌸

device_register β€” register a device with the system.

like, you have a device. the system does not know about it. we fix that. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

int device_register (struct device *dev );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” pointer to the device structure. that's it. that's the whole arg, she's lowkey simple like that ✨

πŸ’– DESCRIPTION πŸ’–

This happens in two clean steps β€” initialize the device, then add it to the system. two steps, very demure, very mindful. 🧚

The two steps can be called separately, but calling device_register is the easiest and most common way to do it. fr fr, this is the main character path.

So when should you split them up into the two separate helpers? Only if you have a clearly defined need to use and refcount the device before it gets added to the hierarchy. that's the vibe check. no clear need? don't split. πŸ‘‘

For more information, go read the kerneldoc for device_initialize and device_add β€” that's where the lore lives πŸ“š

⚠️ NOTE Never directly free dev after calling this function β€” even if it returned an error! 😭 like genuinely never, not "never except when it fails", never never. Always use put_device to give up the reference that got initialized in this function instead. that's the whole move. put_device, not kfree. periodt. πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./drivers/base/core.c, plus this entire extended fam β€” all (9) sections, all iconic, all listed exactly as they come πŸ‘‘:


and that's the page!! shoutout to ./drivers/base for housing all this, and to the October 2026 release for stamping it β€” go register some devices bestie, and remember: put_device, not free. iykyk πŸ’œπŸŽ€

πŸ“¦ where this page comes from