FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Register that a device driver has been added to a devclass
 *
 * Register that a device driver has been added to a devclass.  This
 * is called by devclass_add_driver to accomplish the recursive
 * notification of all the children classes of dc, as well as dc.
 * Each layer will have BUS_DRIVER_ADDED() called for all instances of
 * the devclass.
 *
 * We do a full search here of the devclass list at each iteration
 * level to save storing children-lists in the devclass structure.  If
 * we ever move beyond a few dozen devices doing this, we may need to
 * reevaluate...
 *
 * @param dc		the devclass to edit
 * @param driver	the driver that was just added
 */
@brief Register that a device driver has been added to a devclass
Register that a device driver has been added to a devclass.  This
is called by devclass_add_driver to accomplish the recursive
notification of all the children classes of dc, as well as dc.
Each layer will have BUS_DRIVER_ADDED() called for all instances of
the devclass.

We do a full search here of the devclass list at each iteration
level to save storing children-lists in the devclass structure.  If
we ever move beyond a few dozen devices doing this, we may need to
reevaluate

@param dc            the devclass to edit
@param driver        the driver that was just added
@brief Register that a device driver has been added to a devclass Register that a device driver has been added to a devclass . This is called by devclass_add_driver to accomplish the recursive notification of all the children classes of dc as well as dc . Each layer will have BUS_DRIVER_ADDED () called for all instances of the devclass . We do a full search here of the devclass list at each iteration level to save storing children - lists in the devclass structure . If we ever move beyond a few dozen devices doing this we may need to reevaluate @param dc the devclass to edit @param driver the driver that was just added
static void
devclass_driver_added(devclass_t dc, driver_t *driver)
{
	devclass_t parent;
	int i;
	for (i = 0; i < dc->maxunit; i++)
		if (dc->devices[i] && device_is_attached(dc->devices[i]))
			BUS_DRIVER_ADDED(dc->devices[i], driver);
	if (!(dc->flags & DC_HAS_CHILDREN))
		return;
	parent = dc;
	TAILQ_FOREACH(dc, &devclasses, link) {
		if (dc->parent == parent)
			devclass_driver_added(dc, driver);
	}
}
static void devclass_driver_added ( devclass_t dc , driver_t * driver ) { devclass_t parent ; int i ; for ( i = 0 ; i < dc -> maxunit ; i ++ ) if ( dc -> devices [ i ] && device_is_attached ( dc -> devices [ i ] ) ) BUS_DRIVER_ADDED ( dc -> devices [ i ] , driver ) ; if ( ! ( dc -> flags & DC_HAS_CHILDREN ) ) return ; parent = dc ; TAILQ_FOREACH ( dc , & devclasses , link ) { if ( dc -> parent == parent ) devclass_driver_added ( dc , driver ) ; } }
@brief Register that a device driver has been added to a devclass
 Register that a device driver has been added to a devclass.
@brief Register that a device driver has been added to a devclass Register that a device driver has been added to a devclass .
/*
	 * Call BUS_DRIVER_ADDED for any existing busses in this class.
	 */ /*
	 * Walk through the children classes.  Since we only keep a
	 * single parent pointer around, we walk the entire list of
	 * devclasses looking for children.  We set the
	 * DC_HAS_CHILDREN flag when a child devclass is created on
	 * the parent, so we only walk the list for those devclasses
	 * that have children.
	 */