DEVICE_DETACH(9)

πŸ’– DEVICE_DETACH(9) β€” the kernel developer's manual, but make it cute ✨

okay bestie, welcome to the DEVICE_DETACH page of the Kernel Developer's Manual 🫢 this one's short and sweet and honestly kind of iconic, so let's get into it πŸ’…


✨ NAME ✨

DEVICE_DETACH β€” detach a device πŸ¦‹

like... it's detaching the device. that's the whole thing. periodt.


🌸 SYNOPSIS 🌸

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

int
DEVICE_DETACH(device_t dev);

yes bestie, those includes are <sys/param.h> and <sys/bus.h>, and the signature is literally int DEVICE_DETACH(device_t dev); β€” no cap πŸ’―


πŸ’« DESCRIPTION πŸ’«

so what are we actually doing here? we're detaching a device πŸ‘‘ and there's two main character scenarios where you'd call this:

  • the user is replacing the driver software πŸ”„
  • the device is about to be physically removed from the system 😭 β€” like for pccard(4) devices, iykyk

and here's the part where you have to be a responsible queen πŸ‘‘ β€” the method should:

  • deallocate any system resources allocated during the DEVICE_ATTACH(9) method 🧹
  • reset the hardware to a sane state β€” i.e., disable interrupts etc. ⚑
bestie please actually do the cleanup 😭 leaving resources hanging is NOT the vibe. clean up after yourself like a grown-up πŸ’…

πŸŽ€ RETURN VALUES πŸŽ€

  • Zero is returned on success ✨
  • otherwise, an appropriate error is returned πŸ’€

that's it. that's the return value section. slay.


🌈 SEE ALSO 🌈

the whole friend group fr fr 🫢 go read DEVICE_ATTACH(9) next, it's literally the other half of this story πŸ’–


🧚 AUTHORS 🧚

This manual page was written by Doug Rabson πŸŽ€ absolute legend, we stan 🌟


and that's a wrap bestie ✨ this page came from the Debian crew, dated June 16, 1998 β€” like, vintage vintage πŸ’œ β€” and it lives in the DEVICE_DETACH(9) slot of the Kernel Developer's Manual. detach responsibly, love u, bye πŸ’…πŸ¦‹

πŸ“¦ where this page comes from