Skip to contentSkip to conversation

Compat

PATCH In review Arnaud Lacombe 3 participants 62 messages Nov 10, 2010 – Nov 23, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Compat

Hi Luis,

You will find in answer of this mail the first part of the compat upgrade I am using to support a network-oriented module on kernel from 2.6.15 to 2.6.36.

All this code is available on my repository on github:

https://github.com/lacombar/linux-compat.git local

This repository also contains the second part I will post later concerning a tentative to reduce namespace pollution when using the compat module. As it is mostly mechanical, I will start another thread with a single proof of concept patch and gather feedbacks :)

Comments welcome !

Thanks,
- Arnaud

Arnaud Lacombe (44):
compat/2.6.17: add header's skeleton
compat/2.6.17: add compat macro for NET_SKB_PAD' compat/2.6.18: add compat skeleton for the hwrng' API compat/2.6.18: add compat inline for netdev_alloc_skb() compat/2.6.19: fix comment
compat/2.6.19: add typedef for bool' and true'/`false' compat/2.6.19: rework compat macro to kmem_cache_destroy() compat/2.6.20: add header's skeleton
compat/2.6.20: add compat macro for `struct delayed_work' compat/2.6.23: add compat inline for notifier_{from,to}_errno() compat/2.6.24: add compat macro for sk_alloc() compat/2.6.25: don't include <linux/hw_random.h> prior to 2.6.18 compat/2.6.25: don't include <linux/{io,leds}.h> prior to 2.6.17 compat/2.6.25: conditionally defines `__WARN' compat/2.6.25: add compat macro for ip_route_output_key() compat/2.6.29: don't include <linux/if_link.h> prior to 2.6.19 compat/2.6.29: const'ify compat inline to dev_get_stats() compat/2.6.31: gather all the threaded IRQ backport together compat/2.6.31: fix threaded irq backport wrt. INIT_WORK() macro compat/2.6.32: fix compat inline to flush_delayed_work() compat/2.6.32: add compat macros for sysctl helpers compat/2.6.33: add compat macro to BUILD_BUG_ON_NOT_POWER_OF_2() compat/2.6.33: fix pcmcia include
compat/2.6.33: don't export prototype for pccard_loop_tuple() compat/2.6.36: `va_list' needs <stdarg.h>
compat: remove a couple of macro definition protection compat/2.6.33: remove macro not in mainline
compat: avoid using #include_next' directive in compat headers compat/2.6.22: rework uninitialized_var' and `__maybe_unused' macros compat/2.6.22: nuke pci_{clear,set}_mwi()
compat/2.6.22: add compat for couple of TCP accessors compat/2.6.22: add compat inline for ip_hdrlen() compat/2.6.22: constify skb_transport_header()'s argument compat/2.6.24: move 'struct net' to its own compat header compat/2.6.26: {U,}SHORT_MAX/SHORT_MIN have been deprecated compat/2.6.26: move unaligned backport to its own header compat/2.6.2{7,8}: fix definition for IEEE80211_HT_CAP_DSSSCCK40 compat/2.6.2{8,9}: fix tracepoint macros
compat/2.6.29: protect headers inclusion
compat/2.6.29: don't waste space around DIV_ROUND_CLOSEST() compat/2.6.29: fix typos
compat/2.6.{21,30}: make dev_set_uevent_suppress() a no-op for

    <2.6.21

compat/2.6.{19,31}: fix threaded irq backport for <2.6.19 compat/2.6.35: 2.6.35 does not define `SHRT_MIN'

 include/linux/asm/unaligned.h |  194 ++++++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.17.h |   13 +++
 include/linux/compat-2.6.18.h |   45 +++++++++
 include/linux/compat-2.6.19.h |   23 ++---
 include/linux/compat-2.6.20.h |   14 +++
 include/linux/compat-2.6.22.h |   41 ++++++--
 include/linux/compat-2.6.23.h |   18 +++-
 include/linux/compat-2.6.24.h |   34 +------
 include/linux/compat-2.6.25.h |   10 ++-
 include/linux/compat-2.6.26.h |  219 +----------------------------------------
 include/linux/compat-2.6.27.h |    3 -
 include/linux/compat-2.6.28.h |   27 +-----
 include/linux/compat-2.6.29.h |   40 ++++++--
 include/linux/compat-2.6.30.h |    2 +
 include/linux/compat-2.6.31.h |   54 ++++++++---
 include/linux/compat-2.6.32.h |   31 ++++++-
 include/linux/compat-2.6.33.h |   12 +--
 include/linux/compat-2.6.35.h |    1 -
 include/linux/compat-2.6.36.h |    1 +
 include/linux/pm_qos_params.h |    7 +-
 include/linux/tracepoint.h    |   14 ++--
 include/net/net_namespace.h   |   50 ++++++++--
 include/trace/define_trace.h  |    5 -
 23 files changed, 503 insertions(+), 355 deletions(-)
 create mode 100644 include/linux/asm/unaligned.h
 create mode 100644 include/linux/compat-2.6.17.h
 create mode 100644 include/linux/compat-2.6.20.h
Signature · 1 line
1.7.2.30.gc37d7.dirty
#1 lore raw

PATCH 1/44 compat/2.6.17: add header's skeleton

---
 include/linux/compat-2.6.17.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/compat-2.6.17.h
include/linux/compat-2.6.17.h new file +11 -0
new file mode 100644
index 0000000..36d9fb2
@@ -0,0 +1,11 @@
+#ifndef LINUX_26_17_COMPAT_H
+#define LINUX_26_17_COMPAT_H
+
+#include <linux/version.h>
+
+/* Compat work for 2.6.17 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) */
+
+#endif /* LINUX_26_17_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#2 lore raw

PATCH 2/44 compat/2.6.17: add compat macro for `NET_SKB_PAD'

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.17.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.17.h +2 -0
index 36d9fb2..b7c9473 100644
@@ -6,6 +6,8 @@
 /* Compat work for 2.6.17 */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
 
+#define NET_SKB_PAD	16
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) */
 
 #endif /* LINUX_26_17_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#3 lore raw

PATCH 3/44 compat/2.6.18: add compat skeleton for the `hwrng' API

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.18.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
include/linux/compat-2.6.18.h +24 -0
index 5e0182b..a45cfc7 100644
@@ -8,6 +8,30 @@
 
 #define roundup(x, y)	((((x) + ((y) - 1)) / (y)) * (y))
 
+struct hwrng
+{
+	const char *name;
+	int (*init)(struct hwrng *rng);
+	void (*cleanup)(struct hwrng *rng);
+	int (*data_present)(struct hwrng *rng);
+	int (*data_read)(struct hwrng *rng, u32 *data);
+	unsigned long priv;
+
+	/* internal. */
+	struct list_head list;
+};
+
+static inline int
+hwrng_register(struct hwrng *rng)
+{
+	return -ENOSYS;
+}
+
+static void
+hwrng_unregister(struct hwrng *rng)
+{
+}
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */
 
 #endif /* LINUX_26_18_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#4 lore raw

PATCH 4/44 compat/2.6.18: add compat inline for netdev_alloc_skb()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.18.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
include/linux/compat-2.6.18.h +21 -0
index a45cfc7..4a7034a 100644
@@ -6,8 +6,29 @@
 /* Compat work for 2.6.18 */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
 
+#include <linux/gfp.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+
 #define roundup(x, y)	((((x) + ((y) - 1)) / (y)) * (y))
 
+#ifndef NET_SKB_PAD
+#define NET_SKB_PAD	16
+#endif
+
+static inline struct sk_buff *
+netdev_alloc_skb(struct net_device *dev, unsigned int length)
+{
+	struct sk_buff *skb;
+
+	skb = alloc_skb(length + NET_SKB_PAD, GFP_ATOMIC);
+	if (likely(skb)) {
+		skb_reserve(skb, NET_SKB_PAD);
+		skb->dev = dev;
+	}
+	return skb;
+}
+
 struct hwrng
 {
 	const char *name;
Signature · 1 line
1.7.2.30.gc37d7.dirty
#5 lore raw

Re: [PATCH 04/44] compat/2.6.18: add compat inline for netdev_alloc_skb()

Quoted 11 lines · Arnaud Lacombe
---
 include/linux/compat-2.6.18.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
include/linux/compat-2.6.18.h +0 -0
index a45cfc7..4a7034a 100644
@@ -6,8 +6,29 @@
 /* Compat work for 2.6.18 */

include/linux/compat-2.6.18.h line 16

Quoted 10 lines
include/linux/compat-2.6.18.h +6 -0
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
 
+#include <linux/gfp.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+
 #define roundup(x, y)	((((x) + ((y) - 1)) / (y)) * (y))
 
+#ifndef NET_SKB_PAD
+#define NET_SKB_PAD	16

Why are you adding the ifndef for NET_SKB_PAD if you know you already added it for 2.6.17 on your patch 2/44 ?

Luis

#6 lore raw

Re: [PATCH 04/44] compat/2.6.18: add compat inline for netdev_alloc_skb()

Hi,

Quoted 20 lines · Luis R. Rodriguez
Quoted 19 lines · Arnaud Lacombe

---
 include/linux/compat-2.6.18.h |   21 +++++++++++++++++++++

 1 files changed, 21 insertions(+), 0 deletions(-)
include/linux/compat-2.6.18.h +4 -0
index a45cfc7..4a7034a 100644
@@ -6,8 +6,29 @@
  /* Compat work for 2.6.18 */
  #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
 
+#include <linux/gfp.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+
  #define roundup(x, y)        ((((x) + ((y) - 1)) / (y)) * (y))
 
Quoted 6 lines

include/linux/compat-2.6.18.h line 16

Quoted 2 lines
include/linux/compat-2.6.18.h +2 -0
+#ifndef NET_SKB_PAD
+#define NET_SKB_PAD  16

Why are you adding the ifndef for NET_SKB_PAD if you know you already added it for 2.6.17 on your patch 2/44 ?

I should have lost a track when I made that change, it correctly appeared in 2.6.17. My mistake :)

- Arnaud

#7 lore raw

PATCH 5/44 compat/2.6.19: fix comment

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.19.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/compat-2.6.19.h +1 -1
index 1e648c0..9bb1ace 100644
@@ -19,6 +19,6 @@ compat_kmem_cache_destroy(struct kmem_cache *cachep)
 #endif
 }
 
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) */
 
 #endif /* LINUX_26_19_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#8 lore raw

PATCH 6/44 compat/2.6.19: add typedef for `bool' and `true'/`false'

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.19.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/linux/compat-2.6.19.h +8 -0
index 9bb1ace..bcffc47 100644
@@ -19,6 +19,14 @@ compat_kmem_cache_destroy(struct kmem_cache *cachep)
 #endif
 }
 
+#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) */
+
+typedef _Bool			bool;
+enum {
+	false = 0,
+	true = 1
+};
+
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) */
 
 #endif /* LINUX_26_19_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#9 lore raw

PATCH 7/44 compat/2.6.19: rework compat macro to kmem_cache_destroy()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.19.h |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
include/linux/compat-2.6.19.h +1 -10
index bcffc47..ddba97d 100644
@@ -8,16 +8,7 @@
 
 #include <linux/slab.h>
 
-static inline int
-compat_kmem_cache_destroy(struct kmem_cache *cachep)
-{
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-	return kmem_cache_destroy(cachep);
-#else
-	kmem_cache_destroy(cachep);
-	return 0;
-#endif
-}
+#define kmem_cache_destroy(cachep)	({ kmem_cache_destroy(cachep); 0; })
 
 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) */
 
Signature · 1 line
1.7.2.30.gc37d7.dirty
#10 lore raw

Re: [PATCH 07/44] compat/2.6.19: rework compat macro to kmem_cache_destroy()

Quoted 14 lines · Arnaud Lacombe
---
 include/linux/compat-2.6.19.h |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
include/linux/compat-2.6.19.h +0 -1
index bcffc47..ddba97d 100644
@@ -8,16 +8,7 @@
 
 #include <linux/slab.h>
 
-static inline int

include/linux/compat-2.6.19.h line 11

Quoted 10 lines
include/linux/compat-2.6.19.h +1 -9
-compat_kmem_cache_destroy(struct kmem_cache *cachep)
-{
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-	return kmem_cache_destroy(cachep);
-#else
-	kmem_cache_destroy(cachep);
-	return 0;
-#endif
-}
+#define kmem_cache_destroy(cachep)	({ kmem_cache_destroy(cachep); 0; })

Is this because it shall not even fail for older kernels?

Luis

#11 lore raw

PATCH 8/44 compat/2.6.20: add header's skeleton

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.20.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/compat-2.6.20.h
include/linux/compat-2.6.20.h new file +11 -0
new file mode 100644
index 0000000..bbfdacb
@@ -0,0 +1,11 @@
+#ifndef LINUX_26_20_COMPAT_H
+#define LINUX_26_20_COMPAT_H
+
+#include <linux/version.h>
+
+/* Compat work for 2.6.20 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) */
+
+#endif /* LINUX_26_20_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#12 lore raw

PATCH 9/44 compat/2.6.20: add compat macro for `struct delayed_work'

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.20.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/compat-2.6.20.h +3 -0
index bbfdacb..c77e87e 100644
@@ -6,6 +6,9 @@
 /* Compat work for 2.6.20 */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
 
+/* `struct work_struct' and `struct delayed_work' are field compatible */
+#define delayed_work work_struct
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) */
 
 #endif /* LINUX_26_20_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#13 lore raw

PATCH 10/44 compat/2.6.23: add compat inline for notifier_{from,to}_errno()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.23.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/compat-2.6.23.h +14 -0
index fbfb470..5dd6301 100644
@@ -7,11 +7,25 @@
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
 
 #include <linux/netdevice.h>
+#include <linux/notifier.h>
 #include <linux/sched.h>
 #include <linux/workqueue.h>
 #include <linux/genetlink.h>
 #include <net/sch_generic.h>
 
+/* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
+static inline int notifier_from_errno(int err)
+{
+	return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+}
+
+/* Restore (negative) errno value from notify return value. */
+static inline int notifier_to_errno(int ret)
+{
+	ret &= ~NOTIFY_STOP_MASK;
+	return ret > NOTIFY_OK ? NOTIFY_OK - ret : 0;
+}
+
 /*
  * Tell gcc if a function is cold. The compiler will assume any path
  * directly leading to the call is unlikely.
Signature · 1 line
1.7.2.30.gc37d7.dirty
#14 lore raw

PATCH 11/44 compat/2.6.24: add compat macro for sk_alloc()

In reply to Arnaud Lacombe

This was part of the network namespace move.

---
 include/linux/compat-2.6.24.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/compat-2.6.24.h +3 -0
index f9c777c..6d5dce5 100644
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/scatterlist.h>
+#include <net/sock.h>
 
 #define KEY_BLUETOOTH	237
 #define KEY_WLAN	238
@@ -161,6 +162,8 @@ struct ssb_device_id {
 /* Namespace stuff, introduced on 2.6.24 */
 #define dev_get_by_index(a, b)		dev_get_by_index(b)
 #define __dev_get_by_index(a, b)	__dev_get_by_index(b)
+#define sk_alloc(net, fam, pri, prot)	sk_alloc(fam, pri, prot, 1)
+
 
 /*
  * Display a 6 byte device address (MAC) in a readable format.
Signature · 1 line
1.7.2.30.gc37d7.dirty
#15 lore raw

PATCH 12/44 compat/2.6.25: don't include <linux/hw_random.h> prior to 2.6.18

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.25.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/compat-2.6.25.h +3 -1
index ad3220a..641fbde 100644
@@ -8,8 +8,10 @@
 
 #include <linux/types.h>
 #include <linux/io.h>
-#include <linux/hw_random.h>
 #include <linux/leds.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))
+#include <linux/hw_random.h>
+#endif
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/pm.h>
Signature · 1 line
1.7.2.30.gc37d7.dirty
#16 lore raw

PATCH 13/44 compat/2.6.25: don't include <linux/{io,leds}.h> prior to 2.6.17

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.25.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.25.h +2 -0
index 641fbde..6183a89 100644
@@ -7,8 +7,10 @@
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
 
 #include <linux/types.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17))
 #include <linux/io.h>
 #include <linux/leds.h>
+#endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))
 #include <linux/hw_random.h>
 #endif
Signature · 1 line
1.7.2.30.gc37d7.dirty
#17 lore raw

PATCH 14/44 compat/2.6.25: conditionally defines `__WARN'

In reply to Arnaud Lacombe

powerpc has a MD definition for it already.

---
 include/linux/compat-2.6.25.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.25.h +2 -0
index 6183a89..b2bf50f 100644
@@ -72,7 +72,9 @@ int compat_pm_qos_power_deinit(void);
 /* Although pm_qos stuff is not implemented on <= 2.6.24 lets keep the define */
 #define PM_QOS_DEFAULT_VALUE -1
 
+#ifndef __WARN
 #define __WARN(foo) dump_stack()
+#endif
 
 #define dev_emerg(dev, format, arg...)          \
 	dev_printk(KERN_EMERG , dev , format , ## arg)
Signature · 1 line
1.7.2.30.gc37d7.dirty
#18 lore raw

PATCH 15/44 compat/2.6.25: add compat macro for ip_route_output_key()

In reply to Arnaud Lacombe

This is was a late network namespace conversion :)

---
 include/linux/compat-2.6.25.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.25.h +2 -0
index b2bf50f..4d55bbb 100644
@@ -88,6 +88,8 @@ extern void		__dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct
 
 #define seq_file_net &init_net;
 
+#define ip_route_output_key(net, rt, fl)	ip_route_output_key(rt, fl)
+
 enum nf_inet_hooks {
 	NF_INET_PRE_ROUTING = 0,
 	NF_INET_LOCAL_IN = 1,
Signature · 1 line
1.7.2.30.gc37d7.dirty
#19 lore raw

PATCH 16/44 compat/2.6.29: don't include <linux/if_link.h> prior to 2.6.19

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.29.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.29.h +2 -0
index cce678f..ef40d00 100644
@@ -3,7 +3,9 @@
 
 #include <linux/version.h>
 #include <linux/netdevice.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
 #include <linux/if_link.h>
+#endif
 
 /*
  * I kow this looks odd.. but 2.6.32 added the netdev_tx_t
Signature · 1 line
1.7.2.30.gc37d7.dirty
#20 lore raw

PATCH 17/44 compat/2.6.29: const'ify compat inline to dev_get_stats()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.29.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/compat-2.6.29.h +2 -1
index ef40d00..bd112d0 100644
@@ -229,7 +229,8 @@ static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list,
 }
 
 
-static inline struct net_device_stats *dev_get_stats(struct net_device *dev)
+static inline const struct net_device_stats *
+dev_get_stats(struct net_device *dev)
 {
 	return dev->get_stats(dev);
 }
Signature · 1 line
1.7.2.30.gc37d7.dirty
#21 lore raw

PATCH 18/44 compat/2.6.31: gather all the threaded IRQ backport together

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.31.h |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
include/linux/compat-2.6.31.h +9 -10
index d2e0f01..b9a70bd 100644
@@ -58,16 +58,6 @@
 #define SDIO_DEVICE_ID_MARVELL_8688WLAN		0x9104
 #endif
 
-struct compat_threaded_irq {
-	unsigned int irq;
-	irq_handler_t handler;
-	irq_handler_t thread_fn;
-	void *dev_id;
-	char wq_name[64];
-	struct workqueue_struct *wq;
-	struct work_struct work;
-};
-
 /*
  * kmemleak was introduced on 2.6.31, since older kernels do not have
  * we simply ignore its tuning.
@@ -115,6 +105,15 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
 }
 
 /* Backport threaded IRQ support */
+struct compat_threaded_irq {
+	unsigned int irq;
+	irq_handler_t handler;
+	irq_handler_t thread_fn;
+	void *dev_id;
+	char wq_name[64];
+	struct workqueue_struct *wq;
+	struct work_struct work;
+};
 
 static inline
 void compat_irq_work(struct work_struct *work)
Signature · 1 line
1.7.2.30.gc37d7.dirty
#22 lore raw

PATCH 19/44 compat/2.6.31: fix threaded irq backport wrt. INIT_WORK() macro

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.31.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/compat-2.6.31.h +14 -0
index b9a70bd..b1b7b28 100644
@@ -115,12 +115,22 @@ struct compat_threaded_irq {
 	struct work_struct work;
 };
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+static inline
+void compat_irq_work(void *arg)
+{
+	struct work_struct *work = arg;
+	struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
+	comp->thread_fn(comp->irq, comp->dev_id);
+}
+#else
 static inline
 void compat_irq_work(struct work_struct *work)
 {
 	struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
 	comp->thread_fn(comp->irq, comp->dev_id);
 }
+#endif
 
 static inline
 irqreturn_t compat_irq_dispatcher(int irq, void *dev_id)
@@ -150,7 +160,11 @@ int compat_request_threaded_irq(struct compat_threaded_irq *comp,
 	comp->handler = handler;
 	comp->thread_fn = thread_fn;
 	comp->dev_id = dev_id;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+	INIT_WORK(&comp->work, compat_irq_work, &comp->work);
+#else
 	INIT_WORK(&comp->work, compat_irq_work);
+#endif
 
 	if (!comp->wq) {
 		snprintf(comp->wq_name, sizeof(comp->wq_name),
Signature · 1 line
1.7.2.30.gc37d7.dirty
#23 lore raw

PATCH 20/44 compat/2.6.32: fix compat inline to flush_delayed_work()

In reply to Arnaud Lacombe

This was needed as major API changes was made in 2.6.21.

---
 include/linux/compat-2.6.32.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/compat-2.6.32.h +5 -0
index 321a89a..873ae3d 100644
@@ -20,6 +20,10 @@
 
 static inline void flush_delayed_work(struct delayed_work *dwork)
 {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
+	cancel_delayed_work(dwork);
+	flush_scheduled_work();
+#else
 	if (del_timer_sync(&dwork->timer)) {
 		/*
 		 * This is what would happen on 2.6.32 but since we don't have
@@ -34,6 +38,7 @@ static inline void flush_delayed_work(struct delayed_work *dwork)
 		*/
 	}
 	flush_work(&dwork->work);
+#endif
 }
 
 /*
Signature · 1 line
1.7.2.30.gc37d7.dirty
#24 lore raw

PATCH 21/44 compat/2.6.32: add compat macros for sysctl helpers

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.32.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
include/linux/compat-2.6.32.h +24 -0
index 873ae3d..3b9915e 100644
@@ -99,6 +99,30 @@ struct dev_pm_ops name = { \
 
 #define dev_to_sdio_func(d)	container_of(d, struct sdio_func, dev)
 
+#define proc_dostring(table, write, buff, lenp, ppos) \
+	    ({ proc_dostring(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_dointvec(table, write, buff, lenp, ppos) \
+	    ({ proc_dointvec(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_dointvec_minmax(table, write, buff, lenp, ppos) \
+	    ({ proc_dointvec_minmax(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_dointvec_jiffies(table, write, buff, lenp, ppos) \
+	    ({ proc_dointvec_jiffies(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_dointvec_userhz_jiffies(table, write, buff, lenp, ppos) \
+	    ({ proc_dointvec_userhz_jiffies(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_dointvec_ms_jiffies(table, write, buff, lenp, ppos) \
+	    ({ proc_dointvec_ms_jiffies(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_doulongvec_minmax(table, write, buff, lenp, ppos) \
+	    ({ proc_doulongvec_minmax(table, write, NULL, buff, lenp, ppos); })
+
+#define proc_doulongvec_ms_jiffies_minmax(table, write, buff, lenp, ppos) \
+	    ({ proc_doulongvec_ms_jiffies_minmax(table, write, NULL, buff, lenp, ppos); })
+
 #define lockdep_assert_held(l)			do { } while (0)
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#25 lore raw

PATCH 22/44 compat/2.6.33: add compat macro to BUILD_BUG_ON_NOT_POWER_OF_2()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.33.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/compat-2.6.33.h +3 -0
index c2dbc1b..fe1783c 100644
@@ -14,6 +14,9 @@
 #include <linux/kfifo.h>
 #include <linux/firmware.h>
 
+#define BUILD_BUG_ON_NOT_POWER_OF_2(n)			\
+	BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
+
 #define release_firmware compat_release_firmware
 #define request_firmware compat_request_firmware
 #define request_firmware_nowait compat_request_firmware_nowait
Signature · 1 line
1.7.2.30.gc37d7.dirty
#26 lore raw

PATCH 23/44 compat/2.6.33: fix pcmcia include

In reply to Arnaud Lacombe

This fix 'ppc6xx_defconfig' build.

---
 include/linux/compat-2.6.33.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.33.h +2 -0
index fe1783c..8c8789d 100644
@@ -7,8 +7,10 @@
 
 #include <linux/skbuff.h>
 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
+struct pcmcia_socket;
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cistpl.h>
+#include <pcmcia/cs.h>
 #include <pcmcia/ds.h>
 #endif
 #include <linux/kfifo.h>
Signature · 1 line
1.7.2.30.gc37d7.dirty
#27 lore raw

PATCH 24/44 compat/2.6.33: don't export prototype for pccard_loop_tuple()

In reply to Arnaud Lacombe

Mainline kernel does not defines any prototype for this function.

---
 include/linux/compat-2.6.33.h |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
include/linux/compat-2.6.33.h +0 -7
index 8c8789d..9b9ad35 100644
@@ -87,13 +87,6 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
 
 #endif /* CONFIG_PCMCIA */
 
-/* loop over CIS entries */
-int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
-		      cisdata_t code, cisparse_t *parse, void *priv_data,
-		      int (*loop_tuple) (tuple_t *tuple,
-					 cisparse_t *parse,
-					 void *priv_data));
-
 #endif /* CONFIG_PCCARD */
 
 /* Backport for kfifo
Signature · 1 line
1.7.2.30.gc37d7.dirty
#28 lore raw

PATCH 25/44 compat/2.6.36: `va_list' needs <stdarg.h>

In reply to Arnaud Lacombe

This fixes the following build error:

include/linux/compat-2.6.36.h:13: error: syntax error before "va_list" include/linux/compat-2.6.36.h:13: warning: no semicolon at end of struct or union

---
 include/linux/compat-2.6.36.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/compat-2.6.36.h +1 -0
index 1d929d7..7ca787d 100644
@@ -12,6 +12,7 @@
 #define kparam_block_sysfs_write(a)
 #define kparam_unblock_sysfs_write(a)
 
+#include <stdarg.h>
 struct va_format {
 	const char *fmt;
 	va_list *va;
Signature · 1 line
1.7.2.30.gc37d7.dirty
#29 lore raw

PATCH 26/44 compat: remove a couple of macro definition protection

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.31.h |    4 ----
 include/linux/compat-2.6.32.h |    2 --
 2 files changed, 0 insertions(+), 6 deletions(-)
include/linux/compat-2.6.31.h +0 -4
index b1b7b28..52291f4 100644
@@ -50,13 +50,9 @@
 #endif
 #endif
 
-#ifndef NETDEV_PRE_UP
 #define NETDEV_PRE_UP		0x000D
-#endif
 
-#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN
 #define SDIO_DEVICE_ID_MARVELL_8688WLAN		0x9104
-#endif
 
 /*
  * kmemleak was introduced on 2.6.31, since older kernels do not have
include/linux/compat-2.6.32.h +0 -2
index 3b9915e..8f139b3 100644
@@ -59,7 +59,6 @@ static inline void flush_delayed_work(struct delayed_work *dwork)
 
 #define SET_NETDEV_DEVTYPE(netdev, type)
 
-#ifdef __KERNEL__
 /* Driver transmit return codes */
 enum netdev_tx {
 	BACKPORT_NETDEV_TX_OK = NETDEV_TX_OK,       /* driver took care of packet */
@@ -67,7 +66,6 @@ enum netdev_tx {
 	BACKPORT_NETDEV_TX_LOCKED = NETDEV_TX_LOCKED,  /* driver tx lock was already taken */
 };
 typedef enum netdev_tx netdev_tx_t;
-#endif /* __KERNEL__ */
 
 /*
  * dev_pm_ops is only available on kernels >= 2.6.29, for
Signature · 1 line
1.7.2.30.gc37d7.dirty
#30 lore raw

PATCH 27/44 compat/2.6.33: remove macro not in mainline

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.23.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
include/linux/compat-2.6.23.h +0 -4
index 5dd6301..1a486ab 100644
@@ -84,10 +84,6 @@ static inline void tcf_destroy_chain_compat(struct tcf_proto **fl)
 #define da_users	dmi_users
 #define da_gusers	dmi_gusers
 
-/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and
- * dev_set_promiscuity() became a wrapper. */
-#define __dev_set_promiscuity dev_set_promiscuity
-
 /* Our own 2.6.22 port on compat.c */
 extern void	dev_mc_unsync(struct net_device *to, struct net_device *from);
 extern int	dev_mc_sync(struct net_device *to, struct net_device *from);
Signature · 1 line
1.7.2.30.gc37d7.dirty
#31 lore raw

Re: [PATCH 27/44] compat/2.6.33: remove macro not in mainline

Quoted 10 lines · Arnaud Lacombe
---
 include/linux/compat-2.6.23.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
include/linux/compat-2.6.23.h +0 -0
index 5dd6301..1a486ab 100644

include/linux/compat-2.6.23.h static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) · line 90

Quoted 7 lines
include/linux/compat-2.6.23.h +0 -4
@@ -84,10 +84,6 @@ static inline void tcf_destroy_chain_compat(struct tcf_proto **fl)
 #define da_users	dmi_users
 #define da_gusers	dmi_gusers
 
-/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and
- * dev_set_promiscuity() became a wrapper. */
-#define __dev_set_promiscuity dev_set_promiscuity
-

Good call, how did you find these non-in-kernel thingies?

Luis

#32 lore raw

PATCH 28/44 compat: avoid using `#include_next' directive in compat headers

In reply to Arnaud Lacombe
---
 include/linux/pm_qos_params.h |    7 +++----
 include/linux/tracepoint.h    |   14 +++++++-------
 include/net/net_namespace.h   |   14 +++++++-------
 include/trace/define_trace.h  |    5 -----
 4 files changed, 17 insertions(+), 23 deletions(-)
include/linux/pm_qos_params.h +3 -4
index e1f083c..8c69ab2 100644
@@ -1,8 +1,7 @@
 #include <linux/version.h>
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+
 /* interface for the pm_qos_power infrastructure of the linux kernel.
  *
  * Mark Gross <[email protected]>
@@ -28,5 +27,5 @@ int pm_qos_requirement(int qos);
 
 int pm_qos_add_notifier(int qos, struct notifier_block *notifier);
 int pm_qos_remove_notifier(int qos, struct notifier_block *notifier);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */
 
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */
include/linux/tracepoint.h +7 -7
index 9f5add1..4619247 100644
@@ -1,10 +1,10 @@
-#ifndef _COMPAT_LINUX_TRACEPOINT_H
-#define _COMPAT_LINUX_TRACEPOINT_H 1
-
 #include <linux/version.h>
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
-#include_next <linux/tracepoint.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
+
+#ifndef _LINUX_TRACEPOINT_H
+#define _LINUX_TRACEPOINT_H
+
+#endif /* _LINUX_TRACEPOINT_H */
 
-#endif	/* _COMPAT_LINUX_TRACEPOINT_H */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
include/net/net_namespace.h +7 -7
index 0f74944..23a517a 100644
@@ -1,10 +1,10 @@
-#ifndef _COMPAT_NET_NET_NAMESPACE_H
-#define _COMPAT_NET_NET_NAMESPACE_H 1
-
 #include <linux/version.h>
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23))
-#include_next <net/net_namespace.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+
+#ifndef __NET_NET_NAMESPACE_H
+#define __NET_NET_NAMESPACE_H
+
+#endif /* __NET_NET_NAMESPACE_H */
 
-#endif	/* _COMPAT_NET_NET_NAMESPACE_H */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
include/trace/define_trace.h +0 -5
index 7d03ccf..e69de29 100644
@@ -1,5 +0,0 @@
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
-#include_next <trace/define_trace.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#33 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Quoted 24 lines · Arnaud Lacombe
---
 include/linux/pm_qos_params.h |    7 +++----
 include/linux/tracepoint.h    |   14 +++++++-------
 include/net/net_namespace.h   |   14 +++++++-------
 include/trace/define_trace.h  |    5 -----
 4 files changed, 17 insertions(+), 23 deletions(-)
include/linux/pm_qos_params.h +2 -3
index e1f083c..8c69ab2 100644
@@ -1,8 +1,7 @@
 #include <linux/version.h>
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+
 /* interface for the pm_qos_power infrastructure of the linux kernel.
  *
  * Mark Gross <[email protected]>

include/linux/pm_qos_params.h int pm_qos_requirement(int qos); · line 31

Quoted 6 lines
include/linux/pm_qos_params.h +1 -1
@@ -28,5 +27,5 @@ int pm_qos_requirement(int qos);
 
 int pm_qos_add_notifier(int qos, struct notifier_block *notifier);
 int pm_qos_remove_notifier(int qos, struct notifier_block *notifier);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */
 
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */

With #include_next gone, how would the compiler find the other header file for version >= 2.6.25?

- Felix

#34 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

In reply to Arnaud Lacombe
Quoted 13 lines · Arnaud Lacombe
---
 include/linux/pm_qos_params.h |    7 +++----
 include/linux/tracepoint.h    |   14 +++++++-------
 include/net/net_namespace.h   |   14 +++++++-------
 include/trace/define_trace.h  |    5 -----
 4 files changed, 17 insertions(+), 23 deletions(-)
include/linux/pm_qos_params.h +0 -0
index e1f083c..8c69ab2 100644

include/linux/pm_qos_params.h line 4

Quoted 7 lines
include/linux/pm_qos_params.h +2 -3
@@ -1,8 +1,7 @@
 #include <linux/version.h>
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+

But will the kernels' own pm_qos_params.h be included for kernels >= 2.6.25?

Luis

#35 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Hi,

Quoted 16 lines · Luis R. Rodriguez
Quoted 15 lines · Arnaud Lacombe

---
 include/linux/pm_qos_params.h |    7 +++---- include/linux/tracepoint.h    |   14 +++++++------- include/net/net_namespace.h   |   14 +++++++------- include/trace/define_trace.h  |    5 -----

 4 files changed, 17 insertions(+), 23 deletions(-)
include/linux/pm_qos_params.h +0 -0
index e1f083c..8c69ab2 100644
@@ -1,8 +1,7 @@
  #include <linux/version.h>
 
Quoted 8 lines

include/linux/pm_qos_params.h line 4

Quoted 5 lines
include/linux/pm_qos_params.h +2 -3
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+

But will the kernels' own pm_qos_params.h be included for kernels >= 2.6.25?

The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

- Arnaud

#36 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Quoted 28 lines · Arnaud Lacombe

Hi,

Quoted 16 lines · Luis R. Rodriguez
Quoted 15 lines · Arnaud Lacombe

---
 include/linux/pm_qos_params.h |    7 +++---- include/linux/tracepoint.h    |   14 +++++++------- include/net/net_namespace.h   |   14 +++++++------- include/trace/define_trace.h  |    5 -----

 4 files changed, 17 insertions(+), 23 deletions(-)
include/linux/pm_qos_params.h +0 -0
index e1f083c..8c69ab2 100644
@@ -1,8 +1,7 @@
  #include <linux/version.h>
 
Quoted 8 lines

include/linux/pm_qos_params.h line 4

Quoted 5 lines
include/linux/pm_qos_params.h +2 -3
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+

But will the kernels' own pm_qos_params.h be included for kernels >= 2.6.25?

Quoted 5 lines

The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here. The purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code. Without an include_next we'd simply skip including the kernel's own original header file.

Luis

#37 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Hi,

Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Arnaud Lacombe

[...]
The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here.

certainly :)

Quoted 5 lines

The
purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code.

I'm not sure to get what you mean by "we can avoid ifdef'ing all includes for the same file on the upstream code", can you details ?

Quoted 4 lines

Without
an include_next we'd simply skip including the kernel's own original header file.

I admit that I removed that part merely because I went loose on the trigger that day. AFAIR, there was no technical point per-se, so I would not mind omitting this patch.

- Arnaud

#38 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Quoted 15 lines · Arnaud Lacombe

Hi,

Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Arnaud Lacombe

[...]
The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here.

certainly :)

Quoted 7 lines
Quoted 5 lines

The
purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code.

I'm not sure to get what you mean by "we can avoid ifdef'ing all includes for the same file on the upstream code", can you details ?

Ah, that's right, you don't see or use compat-wireless likely. Ok, so what we do for backporting the 802.11 subsystem, Bluetooth and some Ethernet drivers is we take the stock upstream files, stuff them into a new directory, and then apply a series of patches to them to get the files to properly compile. The patches address all things that was not possible to backport through compat.git. Header file changes is one of the typical things we run into. If a new header file is added to newer kernels we can play a hack for older kernels and leave the code intact and introduce our own include/linux/foo.h through compat by prefering the local path over the kernel's path. If we're on newer kernels though include_next will go on the search path and find the kernel's own header file.

Quoted 7 lines
Quoted 4 lines

Without
an include_next we'd simply skip including the kernel's own original header file.

I admit that I removed that part merely because I went loose on the trigger that day. AFAIR, there was no technical point per-se, so I would not mind omitting this patch.

OK cool, lets skip that then.

Luis

#39 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Hi,

Quoted 24 lines · Luis R. Rodriguez
Quoted 15 lines · Arnaud Lacombe

Hi,

Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Arnaud Lacombe

[...]
The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here.

certainly :)

Quoted 7 lines
Quoted 5 lines

The
purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code.

I'm not sure to get what you mean by "we can avoid ifdef'ing all includes for the same file on the upstream code", can you details ?

Quoted 13 lines

Ah, that's right, you don't see or use compat-wireless likely. Ok, so what we do for backporting the 802.11 subsystem, Bluetooth and some Ethernet drivers is we take the stock upstream files, stuff them into a new directory, and then apply a series of patches to them to get the files to properly compile. The patches address all things that was not possible to backport through compat.git. Header file changes is one of the typical things we run into. If a new header file is added to newer kernels we can play a hack for older kernels and leave the code intact and introduce our own include/linux/foo.h through compat by prefering the local path over the kernel's path. If we're on newer kernels though include_next will go on the search path and find the kernel's own header file.

Is there any reason you want the compat's include directory to be *before* the kernel include directory ? Because just considering this issue, if the kernel include directory was seen first, this would not arise, as the compat-provided header would just be a fallback.

- Arnaud

#40 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Quoted 41 lines · Arnaud Lacombe

Hi,

Quoted 24 lines · Luis R. Rodriguez
Quoted 15 lines · Arnaud Lacombe

Hi,

Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Arnaud Lacombe

[...]
The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here.

certainly :)

Quoted 7 lines
Quoted 5 lines

The
purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code.

I'm not sure to get what you mean by "we can avoid ifdef'ing all includes for the same file on the upstream code", can you details ?

Quoted 13 lines

Ah, that's right, you don't see or use compat-wireless likely. Ok, so what we do for backporting the 802.11 subsystem, Bluetooth and some Ethernet drivers is we take the stock upstream files, stuff them into a new directory, and then apply a series of patches to them to get the files to properly compile. The patches address all things that was not possible to backport through compat.git. Header file changes is one of the typical things we run into. If a new header file is added to newer kernels we can play a hack for older kernels and leave the code intact and introduce our own include/linux/foo.h through compat by prefering the local path over the kernel's path. If we're on newer kernels though include_next will go on the search path and find the kernel's own header file.

Quoted 2 lines

Is there any reason you want the compat's include directory to be *before* the kernel include directory ?

Hm, yeah but I forget why. It'll come to me.

Quoted 3 lines

Because just considering this
issue, if the kernel include directory was seen first, this would not arise, as the compat-provided header would just be a fallback.

True.

Luis

#41 lore raw

Re: [PATCH 28/44] compat: avoid using `#include_next' directive in compat headers

Quoted 42 lines · Luis R. Rodriguez
Quoted 41 lines · Arnaud Lacombe

Hi,

Quoted 37 lines · Luis R. Rodriguez
Quoted 15 lines · Arnaud Lacombe

Hi,

Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Arnaud Lacombe

[...]
The compat headers should be at the end of the include list, so that the kernel headers get included first, and the compat one will only be when the kernel does not provide the header. This is the only sane way to override kernel provided stuff. That said, there is certainly a use-case I missed.

Agreed, but you are missing the purpose of the trick used here.

certainly :)

Quoted 7 lines
Quoted 5 lines

The
purpose of the include_next was so that we can name our own <linux/pm_qos_params.h> which is part of compat and these directories *will* get a priority over the kernel's so that way we can avoid ifdef'ing all includes for the same file on the upstream code.

I'm not sure to get what you mean by "we can avoid ifdef'ing all includes for the same file on the upstream code", can you details ?

Ah, that's right, you don't see or use compat-wireless likely. Ok, so what we do for backporting the 802.11 subsystem, Bluetooth and some Ethernet drivers is we take the stock upstream files, stuff them into a new directory, and then apply a series of patches to them to get the files to properly compile. The patches address all things that was not possible to backport through compat.git. Header file changes is one of the typical things we run into. If a new header file is added to newer kernels we can play a hack for older kernels and leave the code intact and introduce our own include/linux/foo.h through compat by prefering the local path over the kernel's path. If we're on newer kernels though include_next will go on the search path and find the kernel's own header file.

Quoted 4 lines
Quoted 2 lines

Is there any reason you want the compat's include directory to be *before* the kernel include directory ?

Hm, yeah but I forget why. It'll come to me.

Ah, OK so its because we provide our own mac80211.h, and new cfg80211.h

Luis

#42 lore raw

PATCH 29/44 compat/2.6.22: rework `uninitialized_var' and `__maybe_unused' macros

In reply to Arnaud Lacombe

Protect their definitions, and add fallbacks.

---
 include/linux/compat-2.6.22.h |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
include/linux/compat-2.6.22.h +11 -2
index 7ca1b18..174a269 100644
@@ -80,9 +80,18 @@ static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
 	memcpy(to, skb->data + offset, len);
 }
 
-#define __maybe_unused	__attribute__((unused))
+#if defined(__GNUC__)
+#define __maybe_unused		__attribute__((unused))
+#define uninitialized_var(x)	x = x
+#endif
+
+#ifndef __maybe_unused
+#define __maybe_unused		/* unimplemented */
+#endif
 
-#define uninitialized_var(x) x = x
+#ifndef uninitialized_var
+#define uninitialized_var(x)	x
+#endif
 
 /* This will lead to very weird behaviour... */
 #define NLA_BINARY NLA_STRING
Signature · 1 line
1.7.2.30.gc37d7.dirty
#43 lore raw

PATCH 30/44 compat/2.6.22: nuke pci_{clear,set}_mwi()

In reply to Arnaud Lacombe

All 2.6 kernel have had them.

---
 include/linux/compat-2.6.22.h |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
include/linux/compat-2.6.22.h +0 -9
index 174a269..e0cdab2 100644
@@ -96,15 +96,6 @@ static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
 /* This will lead to very weird behaviour... */
 #define NLA_BINARY NLA_STRING
 
-static inline int pci_set_mwi(struct pci_dev *dev)
-{
-	return -ENOSYS;
-}
-
-static inline void pci_clear_mwi(struct pci_dev *dev)
-{
-}
-
 #define list_first_entry(ptr, type, member) \
         list_entry((ptr)->next, type, member)
 
Signature · 1 line
1.7.2.30.gc37d7.dirty
#44 lore raw

Re: [PATCH 30/44] compat/2.6.22: nuke pci_{clear,set}_mwi()

Quoted 1 line · Arnaud Lacombe

All 2.6 kernel have had them.

Odd, wonder why we added it. Ah well, away it goes! Thanks.

Luis

#45 lore raw

PATCH 31/44 compat/2.6.22: add compat for couple of TCP accessors

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.22.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
include/linux/compat-2.6.22.h +20 -0
index e0cdab2..73dbbb6 100644
@@ -80,6 +80,26 @@ static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
 	memcpy(to, skb->data + offset, len);
 }
 
+static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
+{
+	return (struct iphdr *)skb_network_header(skb);
+}
+
+static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
+{
+	return (struct tcphdr *)skb_transport_header(skb);
+}
+
+static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
+{
+	return tcp_hdr(skb)->doff * 4;
+}
+
+static inline unsigned int tcp_optlen(const struct sk_buff *skb)
+{
+	return (tcp_hdr(skb)->doff - 5) * 4;
+}
+
 #if defined(__GNUC__)
 #define __maybe_unused		__attribute__((unused))
 #define uninitialized_var(x)	x = x
Signature · 1 line
1.7.2.30.gc37d7.dirty
#46 lore raw

Re: [PATCH 31/44] compat/2.6.22: add compat for couple of TCP accessors

Hi,

Quoted 10 lines · Arnaud Lacombe

---
 include/linux/compat-2.6.22.h |   20 ++++++++++++++++++++

 1 files changed, 20 insertions(+), 0 deletions(-)
include/linux/compat-2.6.22.h +0 -0
index e0cdab2..73dbbb6 100644

include/linux/compat-2.6.22.h static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, · line 87

Quoted 8 lines
include/linux/compat-2.6.22.h +5 -0
@@ -80,6 +80,26 @@ static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
        memcpy(to, skb->data + offset, len);
  }
 
+static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
+{
+       return (struct iphdr *)skb_network_header(skb);
+}
+

Actually, this one is already defined a few lines above, but lost in the middle of skb accessor inlines :/ I'll remove this part.

- Arnaud

#47 lore raw

PATCH 32/44 compat/2.6.22: add compat inline for ip_hdrlen()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.22.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/compat-2.6.22.h +5 -0
index 73dbbb6..6675027 100644
@@ -85,6 +85,11 @@ static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
 	return (struct iphdr *)skb_network_header(skb);
 }
 
+static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
+{
+	return ip_hdr(skb)->ihl * 4;
+}
+
 static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
 {
 	return (struct tcphdr *)skb_transport_header(skb);
Signature · 1 line
1.7.2.30.gc37d7.dirty
#48 lore raw

PATCH 33/44 compat/2.6.22: constify skb_transport_header()'s argument

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.22.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/compat-2.6.22.h +1 -1
index 6675027..7c0c615 100644
@@ -46,7 +46,7 @@ static inline void skb_set_transport_header(struct sk_buff *skb, int offset)
 	skb->h.raw = skb->data + offset;
 }
 
-static inline unsigned char *skb_transport_header(struct sk_buff *skb)
+static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
 {
 	return skb->h.raw;
 }
Signature · 1 line
1.7.2.30.gc37d7.dirty
#49 lore raw

PATCH 34/44 compat/2.6.24: move 'struct net' to its own compat header

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.24.h |   31 -------------------------------
 include/net/net_namespace.h   |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 31 deletions(-)
include/linux/compat-2.6.24.h +0 -31
index 6d5dce5..4c1231f 100644
@@ -21,37 +21,6 @@
 
 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
 
-struct proc_dir_entry;
-struct net_device;
-struct net {
-	atomic_t		count;		/* To decided when the network
-						 *  namespace should be freed.
-						 */
-	atomic_t		use_count;	/* To track references we
-						 * destroy on demand
-						 */
-	struct list_head	list;		/* list of network namespaces */
-	struct work_struct	work;		/* work struct for freeing */
-
-	struct proc_dir_entry 	*proc_net;
-	struct proc_dir_entry 	*proc_net_stat;
-	struct proc_dir_entry 	*proc_net_root;
-
-	struct net_device       *loopback_dev;          /* The loopback */
-
-	struct list_head 	dev_base_head;
-	struct hlist_head 	*dev_name_head;
-	struct hlist_head	*dev_index_head;
-};
-
-#ifdef CONFIG_NET
-/* Init's network namespace */
-extern struct net init_net;
-#define INIT_NET_NS(net_ns) .net_ns = &init_net,
-#else
-#define INIT_NET_NS(net_ns)
-#endif
-
 /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */
 typedef unsigned long               uintptr_t;
 
include/net/net_namespace.h +36 -0
index 23a517a..250fea2 100644
@@ -5,6 +5,42 @@
 #ifndef __NET_NET_NAMESPACE_H
 #define __NET_NET_NAMESPACE_H
 
+#include <linux/list.h>
+#include <linux/workqueue.h>
+
+#include <asm/atomic.h>
+
+struct proc_dir_entry;
+struct net_device;
+struct net {
+	atomic_t		count;		/* To decided when the network
+						 *  namespace should be freed.
+						 */
+	atomic_t		use_count;	/* To track references we
+						 * destroy on demand
+						 */
+	struct list_head	list;		/* list of network namespaces */
+	struct work_struct	work;		/* work struct for freeing */
+
+	struct proc_dir_entry 	*proc_net;
+	struct proc_dir_entry 	*proc_net_stat;
+	struct proc_dir_entry 	*proc_net_root;
+
+	struct net_device       *loopback_dev;          /* The loopback */
+
+	struct list_head 	dev_base_head;
+	struct hlist_head 	*dev_name_head;
+	struct hlist_head	*dev_index_head;
+};
+
+#ifdef CONFIG_NET
+/* Init's network namespace */
+extern struct net init_net;
+#define INIT_NET_NS(net_ns) .net_ns = &init_net,
+#else
+#define INIT_NET_NS(net_ns)
+#endif
+
 #endif /* __NET_NET_NAMESPACE_H */
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#50 lore raw

PATCH 35/44 compat/2.6.26: {U,}SHORT_MAX/SHORT_MIN have been deprecated

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.26.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
include/linux/compat-2.6.26.h +0 -5
index 30ee46c..38e1d8d 100644
@@ -39,11 +39,6 @@
 #define SW_RFKILL_ALL           0x03  /* rfkill master switch, type "any"
 					 set = radio enabled */
 
-/* From kernel.h */
-#define USHORT_MAX      ((u16)(~0U))
-#define SHORT_MAX       ((s16)(USHORT_MAX>>1))
-#define SHORT_MIN       (-SHORT_MAX - 1)
-
 extern int dev_set_name(struct device *dev, const char *name, ...)
 			__attribute__((format(printf, 2, 3)));
 
Signature · 1 line
1.7.2.30.gc37d7.dirty
#51 lore raw

PATCH 36/44 compat/2.6.26: move unaligned backport to its own header

In reply to Arnaud Lacombe
---
 include/linux/asm/unaligned.h |  194 +++++++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.26.h |  214 +----------------------------------------
 2 files changed, 197 insertions(+), 211 deletions(-)
 create mode 100644 include/linux/asm/unaligned.h
include/linux/asm/unaligned.h new file +194 -0
new file mode 100644
index 0000000..7175e92
@@ -0,0 +1,194 @@
+#ifndef _COMPAT_ASM_UNALIGNED_H
+#define _COMPAT_ASM_UNALIGNED_H
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
+
+/*
+ * 2.6.26 added its own unaligned API which the
+ * new drivers can use. Lets port it here by including it in older
+ * kernels and also deal with the architecture handling here.
+ */
+
+#ifdef CONFIG_ALPHA
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* alpha */
+
+#ifdef CONFIG_ARM
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* arm */
+
+#ifdef CONFIG_AVR32
+/*
+ * AVR32 can handle some unaligned accesses, depending on the
+ * implementation.  The AVR32 AP implementation can handle unaligned
+ * words, but halfwords must be halfword-aligned, and doublewords must
+ * be word-aligned.
+ *
+ * However, swapped word loads must be word-aligned so we can't
+ * optimize word loads in general.
+ */
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif
+
+#ifdef CONFIG_BLACKFIN
+#include <linux/unaligned/le_struct.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* blackfin */
+
+#ifdef CONFIG_CRIS
+/*
+ * CRIS can do unaligned accesses itself.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif /* cris */
+
+#ifdef CONFIG_FRV
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* frv */
+
+#ifdef CONFIG_H8300
+#include <linux/unaligned/be_memmove.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* h8300 */
+
+#ifdef  CONFIG_IA64
+#include <linux/unaligned/le_struct.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* ia64 */
+
+#ifdef CONFIG_M32R
+#if defined(__LITTLE_ENDIAN__)
+# include <linux/unaligned/le_memmove.h>
+# include <linux/unaligned/be_byteshift.h>
+# include <linux/unaligned/generic.h>
+#else
+# include <linux/unaligned/be_memmove.h>
+# include <linux/unaligned/le_byteshift.h>
+# include <linux/unaligned/generic.h>
+#endif
+#endif /* m32r */
+
+#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */
+#ifdef CONFIG_COLDFIRE
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#else
+/*
+ * The m68k can do unaligned accesses itself.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif
+#endif /* m68k and m68knommu */
+
+#ifdef CONFIG_MIPS
+#if defined(__MIPSEB__)
+# include <linux/unaligned/be_struct.h>
+# include <linux/unaligned/le_byteshift.h>
+# include <linux/unaligned/generic.h>
+# define get_unaligned  __get_unaligned_be
+# define put_unaligned  __put_unaligned_be
+#elif defined(__MIPSEL__)
+# include <linux/unaligned/le_struct.h>
+# include <linux/unaligned/be_byteshift.h>
+# include <linux/unaligned/generic.h>
+#endif
+#endif /* mips */
+
+#ifdef CONFIG_MN10300
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif /* mn10300 */
+
+#ifdef CONFIG_PARISC
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* parisc */
+
+#ifdef CONFIG_PPC
+/*
+ * The PowerPC can do unaligned accesses itself in big endian mode.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif /* ppc */
+
+#ifdef CONFIG_S390
+/*
+ * The S390 can do unaligned accesses itself.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif /* s390 */
+
+#ifdef CONFIG_SUPERH
+/* SH can't handle unaligned accesses. */
+#ifdef __LITTLE_ENDIAN__
+# include <linux/unaligned/le_struct.h>
+# include <linux/unaligned/be_byteshift.h>
+# include <linux/unaligned/generic.h>
+#else
+# include <linux/unaligned/be_struct.h>
+# include <linux/unaligned/le_byteshift.h>
+# include <linux/unaligned/generic.h>
+#endif
+#endif /* sh - SUPERH */
+
+#ifdef CONFIG_SPARC
+/* sparc and sparc64 */
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif  /* sparc */
+
+#ifdef CONFIG_UML
+#include "asm/arch/unaligned.h"
+#endif /* um - uml */
+
+#ifdef CONFIG_V850
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+#endif /* v850 */
+
+#ifdef CONFIG_X86
+/*
+ * The x86 can do unaligned accesses itself.
+ */
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+#endif /* x86 */
+
+#ifdef CONFIG_XTENSA
+#ifdef __XTENSA_EL__
+# include <linux/unaligned/le_memmove.h>
+# include <linux/unaligned/be_byteshift.h>
+# include <linux/unaligned/generic.h>
+#elif defined(__XTENSA_EB__)
+# include <linux/unaligned/be_memmove.h>
+# include <linux/unaligned/le_byteshift.h>
+# include <linux/unaligned/generic.h>
+#else
+# error processor byte order undefined!
+#endif
+#endif /* xtensa */
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */
+
+#endif /* _COMPAT_ASM_UNALIGNED_H */
include/linux/compat-2.6.26.h +3 -211

220 lines not on this page · raw message

Signature · 1 line
1.7.2.30.gc37d7.dirty
#52 lore raw

Re: [PATCH 36/44] compat/2.6.26: move unaligned backport to its own header

Quoted 6 lines · Arnaud Lacombe
---
 include/linux/asm/unaligned.h |  194 +++++++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.26.h |  214 +----------------------------------------
 2 files changed, 197 insertions(+), 211 deletions(-)
 create mode 100644 include/linux/asm/unaligned.h

Good idea :)

Luis

#53 lore raw

PATCH 37/44 compat/2.6.2{7,8}: fix definition for IEEE80211_HT_CAP_DSSSCCK40

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.27.h |    3 ---
 include/linux/compat-2.6.28.h |    3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/compat-2.6.27.h +0 -3
index b9d7029..fa2dbd6 100644
@@ -86,9 +86,6 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
 #define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr)
 #define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr)
 
-/* This is from include/linux/ieee80211.h */
-#define IEEE80211_HT_CAP_DSSSCCK40		0x1000
-
 /* New link list changes added as of 2.6.27, needed for ath9k */
 
 static inline void __list_cut_position(struct list_head *list,
include/linux/compat-2.6.28.h +3 -0
index 1de39ad..4cd623b 100644
@@ -234,6 +234,9 @@ extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 		       unsigned int cmd, unsigned long arg);
 
+/* This is from include/linux/ieee80211.h */
+#define IEEE80211_HT_CAP_DSSSCCK40		0x1000
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
 
 #endif /* LINUX_26_28_COMPAT_H */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#54 lore raw

PATCH 38/44 compat/2.6.2{8,9}: fix tracepoint macros

In reply to Arnaud Lacombe

It was introduced in 2.6.29, not 2.6.28.

---
 include/linux/compat-2.6.28.h |   24 ------------------------
 include/linux/compat-2.6.29.h |   20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 24 deletions(-)
include/linux/compat-2.6.28.h +0 -24
index 4cd623b..289ec06 100644
@@ -192,30 +192,6 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
 		head->qlen += list->qlen;
 	}
 }
-
-#ifndef DECLARE_TRACE
-
-#define TP_PROTO(args...)	args
-#define TP_ARGS(args...)		args
-
-#define DECLARE_TRACE(name, proto, args)				\
-	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
-	{ }								\
-	static inline void trace_##name(proto)				\
-	{ }								\
-	static inline int register_trace_##name(void (*probe)(proto))	\
-	{								\
-		return -ENOSYS;						\
-	}								\
-	static inline int unregister_trace_##name(void (*probe)(proto))	\
-	{								\
-		return -ENOSYS;						\
-	}
-
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)
-
-
 #endif
 
 /* openSuse includes round_jiffies_up in it's kernel 2.6.27.
include/linux/compat-2.6.29.h +20 -0
index bd112d0..fa29806 100644
@@ -277,6 +277,26 @@ static inline struct net *read_pnet(struct net * const *pnet)
 
 #endif
 
+#define TP_PROTO(args...)	args
+#define TP_ARGS(args...)		args
+
+#define DECLARE_TRACE(name, proto, args)				\
+	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
+	{ }								\
+	static inline void trace_##name(proto)				\
+	{ }								\
+	static inline int register_trace_##name(void (*probe)(proto))	\
+	{								\
+		return -ENOSYS;						\
+	}								\
+	static inline int unregister_trace_##name(void (*probe)(proto))	\
+	{								\
+		return -ENOSYS;						\
+	}
+
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
+#define EXPORT_TRACEPOINT_SYMBOL(name)
+
 extern int		init_dummy_netdev(struct net_device *dev);
 
 #else
Signature · 1 line
1.7.2.30.gc37d7.dirty
#55 lore raw

PATCH 39/44 compat/2.6.29: protect headers inclusion

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.29.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
include/linux/compat-2.6.29.h +3 -2
index fa29806..b83aca0 100644
@@ -2,7 +2,10 @@
 #define LINUX_26_29_COMPAT_H
 
 #include <linux/version.h>
+
 #include <linux/netdevice.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
 #include <linux/if_link.h>
 #endif
@@ -14,8 +17,6 @@
  */
 #include <linux/compat-2.6.32.h>
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
-
 #include <linux/skbuff.h>
 #include <linux/usb.h>
 
Signature · 1 line
1.7.2.30.gc37d7.dirty
#56 lore raw

PATCH 40/44 compat/2.6.29: don't waste space around DIV_ROUND_CLOSEST()

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.29.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
include/linux/compat-2.6.29.h +2 -4
index b83aca0..0c20c9e 100644
@@ -242,12 +242,10 @@ extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
 #endif /* CONFIG_USB */
 #endif
 
-#define DIV_ROUND_CLOSEST(x, divisor)(			\
-{							\
+#define DIV_ROUND_CLOSEST(x, divisor)	({		\
 	typeof(divisor) __divisor = divisor;		\
 	(((x) + ((__divisor) / 2)) / (__divisor));	\
-}							\
-)
+})
 
 extern int eth_mac_addr(struct net_device *dev, void *p);
 extern int eth_change_mtu(struct net_device *dev, int new_mtu);
Signature · 1 line
1.7.2.30.gc37d7.dirty
#57 lore raw

PATCH 41/44 compat/2.6.29: fix typos

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.29.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/compat-2.6.29.h +2 -2
index 0c20c9e..845a0d8 100644
@@ -11,8 +11,8 @@
 #endif
 
 /*
- * I kow this looks odd.. but 2.6.32 added the netdev_tx_t
- * and we backport that there so inlcude that header first
+ * I know this looks odd.. but 2.6.32 added the netdev_tx_t
+ * and we backport that there so include that header first
  * as we need it for the netdev ops.
  */
 #include <linux/compat-2.6.32.h>
Signature · 1 line
1.7.2.30.gc37d7.dirty
#58 lore raw

PATCH 42/44 compat/2.6.{21,30}: make dev_set_uevent_suppress() a no-op for <2.6.21

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.30.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/compat-2.6.30.h +2 -0
index 28f3d54..e824c22 100644
@@ -27,7 +27,9 @@ enum dpm_order {
 
 static inline void dev_set_uevent_suppress(struct device *dev, int val)
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
 	dev->uevent_suppress = val;
+#endif
 }
 
 /*
Signature · 1 line
1.7.2.30.gc37d7.dirty
#59 lore raw

PATCH 43/44 compat/2.6.{19,31}: fix threaded irq backport for <2.6.19

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.31.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
include/linux/compat-2.6.31.h +17 -0
index 52291f4..76b2cf8 100644
@@ -101,6 +101,10 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
 }
 
 /* Backport threaded IRQ support */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *);
+#endif
+
 struct compat_threaded_irq {
 	unsigned int irq;
 	irq_handler_t handler;
@@ -117,7 +121,11 @@ void compat_irq_work(void *arg)
 {
 	struct work_struct *work = arg;
 	struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+	comp->thread_fn(comp->irq, comp->dev_id, NULL);
+#else
 	comp->thread_fn(comp->irq, comp->dev_id);
+#endif
 }
 #else
 static inline
@@ -128,13 +136,22 @@ void compat_irq_work(struct work_struct *work)
 }
 #endif
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+static inline
+irqreturn_t compat_irq_dispatcher(int irq, void *dev_id, struct pt_regs *regs)
+#else
 static inline
 irqreturn_t compat_irq_dispatcher(int irq, void *dev_id)
+#endif
 {
 	struct compat_threaded_irq *comp = dev_id;
 	irqreturn_t res;
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+	res = comp->handler(irq, comp->dev_id, regs);
+#else
 	res = comp->handler(irq, comp->dev_id);
+#endif
 	if (res == IRQ_WAKE_THREAD) {
 		queue_work(comp->wq, &comp->work);
 		res = IRQ_HANDLED;
Signature · 1 line
1.7.2.30.gc37d7.dirty
#60 lore raw

PATCH 44/44 compat/2.6.35: 2.6.35 does not define `SHRT_MIN'

In reply to Arnaud Lacombe
---
 include/linux/compat-2.6.35.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
include/linux/compat-2.6.35.h +0 -1
index 32fd039..c1e5dea 100644
@@ -11,7 +11,6 @@
 /* added on linux/kernel.h */
 #define USHRT_MAX      ((u16)(~0U))
 #define SHRT_MAX       ((s16)(USHRT_MAX>>1))
-#define SHRT_MIN       ((s16)(-SHRT_MAX - 1))
 
 #define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
 #define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
Signature · 1 line
1.7.2.30.gc37d7.dirty
#61 lore raw
In reply to Arnaud Lacombe
Quoted 7 lines · Arnaud Lacombe

Hi Luis,

You will find in answer of this mail the first part of the compat upgrade I am using to support a network-oriented module on kernel from 2.6.15 to 2.6.36.

All this code is available on my repository on github:

Quoted 8 lines

https://github.com/lacombar/linux-compat.git local

This repository also contains the second part I will post later concerning a tentative to reduce namespace pollution when using the compat module. As it is mostly mechanical, I will start another thread with a single proof of concept patch and gather feedbacks :)

Comments welcome !

All in all, very sexy, thanks alot. Can you provide me with a git pull url once you review the comments? If you can first

git fetch; git rebase origin/master

that would be great too.

Thanks a lot!

Luis