driver_find_device(9)
β¨ driver_find_device(9) β¨
okay so real talk, this is a page from the Kernel API Manual, and bestie, it's a good one. driver_find_device β say it with me β is the device iterator for locating a particular device. That's the whole NAME section, and honestly? iconic. π
π«Ά SYNOPSIS π«Ά
struct device * driver_find_device (const struct device_driver *drv ,
struct device *start , const void *data , device_match_t match );
like, look at that signature. she's got four args and she returns a struct device *. slay. β¨
π ARGUMENTS π
drvβ the device's driver. like, the driver that owns the device you're snooping around for. no notes.startβ the device to begin with. your starting point, your little launchpad, the first one in line. π¦dataβ data to pass to the match function. it just gets handed straight to your callback, no questions asked.matchβ the callback function that checks each device. this is the main character of the whole operation, fr fr. it decides who's "found" and who's just... not.
π DESCRIPTION π
so the vibe here is very similar to the driver_for_each_device function mentioned above β same general energy β but the difference is that this one returns a reference to a device that's 'found' for later use, as determined by the match callback. so instead of just looping over everything and moving on with your life, she actually hands you back the one you were looking for. obsessed. π
here's the rules for the callback, bestie, write them down: it should return 0 if the device doesn't match, and non-zero if it does. non-zero means match. no cap, that's the deal.
and here's the part where it gets a little spicy πΆοΈ β if the callback returns non-zero, this function will return to the caller and not iterate over any more devices. like, she's done, she found her girl, the search is over, everybody go home. periodt. π₯
ngl the zero/non-zero thing trips people up constantly. 0 = nope, non-zero = yep. don't do it backwards, i'm begging. π
π§ SEE ALSO π§
- Kernel file
./drivers/base/driver.c driver_for_each_device(9)driver_create_file(9)driver_remove_file(9)driver_register(9)driver_unregister(9)
and that's the whole page, bestie, you ate that π β this little gem lives in ./drivers/base, and it's dated October 2026. go forth and find your devices. ππ¦πΈ
π¦ 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