Merge tag 'for-linus-20160523' of git://git.infradead.org/linux-mtd
[linux-2.6-block.git] / include / linux / genetlink.h
CommitLineData
482a8524
TG
1#ifndef __LINUX_GENERIC_NETLINK_H
2#define __LINUX_GENERIC_NETLINK_H
3
607ca46e 4#include <uapi/linux/genetlink.h>
482a8524 5
f408e0ce
JC
6
7/* All generic netlink requests are serialized by a global lock. */
8extern void genl_lock(void);
9extern void genl_unlock(void);
320f5ea0 10#ifdef CONFIG_LOCKDEP
61d03535 11extern bool lockdep_genl_is_held(void);
86b1309c 12#endif
f408e0ce 13
ee1c2442
JB
14/* for synchronisation between af_netlink and genetlink */
15extern atomic_t genl_sk_destructing_cnt;
16extern wait_queue_head_t genl_sk_destructing_waitq;
17
b4e16611
JG
18/**
19 * rcu_dereference_genl - rcu_dereference with debug checking
20 * @p: The pointer to read, prior to dereferencing
21 *
22 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
23 * or genl mutex. Note : Please prefer genl_dereference() or rcu_dereference()
24 */
25#define rcu_dereference_genl(p) \
26 rcu_dereference_check(p, lockdep_genl_is_held())
27
28/**
29 * genl_dereference - fetch RCU pointer when updates are prevented by genl mutex
30 * @p: The pointer to read, prior to dereferencing
31 *
32 * Return the value of the specified RCU-protected pointer, but omit
33 * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
34 * caller holds genl mutex.
35 */
36#define genl_dereference(p) \
37 rcu_dereference_protected(p, lockdep_genl_is_held())
38
e9412c37
NH
39#define MODULE_ALIAS_GENL_FAMILY(family)\
40 MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
41
482a8524 42#endif /* __LINUX_GENERIC_NETLINK_H */