bus_find_device(9)
π bus_find_device(9) β like, the Kernel API Manual, bestie β¨
okay so this is bus_find_device from section 9 of the Kernel API Manual, and it is literally the device iterator that goes and finds you a particular device. no cap. let's get into it π
πΈ SYNOPSIS πΈ
struct device * bus_find_device (const struct bus_type *bus , struct
device *start , const void *data , device_match_t match );
like, glance at it, absorb it, love it π
β¨ ARGUMENTS β¨
busβ the bus type, bestie. that's the turf we're searching π¦startβ the device you begin with. your starting point, your opening scene, your main character π«Άdataβ data to pass to the match function. little care package for the callback πmatchβ the callback function that checks the device. this is the vibe check in function form π
π DESCRIPTION π
so this is similar to the bus_for_each_dev function above, but here's the glow-up: it returns a reference to a device that is 'found' for later use, as determined by the match callback. so instead of just walking past every device like "k bye", it actually stops and hands you the one you wanted. iconic behaviour, honestly π
here's the rules of the callback, okay, listen:
- the callback should return
0if the device doesn't match π« - and non-zero if it does β
and the important bit: if the callback returns non-zero, this function will return to the caller and not iterate over any more devices. like it found its person and it left the group chat. periodt π₯
ngl that's the whole plot β the match callback decides when we stop, so your callback logic is doing a lot of heavy lifting here. no pressure bestie π
π§ SEE ALSO π§
kernel file ./drivers/base/bus.c plus the whole friend group:
bus_to_subsys(9), bus_for_each_dev(9), bus_for_each_drv(9), bus_add_device(9), bus_probe_device(9), bus_remove_device(9), bus_add_driver(9), bus_remove_driver(9), bus_rescan_devices(9), device_reprobe(9), bus_register(9), bus_unregister(9), subsys_dev_iter_init(9), subsys_dev_iter_next(9), subsys_dev_iter_exit(9), subsys_system_register(9), subsys_virtual_register(9), driver_find(9), bus_get_dev_root(9)
like genuinely go read them all, iykyk ππ
and that's the page!! π this lil masterpiece lives in ./drivers/base, it's dated October 2026, and yeah it's section 9 of the Kernel API Manual β go off and find your device, bestie, you got this βπ
π¦ 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