sys/bus/u4b/serial/usb_serial.c
static int
ucom_unit_alloc(void)
{
	int unit;

	lockmgr(&ucom_bitmap_lock, LK_EXCLUSIVE);

	for (unit = 0; unit < UCOM_UNIT_MAX; unit++) {
		if ((ucom_bitmap[unit / 8] & (1 << (unit % 8))) == 0) {
			ucom_bitmap[unit / 8] |= (1 << (unit % 8));
			break;
		}
	}

	lockmgr(&ucom_bitmap_lock, LK_RELEASE);

	if (unit == UCOM_UNIT_MAX)
		return -1;
	else
		return unit;
}
/*
 * Mark a unit number (the X in cuaUX) as in use.
 *
 * Note that devices using a different naming scheme (see ucom_tty_name()
 * callback) still use this unit allocation.
 */
Mark a unit number (the X in cuaUX) as in use.
Note that devices using a different naming scheme
callback) still use this unit allocation.
Mark a unit number ( the X in cuaUX ) as in use . Note that devices using a different naming scheme callback ) still use this unit allocation .
static int
ucom_unit_alloc(void)
{
	int unit;
	lockmgr(&ucom_bitmap_lock, LK_EXCLUSIVE);
	for (unit = 0; unit < UCOM_UNIT_MAX; unit++) {
		if ((ucom_bitmap[unit / 8] & (1 << (unit % 8))) == 0) {
			ucom_bitmap[unit / 8] |= (1 << (unit % 8));
			break;
		}
	}
	lockmgr(&ucom_bitmap_lock, LK_RELEASE);
	if (unit == UCOM_UNIT_MAX)
		return -1;
	else
		return unit;
}
static int ucom_unit_alloc ( void ) { int unit ; lockmgr ( & ucom_bitmap_lock , LK_EXCLUSIVE ) ; for ( unit = 0 ; unit < UCOM_UNIT_MAX ; unit ++ ) { if ( ( ucom_bitmap [ unit / 8 ] & ( 1 << ( unit % 8 ) ) ) == 0 ) { ucom_bitmap [ unit / 8 ] |= ( 1 << ( unit % 8 ) ) ; break ; } } lockmgr ( & ucom_bitmap_lock , LK_RELEASE ) ; if ( unit == UCOM_UNIT_MAX ) return -1 ; else return unit ; }
Mark a unit number (the X in cuaUX) as in use.
Mark a unit number ( the X in cuaUX ) as in use .