diff options
author | Sven Eckelmann <sven@narfation.org> | 2017-12-02 13:51:52 -0500 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2017-12-15 11:29:23 -0500 |
commit | e57acf8e93fb65715af7595066d99d4c0c3f0235 (patch) | |
tree | de305cffed87501d2fe176fcd03c90946c1f9d4d | |
parent | 73844a8c78cc975ac43fec05f7c90417f5f99742 (diff) |
batman-adv: Add kernel-doc to functions in headers
Externally visible functions should be documented with kernel-doc. This
usually refers to non-static functions but also static inline files in
headers are visible in other files and should therefore be documented.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
-rw-r--r-- | net/batman-adv/bitarray.h | 7 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.h | 6 | ||||
-rw-r--r-- | net/batman-adv/hash.h | 11 | ||||
-rw-r--r-- | net/batman-adv/log.h | 35 | ||||
-rw-r--r-- | net/batman-adv/main.h | 82 | ||||
-rw-r--r-- | net/batman-adv/originator.h | 9 |
6 files changed, 131 insertions, 19 deletions
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h index 0508353fa28d..ca9d0753dd6b 100644 --- a/net/batman-adv/bitarray.h +++ b/net/batman-adv/bitarray.h | |||
@@ -47,7 +47,12 @@ static inline bool batadv_test_bit(const unsigned long *seq_bits, | |||
47 | return test_bit(diff, seq_bits) != 0; | 47 | return test_bit(diff, seq_bits) != 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | /* turn corresponding bit on, so we can remember that we got the packet */ | 50 | /** |
51 | * batadv_set_bit() - Turn corresponding bit on, so we can remember that we got | ||
52 | * the packet | ||
53 | * @seq_bits: bitmap of the packet receive window | ||
54 | * @n: relative sequence number of newly received packet | ||
55 | */ | ||
51 | static inline void batadv_set_bit(unsigned long *seq_bits, s32 n) | 56 | static inline void batadv_set_bit(unsigned long *seq_bits, s32 n) |
52 | { | 57 | { |
53 | /* if too old, just drop it */ | 58 | /* if too old, just drop it */ |
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index 1e61aacac539..de5e9a374ece 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h | |||
@@ -130,6 +130,12 @@ static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface) | |||
130 | kref_put(&hard_iface->refcount, batadv_hardif_release); | 130 | kref_put(&hard_iface->refcount, batadv_hardif_release); |
131 | } | 131 | } |
132 | 132 | ||
133 | /** | ||
134 | * batadv_primary_if_get_selected() - Get reference to primary interface | ||
135 | * @bat_priv: the bat priv with all the soft interface information | ||
136 | * | ||
137 | * Return: primary interface (with increased refcnt), otherwise NULL | ||
138 | */ | ||
133 | static inline struct batadv_hard_iface * | 139 | static inline struct batadv_hard_iface * |
134 | batadv_primary_if_get_selected(struct batadv_priv *bat_priv) | 140 | batadv_primary_if_get_selected(struct batadv_priv *bat_priv) |
135 | { | 141 | { |
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h index 65396b126f3b..4ce1b6d3ad5c 100644 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h | |||
@@ -121,8 +121,15 @@ out: | |||
121 | return ret; | 121 | return ret; |
122 | } | 122 | } |
123 | 123 | ||
124 | /* removes data from hash, if found. data could be the structure you use with | 124 | /** |
125 | * just the key filled, we just need the key for comparing. | 125 | * batadv_hash_remove() - Removes data from hash, if found |
126 | * @hash: hash table | ||
127 | * @compare: callback to determine if 2 hash elements are identical | ||
128 | * @choose: callback calculating the hash index | ||
129 | * @data: data passed to the aforementioned callbacks as argument | ||
130 | * | ||
131 | * ata could be the structure you use with just the key filled, we just need | ||
132 | * the key for comparing. | ||
126 | * | 133 | * |
127 | * Return: returns pointer do data on success, so you can remove the used | 134 | * Return: returns pointer do data on success, so you can remove the used |
128 | * structure yourself, or NULL on error | 135 | * structure yourself, or NULL on error |
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h index dd22e17b84b4..35e02b2b9e72 100644 --- a/net/batman-adv/log.h +++ b/net/batman-adv/log.h | |||
@@ -79,7 +79,14 @@ enum batadv_dbg_level { | |||
79 | int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) | 79 | int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) |
80 | __printf(2, 3); | 80 | __printf(2, 3); |
81 | 81 | ||
82 | /* possibly ratelimited debug output */ | 82 | /** |
83 | * _batadv_dbg() - Store debug output with(out) ratelimiting | ||
84 | * @type: type of debug message | ||
85 | * @bat_priv: the bat priv with all the soft interface information | ||
86 | * @ratelimited: whether output should be rate limited | ||
87 | * @fmt: format string | ||
88 | * @arg...: variable arguments | ||
89 | */ | ||
83 | #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ | 90 | #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ |
84 | do { \ | 91 | do { \ |
85 | struct batadv_priv *__batpriv = (bat_priv); \ | 92 | struct batadv_priv *__batpriv = (bat_priv); \ |
@@ -98,11 +105,30 @@ static inline void _batadv_dbg(int type __always_unused, | |||
98 | } | 105 | } |
99 | #endif | 106 | #endif |
100 | 107 | ||
108 | /** | ||
109 | * batadv_dbg() - Store debug output without ratelimiting | ||
110 | * @type: type of debug message | ||
111 | * @bat_priv: the bat priv with all the soft interface information | ||
112 | * @arg...: format string and variable arguments | ||
113 | */ | ||
101 | #define batadv_dbg(type, bat_priv, arg...) \ | 114 | #define batadv_dbg(type, bat_priv, arg...) \ |
102 | _batadv_dbg(type, bat_priv, 0, ## arg) | 115 | _batadv_dbg(type, bat_priv, 0, ## arg) |
116 | |||
117 | /** | ||
118 | * batadv_dbg_ratelimited() - Store debug output with ratelimiting | ||
119 | * @type: type of debug message | ||
120 | * @bat_priv: the bat priv with all the soft interface information | ||
121 | * @arg...: format string and variable arguments | ||
122 | */ | ||
103 | #define batadv_dbg_ratelimited(type, bat_priv, arg...) \ | 123 | #define batadv_dbg_ratelimited(type, bat_priv, arg...) \ |
104 | _batadv_dbg(type, bat_priv, 1, ## arg) | 124 | _batadv_dbg(type, bat_priv, 1, ## arg) |
105 | 125 | ||
126 | /** | ||
127 | * batadv_info() - Store message in debug buffer and print it to kmsg buffer | ||
128 | * @net_dev: the soft interface net device | ||
129 | * @fmt: format string | ||
130 | * @arg...: variable arguments | ||
131 | */ | ||
106 | #define batadv_info(net_dev, fmt, arg...) \ | 132 | #define batadv_info(net_dev, fmt, arg...) \ |
107 | do { \ | 133 | do { \ |
108 | struct net_device *_netdev = (net_dev); \ | 134 | struct net_device *_netdev = (net_dev); \ |
@@ -110,6 +136,13 @@ static inline void _batadv_dbg(int type __always_unused, | |||
110 | batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ | 136 | batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ |
111 | pr_info("%s: " fmt, _netdev->name, ## arg); \ | 137 | pr_info("%s: " fmt, _netdev->name, ## arg); \ |
112 | } while (0) | 138 | } while (0) |
139 | |||
140 | /** | ||
141 | * batadv_err() - Store error in debug buffer and print it to kmsg buffer | ||
142 | * @net_dev: the soft interface net device | ||
143 | * @fmt: format string | ||
144 | * @arg...: variable arguments | ||
145 | */ | ||
113 | #define batadv_err(net_dev, fmt, arg...) \ | 146 | #define batadv_err(net_dev, fmt, arg...) \ |
114 | do { \ | 147 | do { \ |
115 | struct net_device *_netdev = (net_dev); \ | 148 | struct net_device *_netdev = (net_dev); \ |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 633e6e41ba14..5ac86df48c42 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -298,40 +298,96 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, | |||
298 | return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); | 298 | return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); |
299 | } | 299 | } |
300 | 300 | ||
301 | /** | ||
302 | * batadv_atomic_dec_not_zero() - Decrease unless the number is 0 | ||
303 | * @v: pointer of type atomic_t | ||
304 | * | ||
305 | * Return: non-zero if v was not 0, and zero otherwise. | ||
306 | */ | ||
301 | #define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) | 307 | #define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) |
302 | 308 | ||
303 | /* Returns the smallest signed integer in two's complement with the sizeof x */ | 309 | /** |
310 | * batadv_smallest_signed_int() - Returns the smallest signed integer in two's | ||
311 | * complement with the sizeof x | ||
312 | * @x: type of integer | ||
313 | * | ||
314 | * Return: smallest signed integer of type | ||
315 | */ | ||
304 | #define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) | 316 | #define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) |
305 | 317 | ||
306 | /* Checks if a sequence number x is a predecessor/successor of y. | 318 | /** |
307 | * they handle overflows/underflows and can correctly check for a | 319 | * batadv_seq_before() - Checks if a sequence number x is a predecessor of y |
308 | * predecessor/successor unless the variable sequence number has grown by | 320 | * @x: potential predecessor of @y |
309 | * more then 2**(bitwidth(x)-1)-1. | 321 | * @y: value to compare @x against |
322 | * | ||
323 | * It handles overflows/underflows and can correctly check for a predecessor | ||
324 | * unless the variable sequence number has grown by more then | ||
325 | * 2**(bitwidth(x)-1)-1. | ||
326 | * | ||
310 | * This means that for a u8 with the maximum value 255, it would think: | 327 | * This means that for a u8 with the maximum value 255, it would think: |
311 | * - when adding nothing - it is neither a predecessor nor a successor | 328 | * |
312 | * - before adding more than 127 to the starting value - it is a predecessor, | 329 | * * when adding nothing - it is neither a predecessor nor a successor |
313 | * - when adding 128 - it is neither a predecessor nor a successor, | 330 | * * before adding more than 127 to the starting value - it is a predecessor, |
314 | * - after adding more than 127 to the starting value - it is a successor | 331 | * * when adding 128 - it is neither a predecessor nor a successor, |
332 | * * after adding more than 127 to the starting value - it is a successor | ||
333 | * | ||
334 | * Return: true when x is a predecessor of y, false otherwise | ||
315 | */ | 335 | */ |
316 | #define batadv_seq_before(x, y) ({typeof(x)_d1 = (x); \ | 336 | #define batadv_seq_before(x, y) ({typeof(x)_d1 = (x); \ |
317 | typeof(y)_d2 = (y); \ | 337 | typeof(y)_d2 = (y); \ |
318 | typeof(x)_dummy = (_d1 - _d2); \ | 338 | typeof(x)_dummy = (_d1 - _d2); \ |
319 | (void)(&_d1 == &_d2); \ | 339 | (void)(&_d1 == &_d2); \ |
320 | _dummy > batadv_smallest_signed_int(_dummy); }) | 340 | _dummy > batadv_smallest_signed_int(_dummy); }) |
341 | |||
342 | /** | ||
343 | * batadv_seq_after() - Checks if a sequence number x is a successor of y | ||
344 | * @x: potential sucessor of @y | ||
345 | * @y: value to compare @x against | ||
346 | * | ||
347 | * It handles overflows/underflows and can correctly check for a successor | ||
348 | * unless the variable sequence number has grown by more then | ||
349 | * 2**(bitwidth(x)-1)-1. | ||
350 | * | ||
351 | * This means that for a u8 with the maximum value 255, it would think: | ||
352 | * | ||
353 | * * when adding nothing - it is neither a predecessor nor a successor | ||
354 | * * before adding more than 127 to the starting value - it is a predecessor, | ||
355 | * * when adding 128 - it is neither a predecessor nor a successor, | ||
356 | * * after adding more than 127 to the starting value - it is a successor | ||
357 | * | ||
358 | * Return: true when x is a successor of y, false otherwise | ||
359 | */ | ||
321 | #define batadv_seq_after(x, y) batadv_seq_before(y, x) | 360 | #define batadv_seq_after(x, y) batadv_seq_before(y, x) |
322 | 361 | ||
323 | /* Stop preemption on local cpu while incrementing the counter */ | 362 | /** |
363 | * batadv_add_counter() - Add to per cpu statistics counter of soft interface | ||
364 | * @bat_priv: the bat priv with all the soft interface information | ||
365 | * @idx: counter index which should be modified | ||
366 | * @count: value to increase counter by | ||
367 | * | ||
368 | * Stop preemption on local cpu while incrementing the counter | ||
369 | */ | ||
324 | static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx, | 370 | static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx, |
325 | size_t count) | 371 | size_t count) |
326 | { | 372 | { |
327 | this_cpu_add(bat_priv->bat_counters[idx], count); | 373 | this_cpu_add(bat_priv->bat_counters[idx], count); |
328 | } | 374 | } |
329 | 375 | ||
376 | /** | ||
377 | * batadv_inc_counter() - Increase per cpu statistics counter of soft interface | ||
378 | * @b: the bat priv with all the soft interface information | ||
379 | * @i: counter index which should be modified | ||
380 | */ | ||
330 | #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1) | 381 | #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1) |
331 | 382 | ||
332 | /* Define a macro to reach the control buffer of the skb. The members of the | 383 | /** |
333 | * control buffer are defined in struct batadv_skb_cb in types.h. | 384 | * BATADV_SKB_CB() - Get batadv_skb_cb from skb control buffer |
334 | * The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h. | 385 | * @__skb: skb holding the control buffer |
386 | * | ||
387 | * The members of the control buffer are defined in struct batadv_skb_cb in | ||
388 | * types.h. The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h. | ||
389 | * | ||
390 | * Return: pointer to the batadv_skb_cb of the skb | ||
335 | */ | 391 | */ |
336 | #define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0])) | 392 | #define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0])) |
337 | 393 | ||
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h index b5d2164532c9..8e543a3cdc6c 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h | |||
@@ -84,8 +84,13 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, | |||
84 | unsigned short vid); | 84 | unsigned short vid); |
85 | void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan); | 85 | void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan); |
86 | 86 | ||
87 | /* hashfunction to choose an entry in a hash table of given size | 87 | /** |
88 | * hash algorithm from http://en.wikipedia.org/wiki/Hash_table | 88 | * batadv_choose_orig() - Return the index of the orig entry in the hash table |
89 | * @data: mac address of the originator node | ||
90 | * @size: the size of the hash table | ||
91 | * | ||
92 | * Return: the hash index where the object represented by @data should be | ||
93 | * stored at. | ||
89 | */ | 94 | */ |
90 | static inline u32 batadv_choose_orig(const void *data, u32 size) | 95 | static inline u32 batadv_choose_orig(const void *data, u32 size) |
91 | { | 96 | { |