FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Set the unit number of a device
 *
 * This function can be used to override the unit number used for a
 * device (e.g. to wire a device to a pre-configured unit number).
 */
@brief Set the unit number of a device
This function can be used to override the unit number used for a
device .
@brief Set the unit number of a device This function can be used to override the unit number used for a device .
int
device_set_unit(device_t dev, int unit)
{
	devclass_t dc;
	int err;
	dc = device_get_devclass(dev);
	if (unit < dc->maxunit && dc->devices[unit])
		return (EBUSY);
	err = devclass_delete_device(dc, dev);
	if (err)
		return (err);
	dev->unit = unit;
	err = devclass_add_device(dc, dev);
	if (err)
		return (err);
	bus_data_generation_update();
	return (0);
}
int device_set_unit ( device_t dev , int unit ) { devclass_t dc ; int err ; dc = device_get_devclass ( dev ) ; if ( unit < dc -> maxunit && dc -> devices [ unit ] ) return ( EBUSY ) ; err = devclass_delete_device ( dc , dev ) ; if ( err ) return ( err ) ; dev -> unit = unit ; err = devclass_add_device ( dc , dev ) ; if ( err ) return ( err ) ; bus_data_generation_update ( ) ; return ( 0 ) ; }
@brief Set the unit number of a device
 This function can be used to override the unit number used for a
 device (e.g.
@brief Set the unit number of a device This function can be used to override the unit number used for a device ( e . g .