]> git.openfabrics.org - ~emulex/for-vlad/old/compat.git/blob - include/linux/compat-2.6.34.h
d189bee7d0c5838b184b894b46f078d2569099da
[~emulex/for-vlad/old/compat.git] / include / linux / compat-2.6.34.h
1 #ifndef LINUX_26_34_COMPAT_H
2 #define LINUX_26_34_COMPAT_H
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34))
7
8 #include <linux/netdevice.h>
9
10 #define netdev_mc_count(dev) ((dev)->mc_count)
11 #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0)
12
13 #define netdev_for_each_mc_addr(mclist, dev) \
14         for (mclist = dev->mc_list; mclist; mclist = mclist->next)
15 /* source: include/linux/netdevice.h */
16
17
18 /* Logging, debugging and troubleshooting/diagnostic helpers. */
19
20 /* netdev_printk helpers, similar to dev_printk */
21
22 static inline const char *netdev_name(const struct net_device *dev)
23 {
24         if (dev->reg_state != NETREG_REGISTERED)
25                 return "(unregistered net_device)";
26         return dev->name;
27 }
28
29 #define netdev_printk(level, netdev, format, args...)           \
30         dev_printk(level, (netdev)->dev.parent,                 \
31                    "%s: " format,                               \
32                    netdev_name(netdev), ##args)
33
34 #define netdev_emerg(dev, format, args...)                      \
35         netdev_printk(KERN_EMERG, dev, format, ##args)
36 #define netdev_alert(dev, format, args...)                      \
37         netdev_printk(KERN_ALERT, dev, format, ##args)
38 #define netdev_crit(dev, format, args...)                       \
39         netdev_printk(KERN_CRIT, dev, format, ##args)
40 #define netdev_err(dev, format, args...)                        \
41         netdev_printk(KERN_ERR, dev, format, ##args)
42 #define netdev_warn(dev, format, args...)                       \
43         netdev_printk(KERN_WARNING, dev, format, ##args)
44 #define netdev_notice(dev, format, args...)                     \
45         netdev_printk(KERN_NOTICE, dev, format, ##args)
46 #define netdev_info(dev, format, args...)                       \
47         netdev_printk(KERN_INFO, dev, format, ##args)
48
49 #if defined(DEBUG)
50 #define netdev_dbg(__dev, format, args...)                      \
51         netdev_printk(KERN_DEBUG, __dev, format, ##args)
52 #elif defined(CONFIG_DYNAMIC_DEBUG)
53 #define netdev_dbg(__dev, format, args...)                      \
54 do {                                                            \
55         dynamic_dev_dbg((__dev)->dev.parent, "%s: " format,     \
56                         netdev_name(__dev), ##args);            \
57 } while (0)
58 #else
59 #define netdev_dbg(__dev, format, args...)                      \
60 ({                                                              \
61         if (0)                                                  \
62                 netdev_printk(KERN_DEBUG, __dev, format, ##args); \
63         0;                                                      \
64 })
65 #endif
66
67 #if defined(VERBOSE_DEBUG)
68 #define netdev_vdbg     netdev_dbg
69 #else
70
71 #define netdev_vdbg(dev, format, args...)                       \
72 ({                                                              \
73         if (0)                                                  \
74                 netdev_printk(KERN_DEBUG, dev, format, ##args); \
75         0;                                                      \
76 })
77 #endif
78
79 /*
80  * netdev_WARN() acts like dev_printk(), but with the key difference
81  * of using a WARN/WARN_ON to get the message out, including the
82  * file/line information and a backtrace.
83  */
84 #define netdev_WARN(dev, format, args...)                       \
85         WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
86
87 /* netif printk helpers, similar to netdev_printk */
88
89 #define netif_printk(priv, type, level, dev, fmt, args...)      \
90 do {                                                            \
91         if (netif_msg_##type(priv))                             \
92                 netdev_printk(level, (dev), fmt, ##args);       \
93 } while (0)
94
95 #define netif_emerg(priv, type, dev, fmt, args...)              \
96         netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
97 #define netif_alert(priv, type, dev, fmt, args...)              \
98         netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
99 #define netif_crit(priv, type, dev, fmt, args...)               \
100         netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
101 #define netif_err(priv, type, dev, fmt, args...)                \
102         netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
103 #define netif_warn(priv, type, dev, fmt, args...)               \
104         netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
105 #define netif_notice(priv, type, dev, fmt, args...)             \
106         netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
107 #define netif_info(priv, type, dev, fmt, args...)               \
108         netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
109
110 #if defined(DEBUG)
111 #define netif_dbg(priv, type, dev, format, args...)             \
112         netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
113 #elif defined(CONFIG_DYNAMIC_DEBUG)
114 #define netif_dbg(priv, type, netdev, format, args...)          \
115 do {                                                            \
116         if (netif_msg_##type(priv))                             \
117                 dynamic_dev_dbg((netdev)->dev.parent,           \
118                                 "%s: " format,                  \
119                                 netdev_name(netdev), ##args);   \
120 } while (0)
121 #else
122 #define netif_dbg(priv, type, dev, format, args...)                     \
123 ({                                                                      \
124         if (0)                                                          \
125                 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
126         0;                                                              \
127 })
128 #endif
129
130 #if defined(VERBOSE_DEBUG)
131 #define netif_vdbg      netdev_dbg
132 #else
133 #define netif_vdbg(priv, type, dev, format, args...)            \
134 ({                                                              \
135         if (0)                                                  \
136                 netif_printk(KERN_DEBUG, dev, format, ##args);  \
137         0;                                                      \
138 })
139 #endif
140 /* source: include/linux/netdevice.h */
141
142
143 static inline void device_lock(struct device *dev)
144 {
145         down(&dev->sem);
146 }
147
148 static inline int device_trylock(struct device *dev)
149 {
150         return down_trylock(&dev->sem);
151 }
152
153 static inline void device_unlock(struct device *dev)
154 {
155         up(&dev->sem);
156 }
157
158 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */
159
160 #endif /* LINUX_26_34_COMPAT_H */