compat: backport netdev_refcnt_read.
[~tnikolova/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 /**
16  * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
17  * @skb: skb to check
18  *
19  * fresh skbs have their ip_summed set to CHECKSUM_NONE.
20  * Instead of forcing ip_summed to CHECKSUM_NONE, we can
21  * use this helper, to document places where we make this assertion.
22  */
23 static inline void skb_checksum_none_assert(struct sk_buff *skb)
24 {
25 #ifdef DEBUG
26         BUG_ON(skb->ip_summed != CHECKSUM_NONE);
27 #endif
28 }
29
30 #define pcmcia_enable_device(link)      pcmcia_request_configuration(link, &link->conf)
31
32 #include <net/genetlink.h>
33
34 struct compat_genl_info {
35         struct genl_info *info;
36
37         u32 snd_seq;
38         u32 snd_pid;
39         struct genlmsghdr *genlhdr;
40         struct nlattr **attrs;
41         void *user_ptr[2];
42 };
43 #define genl_info compat_genl_info
44
45 struct compat_genl_ops {
46         struct genl_ops ops;
47
48         u8 cmd;
49         u8 internal_flags;
50         unsigned int flags;
51         const struct nla_policy *policy;
52
53         int (*doit)(struct sk_buff *skb, struct genl_info *info);
54         int (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb);
55         int (*done)(struct netlink_callback *cb);
56 };
57 #define genl_ops compat_genl_ops
58
59 struct compat_genl_family {
60         struct genl_family family;
61
62         struct list_head list;
63
64         unsigned int id, hdrsize, version, maxattr;
65         const char *name;
66         bool netnsok;
67
68         struct nlattr **attrbuf;
69
70         int (*pre_doit)(struct genl_ops *ops, struct sk_buff *skb,
71                         struct genl_info *info);
72
73         void (*post_doit)(struct genl_ops *ops, struct sk_buff *skb,
74                           struct genl_info *info);
75 };
76
77 #define genl_family compat_genl_family
78
79 #define genl_register_family_with_ops compat_genl_register_family_with_ops
80
81 int genl_register_family_with_ops(struct genl_family *family,
82                                   struct genl_ops *ops, size_t n_ops);
83
84 #define genl_unregister_family compat_genl_unregister_family
85
86 int genl_unregister_family(struct genl_family *family);
87
88 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
89 #define genl_info_net(_info) genl_info_net((_info)->info)
90 #endif
91
92 #define genlmsg_reply(_msg, _info) genlmsg_reply(_msg, (_info)->info)
93 #define genlmsg_put(_skb, _pid, _seq, _fam, _flags, _cmd) genlmsg_put(_skb, _pid, _seq, &(_fam)->family, _flags, _cmd)
94 #define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp)
95 #define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp)
96
97
98 extern void led_blink_set(struct led_classdev *led_cdev,
99                           unsigned long *delay_on,
100                           unsigned long *delay_off);
101
102 #define led_classdev_unregister compat_led_classdev_unregister
103 extern void compat_led_classdev_unregister(struct led_classdev *led_cdev);
104
105 #define led_brightness_set compat_led_brightness_set
106 extern void compat_led_brightness_set(struct led_classdev *led_cdev,
107                                       enum led_brightness brightness);
108
109 #define alloc_ordered_workqueue(name, flags) create_singlethread_workqueue(name)
110
111 #define netdev_refcnt_read(a) atomic_read(&a->refcnt)
112
113 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
114
115 #endif /* LINUX_26_37_COMPAT_H */