FreeBSD/sys/dev/drm2/drm_hashtab.c
/*
 * Just insert an item and return any "bits" bit key that hasn't been
 * used before.
 */
Just insert an item and return any "bits" bit key that hasn't been
used before.
Just insert an item and return any " bits " bit key that hasn ' t been used before .
int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
			      unsigned long seed, int bits, int shift,
			      unsigned long add)
{
	int ret;
	unsigned long mask = (1 << bits) - 1;
	unsigned long first, unshifted_key = 0;
	unshifted_key = hash32_buf(&seed, sizeof(seed), unshifted_key);
	first = unshifted_key;
	do {
		item->key = (unshifted_key << shift) + add;
		ret = drm_ht_insert_item(ht, item);
		if (ret)
			unshifted_key = (unshifted_key + 1) & mask;
	} while(ret && (unshifted_key != first));
	if (ret) {
		DRM_ERROR("Available key bit space exhausted\n");
		return -EINVAL;
	}
	return 0;
}
int drm_ht_just_insert_please ( struct drm_open_hash * ht , struct drm_hash_item * item , unsigned long seed , int bits , int shift , unsigned long add ) { int ret ; unsigned long mask = ( 1 << bits ) - 1 ; unsigned long first , unshifted_key = 0 ; unshifted_key = hash32_buf ( & seed , sizeof ( seed ) , unshifted_key ) ; first = unshifted_key ; do { item -> key = ( unshifted_key << shift ) + add ; ret = drm_ht_insert_item ( ht , item ) ; if ( ret ) unshifted_key = ( unshifted_key + 1 ) & mask ; } while ( ret && ( unshifted_key != first ) ) ; if ( ret ) { DRM_ERROR ( " \n " ) ; return - EINVAL ; } return 0 ; }
Just insert an item and return any "bits" bit key that hasn't been
 used before.
Just insert an item and return any " bits " bit key that hasn ' t been used before .