platform_device_alloc(9)
β¨ 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_nodeanddev.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:
- Kernel file
./drivers/base/platform.cπ platform_get_resource(9)devm_platform_get_and_ioremap_resource(9)devm_platform_ioremap_resource(9)devm_platform_ioremap_resource_byname(9)platform_get_irq_affinity(9)platform_get_irq_optional(9)platform_get_irq(9)platform_irq_count(9)devm_platform_get_irqs_affinity(9)platform_get_resource_byname(9)platform_get_irq_byname(9)platform_get_irq_byname_optional(9)platform_add_devices(9)platform_device_put(9)platform_device_add_resources(9)platform_device_add_data(9)platform_device_set_of_node(9)platform_device_set_fwnode(9)platform_device_set_of_node_from_dev(9)platform_device_add(9)platform_device_del(9)platform_device_register(9)platform_device_unregister(9)platform_device_register_full(9)__platform_driver_register(9)platform_driver_unregister(9)__platform_driver_probe(9)__platform_create_bundle(9)__platform_register_drivers(9)platform_unregister_drivers(9)platform_match(9)platform_find_device_by_driver(9)
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
- 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