bus_find_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 0 if 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