platform_device_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ platform_device_alloc β€” Kernel API Manual ✨

okay so bestie, welcome to the Kernel API Manual πŸ’– this one's a lil function with main character energy: platform_device_alloc. let's get into it 🫢


🌸 NAME 🌸

platform_device_alloc β€” create a platform device πŸŽ€


⭐ SYNOPSIS ⭐

struct platform_device * platform_device_alloc (const char *name , int
id );

like, yes, it really does wrap like that in the original, no cap 😭


πŸ¦‹ ARGUMENTS πŸ¦‹

  • name β€” the base name of the device we're adding. that's your baby's name, choose wisely ✨
  • id β€” the instance id. y'know, in case you have several of these lil guys running around πŸ‘‘

πŸ’… DESCRIPTION πŸ’…

So what does it do? It creates a platform device object πŸ’– and the slay part is that other objects can get attached to it, and then when the platform device is released, all those attached objects get freed too. it's giving "I've got you, bestie, I'll clean up" energy 🧹✨

⚠️ ok this part is important, don't skip it: these fields of the dynamically allocated platform device must not be modified manually β€” resource, num_resources, dev.platform_data, dev.of_node and dev.fwnode. like, hands off πŸ™ˆ

And if you're the kind of person who wants to do the split platform device registration thing with platform_device_alloc + platform_device_add? totally valid, love that for you πŸ’β€β™€οΈ but you are required to use the dedicated helpers for adding resources, platform data, or assigning firmware nodes. no DIY-ing it, periodt. πŸš«πŸ”§


🌈 SEE ALSO 🌈

everything else in the platform device cinematic universe, fr fr:


and that's the whole page, bestie πŸ’œ this lil gem lives in ./drivers/base, stamped October 2026 β€” go forth and allocate responsibly, mwah πŸ˜˜πŸŽ€βœ¨

πŸ“¦ where this page comes from