kunit_devic..._with_driver(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the struct device_driver you 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 peep kunit_device_register if you wish KUnit to create and manage a driver for you β€” like, if you don't wanna hand it a drv yourself, 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 🌈

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