kunit_devic..._with_driver(9)
π kunit_device_register_with_driver β NAME
okay so bestie, this one is kunit_device_register_with_driver and its whole job is literally: Create a struct device for use in KUnit tests. That's it. That's the vibe. π
β¨ SYNOPSIS β¨
struct device * kunit_device_register_with_driver (struct kunit *test ,
const char *name , const struct device_driver *drv );
no cap, that's the whole signature. three args, one pointer back, slay. π
π«Ά ARGUMENTS π«Ά
testβ the test context object. your kunit home base, the main character of the test suite πnameβ the name you're giving the created device. pick something cute, it's yours πΈdrvβ thestruct device_driveryou want to associate with the device. the driver bestie, fr fr π₯
π¦ DESCRIPTION π¦
So what it does is: it creates a struct kunit_device (which is a struct device, iykyk) with the given name and the given driver.
And here's the iconic part β the device gets cleaned up on test exit, or when kunit_device_unregister is called. automatic cleanup? we love to see it. β¨
also peepkunit_device_registerif you wish KUnit to create and manage a driver for you β like, if you don't wanna hand it adrvyourself, that's the one. π§
π RETURN π
It returns a pointer to a struct device which will be cleaned up when the test exits π«Ά β¦or an error pointer if the device could not be allocated or registered π (yes, check it, don't just rawdog the pointer, ok?)
π SEE ALSO π
- Kernel file
./include/kunit/device.h kunit_driver_create(9)kunit_device_register(9)kunit_device_unregister(9)
go read them, they're giving reference material, you'll be obsessed π
and that's the whole page babes β straight from ./include/kunit, dated October 2026, kernel API manual energy only β 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