aboutsummaryrefslogtreecommitdiff
path: root/compat.h
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2007-06-13 03:59:00 -0400
committerGuido Guenther <agx@sigxcpu.org>2007-06-14 10:11:06 +0200
commit9bf21d180fd9b1f969f7706c319be5bb50d1b5ee (patch)
treecfe9166ef019b05236d6942e48ff029b6a2ae781 /compat.h
parent97fc68cb5d0a036fb12f3c940e929a73d69937a0 (diff)
[PATCH] Provide compatibility for older kernels in a separate file
Remove all Linux 2.6.21 compatibility from the driver - it shouldn't be there for kernel submission. Move all compatibility code to a separate file compat.h. Include it forcedly with the "-include" option. Add a makefile option to disable config.h inclusion. Provide compatibility as far back as Linux 2.6.19 - it's not really hard once the infrastructure is in place. Signed-off-by: Pavel Roskin <proski@gnu.org>
Diffstat (limited to 'compat.h')
-rw-r--r--compat.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/compat.h b/compat.h
new file mode 100644
index 0000000..32a66c7
--- /dev/null
+++ b/compat.h
@@ -0,0 +1,43 @@
+/* Compatibility layer for older kernels */
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#include <linux/skbuff.h>
+static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
+{
+ return skb->mac.raw;
+}
+
+static inline void skb_reset_mac_header(struct sk_buff *skb)
+{
+ skb->mac.raw = skb->data;
+}
+
+static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
+{
+ skb->mac.raw = skb->data + offset;
+}
+
+static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
+{
+ return skb->end;
+}
+
+static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
+{
+ return skb->tail;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#undef INIT_WORK
+#define INIT_WORK(_work, _func) \
+ do { \
+ INIT_LIST_HEAD(&(_work)->entry); \
+ (_work)->pending = 0; \
+ PREPARE_WORK((_work), (void (*)(void *))(_func), \
+ (void *)(_work)); \
+ init_timer(&(_work)->timer); \
+ } while (0)
+#endif