BUS_ADD_CHILD(9)
π BUS_ADD_CHILD(9) π
okay bestie, welcome to section 9 of the Kernel Developer's Manual β this is the page for BUS_ADD_CHILD, and it's literally the plug for adding a device node to the tree with a given priority. let's get into it β¨
π SYNOPSIS π
#include <sys/param.h>
#include <sys/bus.h>
device_t
BUS_ADD_CHILD(device_t dev, int order, const char *name, int unit);
like, that's the whole signature, no cap. she takes a dev, an order, a name and a unit, and she hands you back a device_t. π
πΈ DESCRIPTION πΈ
so the BUS_ADD_CHILD() method is what your driver's identify routine uses to add devices to the tree. that's her main character job π«Ά. she can also be used to add children to buses that implement this routine in other contexts, but lowkey the behavior is bus specific β so don't come for me if it's different per bus, that's just how it is. please go read device_add_child(9) for more details, she's the sibling page, they're a duo π.
the interface is the same as device_add_child(9) β same energy, same shape β however, the bus' BUS_ADD_CHILD() is the one that gets called. that distinction is the whole plot twist, iykyk.
now listen, buses that implement BUS_ADD_CHILD() should insert the device into the tree using device_add_child(9) before adding things such as their own ivars and resource lists to the device. order matters, bestie, don't do it backwards π.
and important: BUS_ADD_CHILD() is not called by device_add_child(9). it's the other way around β BUS_ADD_CHILD() instead calls device_add_child(9). not me clarifying this twice but the manpage said it twice so I'm saying it twice, periodt π.
β οΈ and a big one: a panic will result when called for a bus that does not implementBUS_ADD_CHILD(). like, full crash. not cute. also, some buses require a special bus-specific routine to be called instead ofBUS_ADD_CHILD()β so check before you commit, fr fr π
β¨ RETURN VALUES β¨
- the
BUS_ADD_CHILD()method returns thedevice_tadded to the tree π - or
NULLto indicate failure π
that's it, that's the whole vibe check.
π SEE ALSO π
go read them all, they're iconic π
π AUTHORS π
this manual page was written by M. Warner Losh. absolute legend, ate and left no crumbs π
and that's the whole page, babe β BUS_ADD_CHILD(9), Debian, dated April 8, 2018. mwah π
β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2004 M. Warner Losh
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms