DEVICE_ATTACH(9)

πŸ’– DEVICE_ATTACH πŸ’–

okay bestie, gather round, because we're talking about the DEVICE_ATTACH(9) manual page from the Kernel Developer's Manual, and honestly? it's giving glow up for your hardware. πŸ¦‹


✨ NAME ✨

DEVICE_ATTACH β€” attach a device πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

int
DEVICE_ATTACH(device_t dev);

like, that's it. two headers, one function, zero drama. ✨


πŸŽ€ DESCRIPTION πŸŽ€

so here's the tea, bestie πŸ«– β€” you call DEVICE_ATTACH() to attach a device to the system, but ONLY after the DEVICE_PROBE() method has already been called and has said "yeah, this device exists." no cap, the probe has to go first. πŸ™ˆ

once you're in there, the DEVICE_ATTACH() method has two jobs and it does NOT half-do them:

  • it should initialize the hardware πŸ”₯
  • and it should allocate other system resources β€” think stuff like devfs(5) entries ✨

and here's the part that's lowkey iconic: devices that implement buses should use this method to probe for the existence of devices attached to the bus, and then add them as children. πŸ‘‘

and if you pair that with bus_generic_attach(9)? the child devices will be automatically probed AND attached. it's giving hands-free parenting. 🧚 periodt.


πŸ’€ RETURN VALUES πŸ’€

  • Zero is returned on success βœ…
  • otherwise, an appropriate error is returned 😭

that's the whole vibe check. zero = slay, anything else = something went sideways.


πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk πŸ“š


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson <dfr@FreeBSD.org>. absolute main character energy, we stan. 🫢


and that's the whole page, bestie! this version came to you courtesy of the Debian manual, dated January 15, 2017, and the original title was of course DEVICE_ATTACH(9) from the Kernel Developer's Manual. go forth and attach responsibly πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from