aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/hash.h
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-05 16:31:28 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-07-01 16:47:20 -0400
commit5bf74e9ca1e618afe5a513f64ee4923115e67004 (patch)
tree6534af43c249344deaf881006b27240fb77ee4c2 /net/batman-adv/hash.h
parent7f223c0c323a9ac2e88714669994007776e966a8 (diff)
batman-adv: Prefix hash struct and typedef with batadv_
Reported-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/hash.h')
-rw-r--r--net/batman-adv/hash.h33
1 files changed, 18 insertions, 15 deletions
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 7ec4e5b0bd41..83990e318e43 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -25,37 +25,39 @@
25/* callback to a compare function. should compare 2 element datas for their 25/* callback to a compare function. should compare 2 element datas for their
26 * keys, return 0 if same and not 0 if not same 26 * keys, return 0 if same and not 0 if not same
27 */ 27 */
28typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); 28typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,
29 const void *);
29 30
30/* the hashfunction, should return an index 31/* the hashfunction, should return an index
31 * based on the key in the data of the first 32 * based on the key in the data of the first
32 * argument and the size the second 33 * argument and the size the second
33 */ 34 */
34typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); 35typedef uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t);
35typedef void (*hashdata_free_cb)(struct hlist_node *, void *); 36typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
36 37
37struct hashtable_t { 38struct batadv_hashtable {
38 struct hlist_head *table; /* the hashtable itself with the buckets */ 39 struct hlist_head *table; /* the hashtable itself with the buckets */
39 spinlock_t *list_locks; /* spinlock for each hash list entry */ 40 spinlock_t *list_locks; /* spinlock for each hash list entry */
40 uint32_t size; /* size of hashtable */ 41 uint32_t size; /* size of hashtable */
41}; 42};
42 43
43/* allocates and clears the hash */ 44/* allocates and clears the hash */
44struct hashtable_t *batadv_hash_new(uint32_t size); 45struct batadv_hashtable *batadv_hash_new(uint32_t size);
45 46
46/* set class key for all locks */ 47/* set class key for all locks */
47void batadv_hash_set_lock_class(struct hashtable_t *hash, 48void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
48 struct lock_class_key *key); 49 struct lock_class_key *key);
49 50
50/* free only the hashtable and the hash itself. */ 51/* free only the hashtable and the hash itself. */
51void batadv_hash_destroy(struct hashtable_t *hash); 52void batadv_hash_destroy(struct batadv_hashtable *hash);
52 53
53/* remove the hash structure. if hashdata_free_cb != NULL, this function will be 54/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
54 * called to remove the elements inside of the hash. if you don't remove the 55 * called to remove the elements inside of the hash. if you don't remove the
55 * elements, memory might be leaked. 56 * elements, memory might be leaked.
56 */ 57 */
57static inline void batadv_hash_delete(struct hashtable_t *hash, 58static inline void batadv_hash_delete(struct batadv_hashtable *hash,
58 hashdata_free_cb free_cb, void *arg) 59 batadv_hashdata_free_cb free_cb,
60 void *arg)
59{ 61{
60 struct hlist_head *head; 62 struct hlist_head *head;
61 struct hlist_node *node, *node_tmp; 63 struct hlist_node *node, *node_tmp;
@@ -89,9 +91,9 @@ static inline void batadv_hash_delete(struct hashtable_t *hash,
89 * Returns 0 on success, 1 if the element already is in the hash 91 * Returns 0 on success, 1 if the element already is in the hash
90 * and -1 on error. 92 * and -1 on error.
91 */ 93 */
92static inline int batadv_hash_add(struct hashtable_t *hash, 94static inline int batadv_hash_add(struct batadv_hashtable *hash,
93 hashdata_compare_cb compare, 95 batadv_hashdata_compare_cb compare,
94 hashdata_choose_cb choose, 96 batadv_hashdata_choose_cb choose,
95 const void *data, 97 const void *data,
96 struct hlist_node *data_node) 98 struct hlist_node *data_node)
97{ 99{
@@ -134,9 +136,10 @@ out:
134 * structure you use with just the key filled, we just need the key for 136 * structure you use with just the key filled, we just need the key for
135 * comparing. 137 * comparing.
136 */ 138 */
137static inline void *batadv_hash_remove(struct hashtable_t *hash, 139static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
138 hashdata_compare_cb compare, 140 batadv_hashdata_compare_cb compare,
139 hashdata_choose_cb choose, void *data) 141 batadv_hashdata_choose_cb choose,
142 void *data)
140{ 143{
141 uint32_t index; 144 uint32_t index;
142 struct hlist_node *node; 145 struct hlist_node *node;