kunit_platform_device_add(9)
π kunit_platform_device_add(9)
okay so bestie, welcome to the Kernel API Manual β¨ this one's kunit_platform_device_add(9) and it's literally the chillest way to hand a platform device over to KUnit and let the test framework clean up after you π«Ά
β¨ SYNOPSIS β¨
int kunit_platform_device_add (struct kunit *test , struct platform_device *pdev );
πΈ ARGUMENTS πΈ
testβ the test context, aka your main character β¨ it's thestruct kunit *that owns the device's whole lifecycle.pdevβ the platform device to add, thestruct platform_device *you're handing over π
π DESCRIPTION π
So here's the vibe: you call this and it registers a test managed platform device. The way that works is π KUnit takes ownership β when the test completes, the device gets unregistered for you. No manual teardown, no "oops I forgot to clean up," no cap fr fr π¦
Like, you add it, the test runs, the test finishes, and the device is gone. Slay π
π₯ RETURN π₯
0on success β¨ ate- negative errno on failure π (not me getting a negative back β yeah bestie, check it)
π SEE ALSO π
Kernel file ./lib/kunit/platform.c and the rest of the friend group:
kunit_platform_device_alloc(9)kunit_platform_device_register_full(9)kunit_platform_device_unregister(9)kunit_platform_device_prepare_wait_for_probe(9)kunit_platform_driver_register(9)
ngl, if you're poking around in ./lib/kunit you're already doing amazing, keep going π§
and that's the page bestie π this one lives in ./lib/kunit, dated October 2026 β vintage without even trying π catch you in the next manpage π
π¦ 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