Lines Matching full:hash
19 #include "hash.h"
26 /* clears the hash */
27 static void batadv_hash_init(struct batadv_hashtable *hash) in batadv_hash_init() argument
31 for (i = 0; i < hash->size; i++) { in batadv_hash_init()
32 INIT_HLIST_HEAD(&hash->table[i]); in batadv_hash_init()
33 spin_lock_init(&hash->list_locks[i]); in batadv_hash_init()
38 * batadv_hash_destroy() - Free only the hashtable and the hash itself
39 * @hash: hash object to destroy
41 void batadv_hash_destroy(struct batadv_hashtable *hash) in batadv_hash_destroy() argument
43 kfree(hash->list_locks); in batadv_hash_destroy()
44 kfree(hash->table); in batadv_hash_destroy()
45 kfree(hash); in batadv_hash_destroy()
50 * @size: number of hash buckets to allocate
56 struct batadv_hashtable *hash; in batadv_hash_new() local
58 hash = kmalloc(sizeof(*hash), GFP_ATOMIC); in batadv_hash_new()
59 if (!hash) in batadv_hash_new()
62 hash->table = kmalloc_array(size, sizeof(*hash->table), GFP_ATOMIC); in batadv_hash_new()
63 if (!hash->table) in batadv_hash_new()
66 hash->list_locks = kmalloc_array(size, sizeof(*hash->list_locks), in batadv_hash_new()
68 if (!hash->list_locks) in batadv_hash_new()
71 hash->size = size; in batadv_hash_new()
72 batadv_hash_init(hash); in batadv_hash_new()
73 return hash; in batadv_hash_new()
76 kfree(hash->table); in batadv_hash_new()
78 kfree(hash); in batadv_hash_new()
83 * batadv_hash_set_lock_class() - Set specific lockdep class for hash spinlocks
84 * @hash: hash object to modify
87 void batadv_hash_set_lock_class(struct batadv_hashtable *hash, in batadv_hash_set_lock_class() argument
92 for (i = 0; i < hash->size; i++) in batadv_hash_set_lock_class()
93 lockdep_set_class(&hash->list_locks[i], key); in batadv_hash_set_lock_class()