FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Probe a device, and return this status.
 *
 * This function is the core of the device autoconfiguration
 * system. Its purpose is to select a suitable driver for a device and
 * then call that driver to initialise the hardware appropriately. The
 * driver is selected by calling the DEVICE_PROBE() method of a set of
 * candidate drivers and then choosing the driver which returned the
 * best value. This driver is then attached to the device using
 * device_attach().
 *
 * The set of suitable drivers is taken from the list of drivers in
 * the parent device's devclass. If the device was originally created
 * with a specific class name (see device_add_child()), only drivers
 * with that name are probed, otherwise all drivers in the devclass
 * are probed. If no drivers return successful probe values in the
 * parent devclass, the search continues in the parent of that
 * devclass (see devclass_get_parent()) if any.
 *
 * @param dev		the device to initialise
 *
 * @retval 0		success
 * @retval ENXIO	no driver was found
 * @retval ENOMEM	memory allocation failure
 * @retval non-zero	some other unix error code
 * @retval -1		Device already attached
 */
@brief Probe a device, and return this status.
This function is the core of the device autoconfiguration
system. Its purpose is to select a suitable driver for a device and
then call that driver to initialise the hardware appropriately. The
driver is selected by calling the DEVICE_PROBE() method of a set of
candidate drivers and then choosing the driver which returned the
best value. This driver is then attached to the device using
device_attach().

The set of suitable drivers is taken from the list of drivers in
the parent device's devclass. If the device was originally created
with a specific class name ), only drivers
with that name are probed, otherwise all drivers in the devclass
are probed. If no drivers return successful probe values in the
parent devclass, the search continues in the parent of that
devclass ) if any.

@param dev           the device to initialise


@brief Probe a device and return this status . This function is the core of the device autoconfiguration system . Its purpose is to select a suitable driver for a device and then call that driver to initialise the hardware appropriately . The driver is selected by calling the DEVICE_PROBE () method of a set of candidate drivers and then choosing the driver which returned the best value . This driver is then attached to the device using device_attach () . The set of suitable drivers is taken from the list of drivers in the parent device ' s devclass . If the device was originally created with a specific class name ) only drivers with that name are probed otherwise all drivers in the devclass are probed . If no drivers return successful probe values in the parent devclass the search continues in the parent of that devclass ) if any . @param dev the device to initialise
int
device_probe(device_t dev)
{
	int error;
	GIANT_REQUIRED;
	if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0)
		return (-1);
	if (!(dev->flags & DF_ENABLED)) {
		if (bootverbose && device_get_name(dev) != NULL) {
			device_print_prettyname(dev);
			printf("not probed (disabled)\n");
		}
		return (-1);
	}
	if ((error = device_probe_child(dev->parent, dev)) != 0) {
		if (bus_current_pass == BUS_PASS_DEFAULT &&
		    !(dev->flags & DF_DONENOMATCH)) {
			BUS_PROBE_NOMATCH(dev->parent, dev);
			devnomatch(dev);
			dev->flags |= DF_DONENOMATCH;
		}
		return (error);
	}
	return (0);
}
int device_probe ( device_t dev ) { int error ; GIANT_REQUIRED ; if ( dev -> state >= DS_ALIVE && ( dev -> flags & DF_REBID ) == 0 ) return ( -1 ) ; if ( ! ( dev -> flags & DF_ENABLED ) ) { if ( bootverbose && device_get_name ( dev ) != NULL ) { device_print_prettyname ( dev ) ; printf ( " \n " ) ; } return ( -1 ) ; } if ( ( error = device_probe_child ( dev -> parent , dev ) ) != 0 ) { if ( bus_current_pass == BUS_PASS_DEFAULT && ! ( dev -> flags & DF_DONENOMATCH ) ) { BUS_PROBE_NOMATCH ( dev -> parent , dev ) ; devnomatch ( dev ) ; dev -> flags |= DF_DONENOMATCH ; } return ( error ) ; } return ( 0 ) ; }
@brief Probe a device, and return this status.
@brief Probe a device and return this status .