drm_kunit_h..._with_driver(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 contains struct drm_device. So like, the outer container she lives in πŸ‘‘
  • _member β€” the name of the drm_device within _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 πŸ”₯


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