FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Create a new device
 *
 * This creates a new device and adds it as a child of an existing
 * parent device. The new device will be added after the last existing
 * child with the same order.
 *
 * @param dev		the device which will be the parent of the
 *			new child device
 * @param order		a value which is used to partially sort the
 *			children of @p dev - devices created using
 *			lower values of @p order appear first in @p
 *			dev's list of children
 * @param name		devclass name for new device or @c NULL if not
 *			specified
 * @param unit		unit number for new device or @c -1 if not
 *			specified
 *
 * @returns		the new device
 */
@brief Create a new device
This creates a new device and adds it as a child of an existing
parent device. The new device will be added after the last existing
child with the same order.



@returns             the new device
@brief Create a new device This creates a new device and adds it as a child of an existing parent device . The new device will be added after the last existing child with the same order . @returns the new device
device_t
device_add_child_ordered(device_t dev, u_int order, const char *name, int unit)
{
	device_t child;
	device_t place;
	PDEBUG(("%s at %s with order %u as unit %d",
	    name, DEVICENAME(dev), order, unit));
	KASSERT(name != NULL || unit == -1,
	    ("child device with wildcard name and specific unit number"));
	child = make_device(dev, name, unit);
	if (child == NULL)
		return (child);
	child->order = order;
	TAILQ_FOREACH(place, &dev->children, link) {
		if (place->order > order)
			break;
	}
	if (place) {
		TAILQ_INSERT_BEFORE(place, child, link);
	} else {
		TAILQ_INSERT_TAIL(&dev->children, child, link);
	}
	bus_data_generation_update();
	return (child);
}
device_t device_add_child_ordered ( device_t dev , u_int order , const char * name , int unit ) { device_t child ; device_t place ; PDEBUG ( ( " " , name , DEVICENAME ( dev ) , order , unit ) ) ; KASSERT ( name != NULL || unit == -1 , ( " " ) ) ; child = make_device ( dev , name , unit ) ; if ( child == NULL ) return ( child ) ; child -> order = order ; TAILQ_FOREACH ( place , & dev -> children , link ) { if ( place -> order > order ) break ; } if ( place ) { TAILQ_INSERT_BEFORE ( place , child , link ) ; } else { TAILQ_INSERT_TAIL ( & dev -> children , child , link ) ; } bus_data_generation_update ( ) ; return ( child ) ; }
@brief Create a new device
 This creates a new device and adds it as a child of an existing
 parent device.
@brief Create a new device This creates a new device and adds it as a child of an existing parent device .
/*
		 * The device 'place' is the first device whose order is
		 * greater than the new child.
		 */ /*
		 * The new child's order is greater or equal to the order of
		 * any existing device. Add the child to the tail of the list.
		 */