aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--Makefile4
-rw-r--r--at76_usb.c40
-rw-r--r--compat.h43
3 files changed, 54 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 665906c..7cb3b48 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,10 @@ SPECFILE = at76_usb.spec
DISTFILES = $(SRCS) Makefile README COPYING CHANGELOG kernel_patch.diff
+ifndef NO_COMPAT_HEADERS
+EXTRA_CFLAGS += -include $(obj)/compat.h
+endif
+
# get the version from at76_usb.h
ifndef M
VERSION = $(shell sed -n 's/^\#define.*DRIVER_VERSION.*"\(.*\)".*$$/\1/p' at76_usb.h)
diff --git a/at76_usb.c b/at76_usb.c
index d6a1e68..5039288 100644
--- a/at76_usb.c
+++ b/at76_usb.c
@@ -5455,13 +5455,9 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
#endif /* IEEE_STANDARD */
}
-#ifdef SKB_WITH_OVERHEAD
skb_set_mac_header(skb, -(int)sizeof(struct ethhdr));
eth_hdr_p = (struct ethhdr *)skb_mac_header(skb);
-#else
- eth_hdr_p = (struct ethhdr *)(skb->data - sizeof(struct ethhdr));
- skb->mac.raw = (unsigned char *)eth_hdr_p;
-#endif
+
if (build_ethhdr) {
/* This needs to be done in this order (eth_hdr_p->h_dest may
* overlap src_addr) */
@@ -5494,14 +5490,6 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
}
-#ifndef SKB_WITH_OVERHEAD
-static inline void skb_reset_mac_header(struct sk_buff *skb)
-{
- skb->mac.raw = skb->data;
-}
-#endif
-
-
/* check for fragmented data in priv->rx_skb. If the packet was no fragment
or it was the last of a fragment set a skb containing the whole packet
is returned for further processing. Otherwise we get NULL and are
@@ -5543,17 +5531,10 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
hex2str(priv->obuf, data,
min((int)(sizeof(priv->obuf) - 1) / 2, 32), '\0'));
-#ifdef SKB_WITH_OVERHEAD
- at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
- "tail %d end %d len %d",
- priv->netdev->name, skb->head, skb->data, skb->tail,
- skb->end, skb->len);
-#else
at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
- "tail %p end %p len %d",
- priv->netdev->name, skb->head, skb->data, skb->tail,
- skb->end, skb->len);
-#endif
+ "tail %p end %p len %d", priv->netdev->name, skb->head,
+ skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
+ skb->len);
if (data_len < 0) {
/* make sure data starts in the buffer */
@@ -5587,17 +5568,10 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
/* remove FCS at end */
skb_trim(skb, length);
-#ifdef SKB_WITH_OVERHEAD
- at76_dbg(DBG_RX_FRAGS_SKB, "%s: trimmed skb: head %p data %p tail %d "
- "end %d len %d data %p data_len %d",
- priv->netdev->name, skb->head, skb->data, skb->tail,
- skb->end, skb->len, data, data_len);
-#else
at76_dbg(DBG_RX_FRAGS_SKB, "%s: trimmed skb: head %p data %p tail %p "
- "end %p len %d data %p data_len %d",
- priv->netdev->name, skb->head, skb->data, skb->tail,
- skb->end, skb->len, data, data_len);
-#endif
+ "end %p len %d data %p data_len %d", priv->netdev->name,
+ skb->head, skb->data, skb_tail_pointer(skb),
+ skb_end_pointer(skb), skb->len, data, data_len);
/* look if we've got a chain for the sender address.
afterwards optr points to first free or the oldest entry,
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