drm_kunit_h..._with_driver(9)
π drm_kunit_h..._with_driver(9) β from the Kernel API Manual, bestie
Okay so picture this: you're deep in KUnit testing, you need a mock DRM device, and you do not want to hand-roll one. That's literally this function's whole job. Welcome to drm_kunit_helper_alloc_drm_device_with_driver π
β¨ NAME β¨
drm_kunit_helper_alloc_drm_device_with_driver β it allocates a mock DRM device for KUnit tests, no cap π«Ά
π¦ SYNOPSIS π¦
drm_kunit_helper_alloc_drm_device_with_driver (_test , _dev , _type ,
_member , _drv );
Like yes, that's a lot of underscores, she's a macro, she's allowed π
πΈ ARGUMENTS πΈ
_testβ the test context object. Your main character test struct, the whole vibe check of the run β¨_devβ the parent device object π§_typeβ the type of the struct which containsstruct drm_device. So like, the outer container she lives in π_memberβ the name of thedrm_devicewithin_type. Telling us exactly where to find her π_drvβ the mocked DRM device driver features. All the pretend-driver detail π
π DESCRIPTION π
This function creates a struct drm_device from _dev and _drv. Simple as that, periodt.
Heads up though, important detail: _dev should be allocated using drm_kunit_helper_alloc_device. Don't just vibe in with any random device, use the helper, iykyk π
The driver gets tied to the _test context and will be cleaned up at the end of the test β it's giving responsible, self-cleaning icon behavior β¨ And the drm_device itself is allocated through devm_drm_dev_alloc, so it gets freed through a device-managed resource. No manual cleanup arc needed, the devres machinery handles it for you π
β RETURN β
A pointer to the new drm_device π β or an ERR_PTR otherwise π (always check, bestie, always check).
π₯ SEE ALSO π₯
- Kernel file
./include/drm/drm_kunit_helpers.h drm_kunit_helper_alloc_drm_device(9)
That's the whole page, bestie, go write some tests π
Source path: ./include/drm Β· dated October 2026 Β· filed under drm_kunit_h..._with_driver(9) β mwah, catch you in the group chat π¦π
π¦ 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