BUS_ADD_CHILD(9)

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

πŸ’– BUS_ADD_CHILD(9) πŸ’–

okay bestie, welcome to the Kernel Developer's Manual entry for BUS_ADD_CHILD(9) ✨ this is the whole vibe: add a device node to the tree with a given priority. no cap, it's giving kernel-tree matchmaker energy 🫢


🌸 NAME 🌸

BUS_ADD_CHILD β€” add a device node to the tree with a given priority πŸ’…


✨ SYNOPSIS ✨

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

device_t
BUS_ADD_CHILD(device_t dev, int order, const char *name, int unit);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the BUS_ADD_CHILD() method is what the driver identify routine uses to add devices to the tree 🌈 it can also be used to add children to buses that implement this routine in other contexts, but the behavior is bus specific, so check yourself before you wreck yourself πŸ’€ please see device_add_child(9) for more details, iykyk.

the interface is the same as device_add_child(9), however the bus' BUS_ADD_CHILD() is the one that gets called ✨

if you're a bus implementing BUS_ADD_CHILD(), the move is to insert the device into the tree using device_add_child(9) before you start adding things like your own ivars and resource lists to that device πŸ‘‘

and no, device_add_child(9) does not call BUS_ADD_CHILD(). it's the other way around: BUS_ADD_CHILD() calls device_add_child(9) πŸŽ€

🚨 warning bestie 🚨 A panic will result when called for a bus that does not implement BUS_ADD_CHILD(). that is not the cute outcome. also, some buses require a special bus-specific routine to be called instead of BUS_ADD_CHILD() πŸ™ˆ

πŸ’œ RETURN VALUES πŸ’œ

the BUS_ADD_CHILD() method returns the device_t added to the tree, or NULL to indicate failure 🌸 so if you get NULL, that's a no from the kernel, bestie 😭


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by M. Warner Losh πŸ’– iconic behavior, honestly.


cute little sign-off: this footer moment is brought to you by Debian, dated April 8, 2018 β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from