Lines Matching refs:space
363 int devfs_alloc_unique_number (struct unique_numspace *space) in devfs_alloc_unique_number() argument
369 spin_lock (&space->init_lock); in devfs_alloc_unique_number()
370 if (!space->sem_initialised) in devfs_alloc_unique_number()
372 sema_init (&space->semaphore, 1); in devfs_alloc_unique_number()
373 space->sem_initialised = 1; in devfs_alloc_unique_number()
375 spin_unlock (&space->init_lock); in devfs_alloc_unique_number()
376 down (&space->semaphore); in devfs_alloc_unique_number()
377 if (space->num_free < 1) in devfs_alloc_unique_number()
381 if (space->length < 16) length = 16; in devfs_alloc_unique_number()
382 else length = space->length << 1; in devfs_alloc_unique_number()
385 up (&space->semaphore); in devfs_alloc_unique_number()
388 if (space->bits != NULL) in devfs_alloc_unique_number()
390 memcpy (bits, space->bits, space->length); in devfs_alloc_unique_number()
391 vfree (space->bits); in devfs_alloc_unique_number()
393 space->num_free = (length - space->length) << 3; in devfs_alloc_unique_number()
394 space->bits = bits; in devfs_alloc_unique_number()
395 memset (bits + space->length, 0, length - space->length); in devfs_alloc_unique_number()
396 space->length = length; in devfs_alloc_unique_number()
398 number = find_first_zero_bit (space->bits, space->length << 3); in devfs_alloc_unique_number()
399 --space->num_free; in devfs_alloc_unique_number()
400 __set_bit (number, space->bits); in devfs_alloc_unique_number()
401 up (&space->semaphore); in devfs_alloc_unique_number()
415 void devfs_dealloc_unique_number (struct unique_numspace *space, int number) in devfs_dealloc_unique_number() argument
420 down (&space->semaphore); in devfs_dealloc_unique_number()
421 was_set = __test_and_clear_bit (number, space->bits); in devfs_dealloc_unique_number()
422 if (was_set) ++space->num_free; in devfs_dealloc_unique_number()
423 up (&space->semaphore); in devfs_dealloc_unique_number()