compat: support RHEL6 as a build target
[~emulex/for-vlad/old/compat.git] / include / linux / compat-2.6.37.h
1 #ifndef LINUX_26_37_COMPAT_H
2 #define LINUX_26_37_COMPAT_H
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
7
8 #include <linux/skbuff.h>
9 #include <linux/leds.h>
10
11 #define SDIO_CLASS_BT_AMP       0x09    /* Type-A Bluetooth AMP interface */
12
13 extern struct kobj_ns_type_operations net_ns_type_operations;
14
15 /* mask skb_checksum_none_assert as RHEL6 backports this */
16 #define skb_checksum_none_assert(a) compat_skb_checksum_none_assert(a)
17
18 /**
19  * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
20  * @skb: skb to check
21  *
22  * fresh skbs have their ip_summed set to CHECKSUM_NONE.
23  * Instead of forcing ip_summed to CHECKSUM_NONE, we can
24  * use this helper, to document places where we make this assertion.
25  */
26 static inline void skb_checksum_none_assert(struct sk_buff *skb)
27 {
28 #ifdef DEBUG
29         BUG_ON(skb->ip_summed != CHECKSUM_NONE);
30 #endif
31 }
32
33 #define pcmcia_enable_device(link)      pcmcia_request_configuration(link, &link->conf)
34
35 #include <net/genetlink.h>
36
37 struct compat_genl_info {
38         struct genl_info *info;
39
40         u32 snd_seq;
41         u32 snd_pid;
42         struct genlmsghdr *genlhdr;
43         struct nlattr **attrs;
44         void *user_ptr[2];
45 };
46 #define genl_info compat_genl_info
47
48 struct compat_genl_ops {
49         struct genl_ops ops;
50
51         u8 cmd;
52         u8 internal_flags;
53         unsigned int flags;
54         const struct nla_policy *policy;
55
56         int (*doit)(struct sk_buff *skb, struct genl_info *info);
57         int (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb);
58         int (*done)(struct netlink_callback *cb);
59 };
60 #define genl_ops compat_genl_ops
61
62 struct compat_genl_family {
63         struct genl_family family;
64
65         struct list_head list;
66
67         unsigned int id, hdrsize, version, maxattr;
68         const char *name;
69         bool netnsok;
70
71         struct nlattr **attrbuf;
72
73         int (*pre_doit)(struct genl_ops *ops, struct sk_buff *skb,
74                         struct genl_info *info);
75
76         void (*post_doit)(struct genl_ops *ops, struct sk_buff *skb,
77                           struct genl_info *info);
78 };
79
80 #define genl_family compat_genl_family
81
82 #define genl_register_family_with_ops compat_genl_register_family_with_ops
83
84 int genl_register_family_with_ops(struct genl_family *family,
85                                   struct genl_ops *ops, size_t n_ops);
86
87 #define genl_unregister_family compat_genl_unregister_family
88
89 int genl_unregister_family(struct genl_family *family);
90
91 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
92 #define genl_info_net(_info) genl_info_net((_info)->info)
93 #endif
94
95 #define genlmsg_reply(_msg, _info) genlmsg_reply(_msg, (_info)->info)
96 #define genlmsg_put(_skb, _pid, _seq, _fam, _flags, _cmd) genlmsg_put(_skb, _pid, _seq, &(_fam)->family, _flags, _cmd)
97 #define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp)
98 #define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp)
99
100
101 extern void led_blink_set(struct led_classdev *led_cdev,
102                           unsigned long *delay_on,
103                           unsigned long *delay_off);
104
105 #define led_classdev_unregister compat_led_classdev_unregister
106 extern void compat_led_classdev_unregister(struct led_classdev *led_cdev);
107
108 #define led_brightness_set compat_led_brightness_set
109 extern void compat_led_brightness_set(struct led_classdev *led_cdev,
110                                       enum led_brightness brightness);
111
112 #define alloc_ordered_workqueue(name, flags) create_singlethread_workqueue(name)
113
114 #define netdev_refcnt_read(a) atomic_read(&a->refcnt)
115
116 /* mask vzalloc as RHEL6 backports this */
117 #define vzalloc(a) compat_vzalloc(a)
118
119 extern void *vzalloc(unsigned long size);
120
121 #define rtnl_dereference(p)                                     \
122         rcu_dereference_protected(p, lockdep_rtnl_is_held())
123
124 /**
125  * RCU_INIT_POINTER() - initialize an RCU protected pointer
126  *
127  * Initialize an RCU-protected pointer in such a way to avoid RCU-lockdep
128  * splats.
129  */
130 #define RCU_INIT_POINTER(p, v) \
131                 p = (typeof(*v) __force __rcu *)(v)
132
133 static inline bool skb_has_frag_list(const struct sk_buff *skb)
134 {
135         return skb_shinfo(skb)->frag_list != NULL;
136 }
137
138 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
139
140 #endif /* LINUX_26_37_COMPAT_H */