DEVICE_DELETE_CHILD(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… DEVICE_DELETE_CHILD πŸ’…

okay so bestie, welcome to device_delete_child(9) β€” it's a kernel developer's manual page, and honestly? it's giving "small function, big responsibilities." let me put you on 🫢


✨ NAME ✨

device_delete_child β€” delete a child from a device. yes, literally that. the child gets deleted. gone. no cap. πŸ’€


πŸŽ€ SYNOPSIS πŸŽ€

here's the exact vibe, copy it character for character:

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

int
device_delete_child(device_t dev, device_t child);

🌸 DESCRIPTION 🌸

so the specified device gets removed from dev and then deleted. periodt. ✨

but wait β€” if the device is currently attached, it's first detached via device_detach(9). and if device_detach() fails, its error value is returned. like, the function is not gonna pretend everything's fine, it's gonna hand you back that error and let you deal with it. real main character energy, honestly. πŸ”₯

otherwise (and this is the slay part), all descendant devices of child are deleted and zero is returned. the whole little family tree gets cleaned up and you get a 0 back. 🧚

also! the BUS_CHILD_DELETED(9) method is invoked for each device that is deleted. this permits the parent device's driver to tear down any state associated with child devices such as ivars. like it's the parent driver's moment to clean up its own business before everything's gone. respectful. iconic. πŸ‘‘


πŸ’œ RETURN VALUES πŸ’œ

zero is returned on success, otherwise an error is returned. simple, cute, no surprises. πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ’– AUTHORS πŸ’–

this manual page was written by Doug Rabson. thank you Doug, king behavior, we see you. πŸ‘‘


ngl bestie, if you're deleting devices you're already doing some serious kernel work β€” take a vibe check before you ship it, and read the SEE ALSO entries. they're there for a reason. πŸ™ˆ

this page was brought to you by the Debian crew, dated February 5, 2025 β€” DEVICE_DELETE_CHILD(9) in the Kernel Developer's Manual. mwah, bye! πŸ’…βœ¨

πŸ“¦ where this page comes from