From: Johannes Berg <[email protected]>

Signed-off-by: Johannes Berg <[email protected]>
---
 backport/backport-include/linux/compat-3.5.h     | 378 -----------------------
 backport/backport-include/linux/device.h         |  44 +++
 backport/backport-include/linux/etherdevice.h    |   7 +
 backport/backport-include/linux/genetlink.h      |  18 ++
 backport/backport-include/linux/hrtimer.h        |  11 +
 backport/backport-include/linux/i2c.h            |  12 +
 backport/backport-include/linux/kernel.h         |  12 +
 backport/backport-include/linux/net.h            |  44 +++
 backport/backport-include/linux/pagemap.h        |  76 +++++
 backport/backport-include/linux/pkt_sched.h      | 106 +++++++
 backport/backport-include/linux/regmap.h         |  16 +
 backport/backport-include/linux/vga_switcheroo.h |  51 ++-
 backport/backport-include/net/netlink.h          |  26 ++
 13 files changed, 413 insertions(+), 388 deletions(-)
 delete mode 100644 backport/backport-include/linux/compat-3.5.h
 create mode 100644 backport/backport-include/linux/genetlink.h
 create mode 100644 backport/backport-include/linux/hrtimer.h
 create mode 100644 backport/backport-include/linux/net.h
 create mode 100644 backport/backport-include/linux/pagemap.h
 create mode 100644 backport/backport-include/linux/pkt_sched.h
 create mode 100644 backport/backport-include/linux/regmap.h

diff --git a/backport/backport-include/linux/compat-3.5.h 
b/backport/backport-include/linux/compat-3.5.h
deleted file mode 100644
index e21048d..0000000
--- a/backport/backport-include/linux/compat-3.5.h
+++ /dev/null
@@ -1,378 +0,0 @@
-#ifndef LINUX_3_5_COMPAT_H
-#define LINUX_3_5_COMPAT_H
-
-#include <linux/version.h>
-#include <linux/fs.h>
-#include <linux/etherdevice.h>
-#include <linux/net.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
-
-#include <net/netlink.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include <linux/regmap.h>
-
-#define dev_get_regmap LINUX_BACKPORT(dev_get_regmap)
-static inline
-struct regmap *dev_get_regmap(struct device *dev, const char *name)
-{
-       return NULL;
-}
-
-#define devres_release LINUX_BACKPORT(devres_release)
-extern int devres_release(struct device *dev, dr_release_t release,
-                         dr_match_t match, void *match_data);
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
-#include <linux/ratelimit.h>
-#define dev_level_ratelimited(dev_level, dev, fmt, ...)                        
\
-do {                                                                   \
-       static DEFINE_RATELIMIT_STATE(_rs,                              \
-                                     DEFAULT_RATELIMIT_INTERVAL,       \
-                                     DEFAULT_RATELIMIT_BURST);         \
-       if (__ratelimit(&_rs))                                          \
-               dev_level(dev, fmt, ##__VA_ARGS__);                     \
-} while (0)
-
-#define dev_emerg_ratelimited(dev, fmt, ...)                           \
-       dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
-#define dev_alert_ratelimited(dev, fmt, ...)                           \
-       dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
-
-
-#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
-#define dev_dbg_ratelimited(dev, fmt, ...)                             \
-do {                                                                   \
-       static DEFINE_RATELIMIT_STATE(_rs,                              \
-                                     DEFAULT_RATELIMIT_INTERVAL,       \
-                                     DEFAULT_RATELIMIT_BURST);         \
-       DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                 \
-       if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&        \
-           __ratelimit(&_rs))                                          \
-               __dynamic_pr_debug(&descriptor, pr_fmt(fmt),            \
-                                  ##__VA_ARGS__);                      \
-} while (0)
-#else
-#define dev_dbg_ratelimited(dev, fmt, ...)                     \
-       no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif
-
-#endif
-
-/*
- * This backports:
- * commit 569a8fc38367dfafd87454f27ac646c8e6b54bca
- * Author: David S. Miller <[email protected]>
- * Date:   Thu Mar 29 23:18:53 2012 -0400
- *
- *     netlink: Add nla_put_be{16,32,64}() helpers.
- */
-
-static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
-{
-       return nla_put(skb, attrtype, sizeof(__be16), &value);
-}
-
-static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
-{
-       return nla_put(skb, attrtype, sizeof(__be32), &value);
-}
-
-static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
-{
-       return nla_put(skb, attrtype, sizeof(__be64), &value);
-}
-
-/*
- * This backports:
- *
- * commit f56f821feb7b36223f309e0ec05986bb137ce418
- * Author: Daniel Vetter <[email protected]>
- * Date:   Sun Mar 25 19:47:41 2012 +0200
- *
- *     mm: extend prefault helpers to fault in more than PAGE_SIZE
- *
- * The new functions are used by drm/i915 driver.
- *
- */
-
-static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
-{
-        int ret = 0;
-        char __user *end = uaddr + size - 1;
-
-        if (unlikely(size == 0))
-                return ret;
-
-        /*
-         * Writing zeroes into userspace here is OK, because we know that if
-         * the zero gets there, we'll be overwriting it.
-         */
-        while (uaddr <= end) {
-                ret = __put_user(0, uaddr);
-                if (ret != 0)
-                        return ret;
-                uaddr += PAGE_SIZE;
-        }
-
-        /* Check whether the range spilled into the next page. */
-        if (((unsigned long)uaddr & PAGE_MASK) ==
-                        ((unsigned long)end & PAGE_MASK))
-                ret = __put_user(0, end);
-
-        return ret;
-}
-
-static inline int fault_in_multipages_readable(const char __user *uaddr,
-                                               int size)
-{
-        volatile char c;
-        int ret = 0;
-        const char __user *end = uaddr + size - 1;
-
-        if (unlikely(size == 0))
-                return ret;
-
-        while (uaddr <= end) {
-                ret = __get_user(c, uaddr);
-                if (ret != 0)
-                        return ret;
-                uaddr += PAGE_SIZE;
-        }
-
-        /* Check whether the range spilled into the next page. */
-        if (((unsigned long)uaddr & PAGE_MASK) ==
-                        ((unsigned long)end & PAGE_MASK)) {
-                ret = __get_user(c, end);
-                (void)c;
-        }
-
-        return ret;
-}
-
-/* switcheroo is available on >= 2.6.34 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
-#include <linux/vga_switcheroo.h>
-/*
- * This backports:
- *
- *   From 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 Mon Sep 17 00:00:00 2001
- *   From: Takashi Iwai <[email protected]>
- *   Date: Fri, 11 May 2012 07:51:17 +0200
- *   Subject: [PATCH] vga_switcheroo: Introduce struct 
vga_switcheroo_client_ops
- *
- */
-
-struct vga_switcheroo_client_ops {
-    void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
-    void (*reprobe)(struct pci_dev *dev);
-    bool (*can_switch)(struct pci_dev *dev);
-};
-
-/* Wrap around the old code and redefine vga_switcheroo_register_client()
- * for older kernels < 3.5.0.
- */
-static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev,
-               const struct vga_switcheroo_client_ops *ops) {
-
-       return vga_switcheroo_register_client(dev,
-                                             ops->set_gpu_state,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
-                                             ops->reprobe,
-#endif
-                                             ops->can_switch);
-}
-
-#define vga_switcheroo_register_client(_dev, _ops) \
-       compat_vga_switcheroo_register_client(_dev, _ops)
-
-#endif
-
-/* This backports
- *
- * commit 14674e70119ea01549ce593d8901a797f8a90f74
- * Author: Mark Brown <[email protected]>
- * Date:   Wed May 30 10:55:34 2012 +0200
- *
- *     i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING
- */
-
-#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
-
-/*
- * This backports:
- *
- *   From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 2001
- *   From: Xi Wang <[email protected]>
- *   Date: Thu, 31 May 2012 16:26:04 -0700
- *   Subject: [PATCH] introduce SIZE_MAX
- */
-
-#define SIZE_MAX    (~(size_t)0)
-
-
-#include <linux/pkt_sched.h>
-
-/*
- * This backports:
- *
- *   From 76e3cc126bb223013a6b9a0e2a51238d1ef2e409 Mon Sep 17 00:00:00 2001
- *   From: Eric Dumazet <[email protected]>
- *   Date: Thu, 10 May 2012 07:51:25 +0000
- *   Subject: [PATCH] codel: Controlled Delay AQM
- */
-
-#ifndef TCA_CODEL_MAX
-/* CODEL */
-
-#define COMPAT_CODEL_BACKPORT
-
-enum {
-       TCA_CODEL_UNSPEC,
-       TCA_CODEL_TARGET,
-       TCA_CODEL_LIMIT,
-       TCA_CODEL_INTERVAL,
-       TCA_CODEL_ECN,
-       __TCA_CODEL_MAX
-};
-
-#define TCA_CODEL_MAX  (__TCA_CODEL_MAX - 1)
-
-struct tc_codel_xstats {
-       __u32   maxpacket; /* largest packet we've seen so far */
-       __u32   count;     /* how many drops we've done since the last time we
-                           * entered dropping state
-                           */
-       __u32   lastcount; /* count at entry to dropping state */
-       __u32   ldelay;    /* in-queue delay seen by most recently dequeued 
packet */
-       __s32   drop_next; /* time to drop next packet */
-       __u32   drop_overlimit; /* number of time max qdisc packet limit was 
hit */
-       __u32   ecn_mark;  /* number of packets we ECN marked instead of 
dropped */
-       __u32   dropping;  /* are we in dropping state ? */
-};
-
-/* This backports:
- *
- * commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe
- * Author: Eric Dumazet <[email protected]>
- * Date:   Fri May 11 09:30:50 2012 +0000
- *    fq_codel: Fair Queue Codel AQM
- */
-
-/* FQ_CODEL */
-
-enum {
-       TCA_FQ_CODEL_UNSPEC,
-       TCA_FQ_CODEL_TARGET,
-       TCA_FQ_CODEL_LIMIT,
-       TCA_FQ_CODEL_INTERVAL,
-       TCA_FQ_CODEL_ECN,
-       TCA_FQ_CODEL_FLOWS,
-       TCA_FQ_CODEL_QUANTUM,
-       __TCA_FQ_CODEL_MAX
-};
-
-#define TCA_FQ_CODEL_MAX       (__TCA_FQ_CODEL_MAX - 1)
-
-enum {
-       TCA_FQ_CODEL_XSTATS_QDISC,
-       TCA_FQ_CODEL_XSTATS_CLASS,
-};
-
-struct tc_fq_codel_qd_stats {
-       __u32   maxpacket;      /* largest packet we've seen so far */
-       __u32   drop_overlimit; /* number of time max qdisc
-                                * packet limit was hit
-                                */
-       __u32   ecn_mark;       /* number of packets we ECN marked
-                                * instead of being dropped
-                                */
-       __u32   new_flow_count; /* number of time packets
-                                * created a 'new flow'
-                                */
-       __u32   new_flows_len;  /* count of flows in new list */
-       __u32   old_flows_len;  /* count of flows in old list */
-};
-
-struct tc_fq_codel_cl_stats {
-       __s32   deficit;
-       __u32   ldelay;         /* in-queue delay seen by most recently
-                                * dequeued packet
-                                */
-       __u32   count;
-       __u32   lastcount;
-       __u32   dropping;
-       __s32   drop_next;
-};
-
-struct tc_fq_codel_xstats {
-       __u32   type;
-       union {
-               struct tc_fq_codel_qd_stats qdisc_stats;
-               struct tc_fq_codel_cl_stats class_stats;
-       };
-};
-#endif /* TCA_CODEL_MAX */
-
-/* Backport ether_addr_equal */
-static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
-{
-    return !compare_ether_addr(addr1, addr2);
-}
-
-#define net_ratelimited_function(function, ...)                        \
-do {                                                           \
-       if (net_ratelimit())                                    \
-               function(__VA_ARGS__);                          \
-} while (0)
-
-#define net_emerg_ratelimited(fmt, ...)                                \
-       net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
-#define net_alert_ratelimited(fmt, ...)                                \
-       net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
-#define net_crit_ratelimited(fmt, ...)                         \
-       net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
-#define net_err_ratelimited(fmt, ...)                          \
-       net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
-#define net_notice_ratelimited(fmt, ...)                       \
-       net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
-#define net_warn_ratelimited(fmt, ...)                         \
-       net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
-#define net_info_ratelimited(fmt, ...)                         \
-       net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
-#define net_dbg_ratelimited(fmt, ...)                          \
-       net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
-
-#define ktime_get_monotonic_offset LINUX_BACKPORT(ktime_get_monotonic_offset)
-extern ktime_t ktime_get_monotonic_offset(void);
-
-/* This backports:
- *
- * commit 2033e9bf06f07e049bbc77e9452856df846714cc
- * Author: Neil Horman <[email protected]>
- * Date:   Tue May 29 09:30:40 2012 +0000
- *
- *     net: add MODULE_ALIAS_NET_PF_PROTO_NAME
- */
-
-#define MODULE_ALIAS_NET_PF_PROTO_NAME(pf, proto, name) \
-       MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
-                    name)
-
-/* This backports:
- *
- * commit e9412c37082b5c932e83364aaed0c38c2ce33acb
- * Author: Neil Horman <[email protected]>
- * Date:   Tue May 29 09:30:41 2012 +0000
- *
- *     genetlink: Build a generic netlink family module alias
- */
-
-#define MODULE_ALIAS_GENL_FAMILY(family)\
- MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */
-
-#endif /* LINUX_3_5_COMPAT_H */
diff --git a/backport/backport-include/linux/device.h 
b/backport/backport-include/linux/device.h
index 2851dae..872d704 100644
--- a/backport/backport-include/linux/device.h
+++ b/backport/backport-include/linux/device.h
@@ -19,4 +19,48 @@
 void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+#define devres_release LINUX_BACKPORT(devres_release)
+extern int devres_release(struct device *dev, dr_release_t release,
+                         dr_match_t match, void *match_data);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
+    LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#include <linux/ratelimit.h>
+
+#define dev_level_ratelimited(dev_level, dev, fmt, ...)                        
\
+do {                                                                   \
+       static DEFINE_RATELIMIT_STATE(_rs,                              \
+                                     DEFAULT_RATELIMIT_INTERVAL,       \
+                                     DEFAULT_RATELIMIT_BURST);         \
+       if (__ratelimit(&_rs))                                          \
+               dev_level(dev, fmt, ##__VA_ARGS__);                     \
+} while (0)
+
+#define dev_emerg_ratelimited(dev, fmt, ...)                           \
+       dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
+#define dev_alert_ratelimited(dev, fmt, ...)                           \
+       dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
+
+
+#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
+#define dev_dbg_ratelimited(dev, fmt, ...)                             \
+do {                                                                   \
+       static DEFINE_RATELIMIT_STATE(_rs,                              \
+                                     DEFAULT_RATELIMIT_INTERVAL,       \
+                                     DEFAULT_RATELIMIT_BURST);         \
+       DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                 \
+       if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&        \
+           __ratelimit(&_rs))                                          \
+               __dynamic_pr_debug(&descriptor, pr_fmt(fmt),            \
+                                  ##__VA_ARGS__);                      \
+} while (0)
+#else
+#define dev_dbg_ratelimited(dev, fmt, ...)                     \
+       no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#endif /* dynamic debug */
+#endif /* 2.6.27 <= version <= 3.5 */
+
 #endif /* __BACKPORT_DEVICE_H */
diff --git a/backport/backport-include/linux/etherdevice.h 
b/backport/backport-include/linux/etherdevice.h
index 1246be4..aba5e67 100644
--- a/backport/backport-include/linux/etherdevice.h
+++ b/backport/backport-include/linux/etherdevice.h
@@ -47,4 +47,11 @@ static inline void eth_zero_addr(u8 *addr)
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
+static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
+{
+       return !compare_ether_addr(addr1, addr2);
+}
+#endif
+
 #endif /* _BACKPORT_LINUX_ETHERDEVICE_H */
diff --git a/backport/backport-include/linux/genetlink.h 
b/backport/backport-include/linux/genetlink.h
new file mode 100644
index 0000000..afd1f67
--- /dev/null
+++ b/backport/backport-include/linux/genetlink.h
@@ -0,0 +1,18 @@
+#ifndef __BACKPORT_LINUX_GENETLINK_H
+#define __BACKPORT_LINUX_GENETLINK_H
+#include_next <linux/genetlink.h>
+
+/* This backports:
+ *
+ * commit e9412c37082b5c932e83364aaed0c38c2ce33acb
+ * Author: Neil Horman <[email protected]>
+ * Date:   Tue May 29 09:30:41 2012 +0000
+ *
+ *     genetlink: Build a generic netlink family module alias
+ */
+#ifndef MODULE_ALIAS_GENL_FAMILY
+#define MODULE_ALIAS_GENL_FAMILY(family)\
+ MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
+#endif
+
+#endif /* __BACKPORT_LINUX_GENETLINK_H */
diff --git a/backport/backport-include/linux/hrtimer.h 
b/backport/backport-include/linux/hrtimer.h
new file mode 100644
index 0000000..c099dd4
--- /dev/null
+++ b/backport/backport-include/linux/hrtimer.h
@@ -0,0 +1,11 @@
+#ifndef __BACKPORT_LINUX_HRTIMER_H
+#define __BACKPORT_LINUX_HRTIMER_H
+#include_next <linux/hrtimer.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
+#define ktime_get_monotonic_offset LINUX_BACKPORT(ktime_get_monotonic_offset)
+extern ktime_t ktime_get_monotonic_offset(void);
+#endif
+
+#endif /* __BACKPORT_LINUX_HRTIMER_H */
diff --git a/backport/backport-include/linux/i2c.h 
b/backport/backport-include/linux/i2c.h
index 5b87732..1cbbd2f 100644
--- a/backport/backport-include/linux/i2c.h
+++ b/backport/backport-include/linux/i2c.h
@@ -12,4 +12,16 @@ extern int __i2c_transfer(struct i2c_adapter *adap, struct 
i2c_msg *msgs,
                          int num);
 #endif
 
+/* This backports
+ *
+ * commit 14674e70119ea01549ce593d8901a797f8a90f74
+ * Author: Mark Brown <[email protected]>
+ * Date:   Wed May 30 10:55:34 2012 +0200
+ *
+ *     i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING
+ */
+#ifndef I2C_FUNC_NOSTART
+#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
+#endif
+
 #endif /* __BACKPORT_LINUX_I2C_H */
diff --git a/backport/backport-include/linux/kernel.h 
b/backport/backport-include/linux/kernel.h
index 499f538..01aaa91 100644
--- a/backport/backport-include/linux/kernel.h
+++ b/backport/backport-include/linux/kernel.h
@@ -14,4 +14,16 @@ extern int strict_strtoul(const char *, unsigned int, 
unsigned long *);
 extern int strict_strtol(const char *, unsigned int, long *);
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */
 
+/*
+ * This backports:
+ *
+ *   From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 2001
+ *   From: Xi Wang <[email protected]>
+ *   Date: Thu, 31 May 2012 16:26:04 -0700
+ *   Subject: [PATCH] introduce SIZE_MAX
+ */
+#ifndef SIZE_MAX
+#define SIZE_MAX    (~(size_t)0)
+#endif
+
 #endif /* __BACKPORT_KERNEL_H */
diff --git a/backport/backport-include/linux/net.h 
b/backport/backport-include/linux/net.h
new file mode 100644
index 0000000..9d7cbf5
--- /dev/null
+++ b/backport/backport-include/linux/net.h
@@ -0,0 +1,44 @@
+#ifndef __BACKPORT_LINUX_NET_H
+#define __BACKPORT_LINUX_NET_H
+#include_next <linux/net.h>
+
+/* This backports:
+ *
+ * commit 2033e9bf06f07e049bbc77e9452856df846714cc
+ * Author: Neil Horman <[email protected]>
+ * Date:   Tue May 29 09:30:40 2012 +0000
+ *
+ *     net: add MODULE_ALIAS_NET_PF_PROTO_NAME
+ */
+#ifndef MODULE_ALIAS_NET_PF_PROTO_NAME
+#define MODULE_ALIAS_NET_PF_PROTO_NAME(pf, proto, name) \
+       MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
+                    name)
+#endif
+
+#ifndef net_ratelimited_function
+#define net_ratelimited_function(function, ...)                        \
+do {                                                           \
+       if (net_ratelimit())                                    \
+               function(__VA_ARGS__);                          \
+} while (0)
+
+#define net_emerg_ratelimited(fmt, ...)                                \
+       net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
+#define net_alert_ratelimited(fmt, ...)                                \
+       net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
+#define net_crit_ratelimited(fmt, ...)                         \
+       net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
+#define net_err_ratelimited(fmt, ...)                          \
+       net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
+#define net_notice_ratelimited(fmt, ...)                       \
+       net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
+#define net_warn_ratelimited(fmt, ...)                         \
+       net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
+#define net_info_ratelimited(fmt, ...)                         \
+       net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
+#define net_dbg_ratelimited(fmt, ...)                          \
+       net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
+#endif
+
+#endif /* __BACKPORT_LINUX_NET_H */
diff --git a/backport/backport-include/linux/pagemap.h 
b/backport/backport-include/linux/pagemap.h
new file mode 100644
index 0000000..19d72de
--- /dev/null
+++ b/backport/backport-include/linux/pagemap.h
@@ -0,0 +1,76 @@
+#ifndef __BACKPORT_LINUX_PAGEMAP_H
+#define __BACKPORT_LINUX_PAGEMAP_H
+#include_next <linux/pagemap.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
+#include <asm/uaccess.h>
+/*
+ * This backports:
+ *
+ * commit f56f821feb7b36223f309e0ec05986bb137ce418
+ * Author: Daniel Vetter <[email protected]>
+ * Date:   Sun Mar 25 19:47:41 2012 +0200
+ *
+ *     mm: extend prefault helpers to fault in more than PAGE_SIZE
+ *
+ * The new functions are used by drm/i915 driver.
+ *
+ */
+
+static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
+{
+        int ret = 0;
+        char __user *end = uaddr + size - 1;
+
+        if (unlikely(size == 0))
+                return ret;
+
+        /*
+         * Writing zeroes into userspace here is OK, because we know that if
+         * the zero gets there, we'll be overwriting it.
+         */
+        while (uaddr <= end) {
+                ret = __put_user(0, uaddr);
+                if (ret != 0)
+                        return ret;
+                uaddr += PAGE_SIZE;
+        }
+
+        /* Check whether the range spilled into the next page. */
+        if (((unsigned long)uaddr & PAGE_MASK) ==
+                        ((unsigned long)end & PAGE_MASK))
+                ret = __put_user(0, end);
+
+        return ret;
+}
+
+static inline int fault_in_multipages_readable(const char __user *uaddr,
+                                               int size)
+{
+        volatile char c;
+        int ret = 0;
+        const char __user *end = uaddr + size - 1;
+
+        if (unlikely(size == 0))
+                return ret;
+
+        while (uaddr <= end) {
+                ret = __get_user(c, uaddr);
+                if (ret != 0)
+                        return ret;
+                uaddr += PAGE_SIZE;
+        }
+
+        /* Check whether the range spilled into the next page. */
+        if (((unsigned long)uaddr & PAGE_MASK) ==
+                        ((unsigned long)end & PAGE_MASK)) {
+                ret = __get_user(c, end);
+                (void)c;
+        }
+
+        return ret;
+}
+#endif /* < 3.5 */
+
+#endif /* __BACKPORT_LINUX_PAGEMAP_H */
diff --git a/backport/backport-include/linux/pkt_sched.h 
b/backport/backport-include/linux/pkt_sched.h
new file mode 100644
index 0000000..40ed863
--- /dev/null
+++ b/backport/backport-include/linux/pkt_sched.h
@@ -0,0 +1,106 @@
+#ifndef __BACKPORT_LINUX_PKT_SCHED_H
+#define __BACKPORT_LINUX_PKT_SCHED_H
+#include_next <linux/pkt_sched.h>
+#include <linux/version.h>
+
+/*
+ * This backports:
+ *
+ *   From 76e3cc126bb223013a6b9a0e2a51238d1ef2e409 Mon Sep 17 00:00:00 2001
+ *   From: Eric Dumazet <[email protected]>
+ *   Date: Thu, 10 May 2012 07:51:25 +0000
+ *   Subject: [PATCH] codel: Controlled Delay AQM
+ */
+#ifndef TCA_CODEL_MAX
+/* CODEL */
+
+#define COMPAT_CODEL_BACKPORT
+
+enum {
+       TCA_CODEL_UNSPEC,
+       TCA_CODEL_TARGET,
+       TCA_CODEL_LIMIT,
+       TCA_CODEL_INTERVAL,
+       TCA_CODEL_ECN,
+       __TCA_CODEL_MAX
+};
+
+#define TCA_CODEL_MAX  (__TCA_CODEL_MAX - 1)
+
+struct tc_codel_xstats {
+       __u32   maxpacket; /* largest packet we've seen so far */
+       __u32   count;     /* how many drops we've done since the last time we
+                           * entered dropping state
+                           */
+       __u32   lastcount; /* count at entry to dropping state */
+       __u32   ldelay;    /* in-queue delay seen by most recently dequeued 
packet */
+       __s32   drop_next; /* time to drop next packet */
+       __u32   drop_overlimit; /* number of time max qdisc packet limit was 
hit */
+       __u32   ecn_mark;  /* number of packets we ECN marked instead of 
dropped */
+       __u32   dropping;  /* are we in dropping state ? */
+};
+
+/* This backports:
+ *
+ * commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe
+ * Author: Eric Dumazet <[email protected]>
+ * Date:   Fri May 11 09:30:50 2012 +0000
+ *    fq_codel: Fair Queue Codel AQM
+ */
+
+/* FQ_CODEL */
+
+enum {
+       TCA_FQ_CODEL_UNSPEC,
+       TCA_FQ_CODEL_TARGET,
+       TCA_FQ_CODEL_LIMIT,
+       TCA_FQ_CODEL_INTERVAL,
+       TCA_FQ_CODEL_ECN,
+       TCA_FQ_CODEL_FLOWS,
+       TCA_FQ_CODEL_QUANTUM,
+       __TCA_FQ_CODEL_MAX
+};
+
+#define TCA_FQ_CODEL_MAX       (__TCA_FQ_CODEL_MAX - 1)
+
+enum {
+       TCA_FQ_CODEL_XSTATS_QDISC,
+       TCA_FQ_CODEL_XSTATS_CLASS,
+};
+
+struct tc_fq_codel_qd_stats {
+       __u32   maxpacket;      /* largest packet we've seen so far */
+       __u32   drop_overlimit; /* number of time max qdisc
+                                * packet limit was hit
+                                */
+       __u32   ecn_mark;       /* number of packets we ECN marked
+                                * instead of being dropped
+                                */
+       __u32   new_flow_count; /* number of time packets
+                                * created a 'new flow'
+                                */
+       __u32   new_flows_len;  /* count of flows in new list */
+       __u32   old_flows_len;  /* count of flows in old list */
+};
+
+struct tc_fq_codel_cl_stats {
+       __s32   deficit;
+       __u32   ldelay;         /* in-queue delay seen by most recently
+                                * dequeued packet
+                                */
+       __u32   count;
+       __u32   lastcount;
+       __u32   dropping;
+       __s32   drop_next;
+};
+
+struct tc_fq_codel_xstats {
+       __u32   type;
+       union {
+               struct tc_fq_codel_qd_stats qdisc_stats;
+               struct tc_fq_codel_cl_stats class_stats;
+       };
+};
+#endif /* TCA_CODEL_MAX */
+
+#endif /* __BACKPORT_LINUX_PKT_SCHED_H */
diff --git a/backport/backport-include/linux/regmap.h 
b/backport/backport-include/linux/regmap.h
new file mode 100644
index 0000000..fff8e46
--- /dev/null
+++ b/backport/backport-include/linux/regmap.h
@@ -0,0 +1,16 @@
+#ifndef __BACKPORT_LINUX_REGMAP_H
+#define __BACKPORT_LINUX_REGMAP_H
+#include_next <linux/regmap.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+#define dev_get_regmap LINUX_BACKPORT(dev_get_regmap)
+static inline
+struct regmap *dev_get_regmap(struct device *dev, const char *name)
+{
+       return NULL;
+}
+#endif
+
+#endif /* __BACKPORT_LINUX_REGMAP_H */
diff --git a/backport/backport-include/linux/vga_switcheroo.h 
b/backport/backport-include/linux/vga_switcheroo.h
index 4bda17b..698f3f7 100644
--- a/backport/backport-include/linux/vga_switcheroo.h
+++ b/backport/backport-include/linux/vga_switcheroo.h
@@ -1,12 +1,43 @@
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+#ifndef __BACKPORT_VGA_SWITCHEROO_H
+#define __BACKPORT_VGA_SWITCHEROO_H
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
+#include_next <linux/vga_switcheroo.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
 /*
- * XXX: The include guard was sent upstream, drop this
- * once the guard is merged.
+ * This backports:
+ *
+ *   From 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 Mon Sep 17 00:00:00 2001
+ *   From: Takashi Iwai <[email protected]>
+ *   Date: Fri, 11 May 2012 07:51:17 +0200
+ *   Subject: [PATCH] vga_switcheroo: Introduce struct 
vga_switcheroo_client_ops
+ *
  */
-#ifndef LINUX_VGA_SWITCHEROO_H /* in case this gets upstream */
-#include_next <linux/vga_switcheroo.h>
-#ifndef LINUX_VGA_SWITCHEROO_H /* do not redefine once this gets upstream */
-#define LINUX_VGA_SWITCHEROO_H
-#endif /* case 1 LINUX_VGA_SWITCHEROO_H */
-#endif /* case 2 LINUX_VGA_SWITCHEROO_H */
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
+
+struct vga_switcheroo_client_ops {
+    void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
+    void (*reprobe)(struct pci_dev *dev);
+    bool (*can_switch)(struct pci_dev *dev);
+};
+
+/* Wrap around the old code and redefine vga_switcheroo_register_client()
+ * for older kernels < 3.5.0.
+ */
+static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev,
+               const struct vga_switcheroo_client_ops *ops) {
+
+       return vga_switcheroo_register_client(dev,
+                                             ops->set_gpu_state,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+                                             ops->reprobe,
+#endif
+                                             ops->can_switch);
+}
+
+#define vga_switcheroo_register_client(_dev, _ops) \
+       compat_vga_switcheroo_register_client(_dev, _ops)
+
+#endif /* < 3.5 */
+
+#endif /* >= 2.6.34 */
+#endif /* __BACKPORT_VGA_SWITCHEROO_H */
diff --git a/backport/backport-include/net/netlink.h 
b/backport/backport-include/net/netlink.h
index ee51de6..39e0149 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -93,4 +93,30 @@ static inline s64 nla_get_s64(struct nlattr *nla)
 }
 #endif /* < 3.7.0 */
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+/*
+ * This backports:
+ * commit 569a8fc38367dfafd87454f27ac646c8e6b54bca
+ * Author: David S. Miller <[email protected]>
+ * Date:   Thu Mar 29 23:18:53 2012 -0400
+ *
+ *     netlink: Add nla_put_be{16,32,64}() helpers.
+ */
+
+static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be16), &value);
+}
+
+static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be32), &value);
+}
+
+static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be64), &value);
+}
+#endif /* < 3.5 */
+
 #endif /* __BACKPORT_NET_NETLINK_H */
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe backports" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to