--- /dev/null
+/*
+The new attribute sysfs group was added onto struct class via
+commit d05a6f96c
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains d05a6f96c
+v3.11-rc2~18^2~3
+
+This backpoort makes use of the helpers to backport this more efficiently.
+Refer to the INFO file for documentation there on that.
+
+commit d05a6f96c76062b5f25858ac02cf677602076f7e
+Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Sun Jul 14 16:05:58 2013 -0700
+
+ driver core: add default groups to struct class
+
+ We should be using groups, not attribute lists, for classes to allow
+ subdirectories, and soon, binary files. Groups are just more flexible
+ overall, so add them.
+
+ The dev_attrs list will go away after all in-kernel users are converted
+ to use dev_groups.
+
+ Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+ Tested-by: Guenter Roeck <linux@roeck-us.net>
+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+*/
+
+@ attribute_group @
+identifier group;
+declarer name ATTRIBUTE_GROUPS;
+@@
+
+ATTRIBUTE_GROUPS(group);
+
+@script:python attribute_groups_name@
+group << attribute_group.group;
+groups;
+@@
+coccinelle.groups = group + "_groups"
+
+@ class_group @
+identifier group_class;
+identifier attribute_groups_name.groups;
+fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
+@@
+
+struct class group_class = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ .dev_groups = groups,
++#else
++ .dev_attrs = group_dev_attr,
++#endif
+};
+
+@ attribute_group_mod depends on class_group @
+declarer name ATTRIBUTE_GROUPS_BACKPORT;
+identifier attribute_group.group;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ATTRIBUTE_GROUPS(group);
++#else
++#define BP_ATTR_GRP_STRUCT device_attribute
++ATTRIBUTE_GROUPS_BACKPORT(group);
++#endif
+
+@ class_registering @
+identifier class_register, ret;
+identifier class_group.group_class;
+fresh identifier group_class_init = "init_" ## attribute_group.group ## "_attrs";
+@@
+
+(
++ group_class_init();
+ return class_register(&group_class);
+|
++ group_class_init();
+ ret = class_register(&group_class);
+)
--- /dev/null
+/*
+The new attribute sysfs group was added onto struct bus_type via
+commit fa6fdb33b
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains fa6fdb33b
+v3.12-rc1~184^2~89
+
+This backport makes use of the helpers to backport this more efficiently.
+Refer to the INFO file for documentation there on that.
+
+commit fa6fdb33b486a8afc5439c504da8d581e142c77d
+Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Thu Aug 8 15:22:55 2013 -0700
+
+ driver core: bus_type: add dev_groups
+
+ attribute groups are much more flexible than just a list of attributes,
+ due to their support for visibility of the attributes, and binary
+ attributes. Add dev_groups to struct bus_type which should be used
+ instead of dev_attrs.
+
+ dev_attrs will be removed from the structure soon.
+
+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+*/
+
+@ attribute_group @
+identifier group;
+declarer name ATTRIBUTE_GROUPS;
+@@
+
+ATTRIBUTE_GROUPS(group);
+
+@script:python attribute_groups_name@
+group << attribute_group.group;
+groups;
+@@
+coccinelle.groups = group + "_groups"
+
+@ bus_group @
+identifier group_bus;
+identifier attribute_groups_name.groups;
+fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
+@@
+
+struct bus_type group_bus = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ .dev_groups = groups,
++#else
++ .dev_attrs = group_dev_attr,
++#endif
+};
+
+@ attribute_group_mod depends on bus_group @
+declarer name ATTRIBUTE_GROUPS_BACKPORT;
+identifier attribute_group.group;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ATTRIBUTE_GROUPS(group);
++#else
++#define BP_ATTR_GRP_STRUCT device_attribute
++ATTRIBUTE_GROUPS_BACKPORT(group);
++#endif
+
+@ bus_registering @
+identifier bus_register, ret;
+identifier bus_group.group_bus;
+fresh identifier group_bus_init = "init_" ## attribute_group.group ## "_attrs";
+@@
+
+(
++ group_bus_init();
+ return bus_register(&group_bus);
+|
++ group_bus_init();
+ ret = bus_register(&group_bus);
+)
--- /dev/null
+/* see upstream commit ced6473e74867 */
+
+@ attribute_group @
+identifier group;
+declarer name ATTRIBUTE_GROUPS;
+@@
+
+ATTRIBUTE_GROUPS(group);
+
+@script:python attribute_groups_name@
+group << attribute_group.group;
+groups;
+@@
+coccinelle.groups = group + "_groups"
+
+@ class_group @
+identifier group_class;
+identifier attribute_groups_name.groups;
+fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
+@@
+
+struct class group_class = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
+ .class_groups = groups,
++#else
++ .class_attrs = group_dev_attr,
++#endif
+};
+
+@ attribute_group_mod depends on class_group @
+declarer name ATTRIBUTE_GROUPS_BACKPORT;
+identifier attribute_group.group;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
+ATTRIBUTE_GROUPS(group);
++#else
++#define BP_ATTR_GRP_STRUCT class_attribute
++ATTRIBUTE_GROUPS_BACKPORT(group);
++#endif
+
+@ class_registering @
+identifier class_register, ret;
+identifier class_group.group_class;
+fresh identifier group_class_init = "init_" ## attribute_group.group ## "_attrs";
+@@
+
+(
++ group_class_init();
+ return class_register(&group_class);
+|
++ group_class_init();
+ ret = class_register(&group_class);
+)
--- /dev/null
+The new attribute sysfs group was added via these commits:
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains f2f37f58b
+v3.11-rc2~18^2~9
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 3493f69f4
+v3.11-rc2~18^2~2
+
+We backport them with our own respective set of helpers. Each new data
+structure that gets an attribute group needs a respective SmPL set of
+rules for the transformation. We might be able to share the rules for
+lookup / indexing between rules some how. These lookup reveal would
+be used for inherent structural searches, pivots, if you will.
+
+The changes that added the new APIs:
+
+commit f2f37f58b1b933b06d6d84e80a31a1b500fb0db2
+Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Sun Jul 14 16:05:52 2013 -0700
+
+ sysfs.h: add ATTRIBUTE_GROUPS() macro
+
+ To make it easier for driver subsystems to work with attribute groups,
+ create the ATTRIBUTE_GROUPS macro to remove some of the repetitive
+ typing for the most common use for attribute groups.
+
+ Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+ Tested-by: Guenter Roeck <linux@roeck-us.net>
+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+commit 3493f69f4c4e8703961919a9a56c2d2e6a25b46f
+Author: Oliver Schinagl <oliver@schinagl.nl>
+Date: Sun Jul 14 16:05:59 2013 -0700
+
+ sysfs: add more helper macro's for (bin_)attribute(_groups)
+
+ With the recent changes to sysfs there's various helper macro's.
+ However there's no RW, RO BIN_ helper macro's. This patch adds them.
+
+ Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
--- /dev/null
+@@
+struct netlink_notify *notify;
+@@
+-notify->portid
++netlink_notify_portid(notify)
+
+@@
+struct genl_info *info;
+@@
+-info->snd_portid
++genl_info_snd_portid(info)
+
+@@
+expression skb;
+@@
+-NETLINK_CB(skb).portid
++NETLINK_CB_PORTID(skb)
--- /dev/null
+Commit c60520fa needs to be reverted for older kernels because
+although we can backport some new DMA changes some other
+larger changes ended up extending some core dma data
+structures, for details see bca0fa5f as an example. We're
+aided with this revert by having added vb2_mmap_pfn_range() to
+compat. The main reason to revert is usage of the new
+dma_mmap_coherent() and core changes required via
+bca0fa5f.
+
+commit c60520fa50cd86d64bc8ebb34300ddc4ca91393d
+Author: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Thu Jun 14 11:32:21 2012 -0300
+
+ [media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
+
+ Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes
+ vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent
+ Pinchart. The function is no longer used in vb2 code.
+
+ Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+ Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
+ Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
+ Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
+
+--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
++++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
+@@ -177,6 +177,52 @@ static void *vb2_dc_alloc(void *alloc_ct
+ return buf;
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
++static int
++backport_vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
++ unsigned long size,
++ const struct vm_operations_struct *vm_ops,
++ void *priv)
++{
++ int ret;
++
++ size = min_t(unsigned long, vma->vm_end - vma->vm_start, size);
++
++ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
++ ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT,
++ size, vma->vm_page_prot);
++ if (ret) {
++ printk(KERN_ERR "Remapping memory failed, error: %d\n", ret);
++ return ret;
++ }
++
++ vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
++ vma->vm_private_data = priv;
++ vma->vm_ops = vm_ops;
++
++ vma->vm_ops->open(vma);
++
++ pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n",
++ __func__, paddr, vma->vm_start, size);
++
++ return 0;
++}
++
++static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
++{
++ struct vb2_dc_buf *buf = buf_priv;
++
++ if (!buf) {
++ printk(KERN_ERR "No buffer to map\n");
++ return -EINVAL;
++ }
++
++ return backport_vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,
++ &vb2_common_vm_ops, &buf->handler);
++}
++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
++#else
+ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
+ {
+ struct vb2_dc_buf *buf = buf_priv;
+@@ -213,6 +259,7 @@ static int vb2_dc_mmap(void *buf_priv, s
+
+ return 0;
+ }
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
+
+ /*********************************************/
+ /* DMABUF ops for exporters */
--- /dev/null
+On older kernels, we can't do this workaround, so if you use
+an old 64-bit kernel with compat you'd better upgrade.
+
+For more details of this work around refer to this commit
+upstream that deals with the code added:
+
+commit 645e77def93f1dd0e211c7244fbe152dac8a7100
+Author: Johannes Berg <johannes.berg@intel.com>
+Date: Fri Mar 1 14:03:49 2013 +0100
+
+ nl80211: increase wiphy dump size dynamically
+
+ Given a device with many channels capabilities the wiphy
+ information can still overflow even though its size in
+ 3.9 was reduced to 3.8 levels. For new userspace and
+ kernel 3.10 we're going to implement a new "split dump"
+ protocol that can use multiple messages per wiphy.
+
+ For now though, add a workaround to be able to send more
+ information to userspace. Since generic netlink doesn't
+ have a way to set the minimum dump size globally, and we
+ wouldn't really want to set it globally anyway, increase
+ the size only when needed, as described in the comments.
+ As userspace might not be prepared for large buffers, we
+ can only use 4k.
+
+ Also increase the size for the get_wiphy command.
+
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -1846,6 +1846,7 @@ static int nl80211_dump_wiphy(struct sk_
+ cb->nlh->nlmsg_seq,
+ NLM_F_MULTI, state);
+ if (ret < 0) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ /*
+ * If sending the wiphy data didn't fit (ENOBUFS
+ * or EMSGSIZE returned), this SKB is still
+@@ -1867,6 +1868,7 @@ static int nl80211_dump_wiphy(struct sk_
+ rtnl_unlock();
+ return 1;
+ }
++#endif
+ idx--;
+ break;
+ }
--- /dev/null
+/* convert gpio: change member .dev to .parent
+ *
+ * add semantic patch which uses the dev member of struct gpio_chip on
+ * kenrel version < 4.5 This change was done in upstream kernel commit
+ * 58383c78 "gpio: change member .dev to .parent".
+ */
+
+@r1@
+struct gpio_chip *chip;
+expression E1;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
+ chip->parent = E1;
++#else
++chip->dev = E1;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) */
+@r2@
+struct gpio_chip chip;
+expression E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
+ chip.parent = E2;
++#else
++chip.dev = E2;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) */
--- /dev/null
+This is a tricky one.
+
+Consider a kernel that has this code in net/wireless/wext-core.c:
+
+#ifdef CONFIG_CFG80211_WEXT
+ if (dev->ieee80211_ptr && dev->ieee80211_ptr->wiphy)
+ handlers = dev->ieee80211_ptr->wiphy->wext;
+#endif
+#ifdef CONFIG_WIRELESS_EXT
+ if (dev->wireless_handlers)
+ handlers = dev->wireless_handlers;
+#endif
+
+If a kernel is compiled without CONFIG_WIRELESS_EXT then
+compat-drivers can't do wireless extensions against it.
+However, if the kernel is compiled with CONFIG_CFG80211_WEXT
+then it will try to get the wext handlers from struct wiphy.
+
+Now, struct wiphy in the base kernel and struct wiphy in
+compat-drivers don't match, so the kernel crashes!!
+
+To fix this, add lots of padding to compat-drivers's
+struct wiphy so that the "wext" pointer is guaranteed
+to be NULL.
+
+Make sure the padding is larger than the struct so we
+don't ever run into this again because the wext pointer
+moved due to struct enlargements.
+
+
--- /dev/null
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -3222,6 +3222,9 @@ struct wiphy_vendor_command {
+ struct wiphy {
+ /* assign these fields before you register the wiphy */
+
++#define WIPHY_COMPAT_PAD_SIZE 2048
++ u8 padding[WIPHY_COMPAT_PAD_SIZE];
++
+ /* permanent MAC address(es) */
+ u8 perm_addr[ETH_ALEN];
+ u8 addr_mask[ETH_ALEN];
--- /dev/null
+--- a/net/wireless/core.c
++++ b/net/wireless/core.c
+@@ -344,6 +344,17 @@ struct wiphy *wiphy_new_nm(const struct
+ struct cfg80211_registered_device *rdev;
+ int alloc_size;
+
++ /*
++ * Make sure the padding is >= the rest of the struct so that we
++ * always keep it large enough to pad out the entire original
++ * kernel's struct. We really only need to make sure it's larger
++ * than the kernel compat is compiled against, but since it'll
++ * only increase in size make sure it's larger than the current
++ * version of it. Subtract since it's included.
++ */
++ BUILD_BUG_ON(WIPHY_COMPAT_PAD_SIZE <
++ sizeof(struct wiphy) - WIPHY_COMPAT_PAD_SIZE);
++
+ WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
+ WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
+ WARN_ON(ops->connect && !ops->disconnect);
--- /dev/null
+There's no way to build wireless extensions out of tree
+so remove the Kconfig options for them.
+
+--- a/net/wireless/Kconfig
++++ b/net/wireless/Kconfig
+@@ -1,21 +1,3 @@
+-config WIRELESS_EXT
+- bool
+-
+-config WEXT_CORE
+- def_bool y
+- depends on CFG80211_WEXT || WIRELESS_EXT
+-
+-config WEXT_PROC
+- def_bool y
+- depends on PROC_FS
+- depends on WEXT_CORE
+-
+-config WEXT_SPY
+- bool
+-
+-config WEXT_PRIV
+- bool
+-
+ config CFG80211
+ tristate "cfg80211 - wireless configuration API"
+ depends on RFKILL || !RFKILL
+@@ -174,7 +156,7 @@ config CFG80211_CRDA_SUPPORT
+ config CFG80211_WEXT
+ bool "cfg80211 wireless extensions compatibility" if !CFG80211_WEXT_EXPORT
+ depends on CFG80211
+- select WEXT_CORE
++ depends on WEXT_CORE
+ default y if CFG80211_WEXT_EXPORT
+ help
+ Enable this option if you need old userspace for wireless
--- /dev/null
+--- a/drivers/net/usb/Makefile
++++ b/drivers/net/usb/Makefile
+@@ -10,7 +10,6 @@ obj-$(CONFIG_USB_RTL8152) += r8152.o
+ obj-$(CONFIG_USB_HSO) += hso.o
+ obj-$(CONFIG_USB_LAN78XX) += lan78xx.o
+ obj-$(CONFIG_USB_NET_AX8817X) += asix.o
+-asix-y := asix_devices.o asix_common.o ax88172a.o
+ obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o
+ obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
+ obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o
--- /dev/null
+This is required unless we add some macro wrappers for this
+type of static work upstream but not sure if that is a good
+idea yet.
+
+--- a/net/ieee802154/reassembly.c
++++ b/net/ieee802154/reassembly.c
+@@ -97,7 +97,11 @@ static void lowpan_frag_expire(unsigned
+ struct net *net;
+
+ fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
++#else
++ net = &init_net;
++#endif
+
+ spin_lock(&fq->q.lock);
+
+@@ -395,24 +399,44 @@ static int zero;
+ static struct ctl_table lowpan_frags_ns_ctl_table[] = {
+ {
+ .procname = "6lowpanfrag_high_thresh",
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ .data = &init_net.ieee802154_lowpan.frags.high_thresh,
++#else
++ .data = &ieee802154_lowpan.frags.high_thresh,
++#endif
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ .extra1 = &init_net.ieee802154_lowpan.frags.low_thresh
++#else
++ .extra1 = &ieee802154_lowpan.frags.low_thresh
++#endif
+ },
+ {
+ .procname = "6lowpanfrag_low_thresh",
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ .data = &init_net.ieee802154_lowpan.frags.low_thresh,
++#else
++ .data = &ieee802154_lowpan.frags.low_thresh,
++#endif
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = &zero,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ .extra2 = &init_net.ieee802154_lowpan.frags.high_thresh
++#else
++ .extra2 = &ieee802154_lowpan.frags.high_thresh
++#endif
+ },
+ {
+ .procname = "6lowpanfrag_time",
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
+ .data = &init_net.ieee802154_lowpan.frags.timeout,
++#else
++ .data = &ieee802154_lowpan.frags.timeout,
++#endif
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_jiffies,
--- /dev/null
+Domain specific backport for inet_frag_lru_move()
+This requires two parts, the data structure changes
+and then domain specific inet_frag_lru_move() define.
+
+--- a/net/ieee802154/reassembly.c
++++ b/net/ieee802154/reassembly.c
+@@ -89,6 +89,9 @@ static void lowpan_frag_init(struct inet
+ fq->d_size = arg->d_size;
+ fq->saddr = *arg->src;
+ fq->daddr = *arg->dst;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
++ spin_lock_init(&fq->lru_lock);
++#endif
+ }
+
+ static void lowpan_frag_expire(unsigned long data)
+--- a/net/ieee802154/reassembly.h
++++ b/net/ieee802154/reassembly.h
+@@ -2,6 +2,7 @@
+ #define __IEEE802154_6LOWPAN_REASSEMBLY_H__
+
+ #include <net/inet_frag.h>
++#include <linux/spinlock.h>
+
+ struct lowpan_create_arg {
+ u16 tag;
+@@ -19,8 +20,32 @@ struct lowpan_frag_queue {
+ u16 d_size;
+ struct ieee802154_addr saddr;
+ struct ieee802154_addr daddr;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
++ spinlock_t lru_lock;
++#endif
+ };
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
++/*
++ * XXX: this is a *domain* specific inet_frag_lru_move backport,
++ * note the added lowpan_ prefix, this requires a respective patch
++ * which extends struct lowpan_frag_queue with an lru_lock and
++ * initializes it. We add this helper here to reduce the backport.
++ * There is no way to generalize the other changes in the patch.
++ */
++#define inet_frag_lru_move LINUX_BACKPORT(lowpan_inet_frag_lru_move)
++static inline void inet_frag_lru_move(struct inet_frag_queue *q)
++{
++ struct lowpan_frag_queue *fq;
++
++ fq = container_of(q, struct lowpan_frag_queue, q);
++
++ spin_lock(&fq->lru_lock);
++ list_move_tail(&q->lru_list, &q->net->lru_list);
++ spin_unlock(&fq->lru_lock);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) */
++
+ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
+ {
+ switch (a->mode) {
--- /dev/null
+network namespaces didn't get usernamespaces pegged until 3.8
+via commit 038e7332b8.
+
+--- a/net/ieee802154/reassembly.c
++++ b/net/ieee802154/reassembly.c
+@@ -481,9 +481,11 @@ static int __net_init lowpan_frags_ns_sy
+ table[1].extra2 = &ieee802154_lowpan->frags.high_thresh;
+ table[2].data = &ieee802154_lowpan->frags.timeout;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+ /* Don't export sysctls to unprivileged users */
+ if (net->user_ns != &init_user_ns)
+ table[0].procname = NULL;
++#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,8,0) */
+ }
+
+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
--- /dev/null
+The patch "wext: refactor" by Johannes Berg refactored
+wext code so that new kernels no longer get the wext
+handlers through struct netdevice, instead they get
+it through the struct wiphy which is cfg80211 specific.
+
+For old kernels this means you get not wext handlers
+anymore when backporting code, this adds the wext handler
+back to the netdevice wireless_handlers to let compat
+users use wext again.
+
+We do this for every kernel version because the struct wiphy
+is changing from kernel version to version. At least the
+struct from kernel 2.6.33 and 2.6.34 are incompatible and
+the kernel would dereference some wrong type in the struct
+and oops. The old interface is not affected by this. This
+will cause that CONFIG_CFG80211_WEXT still depends on
+CONFIG_WIRELESS_EXT in compat-drivers.
+
--- /dev/null
+--- a/net/wireless/core.c
++++ b/net/wireless/core.c
+@@ -433,10 +433,6 @@ use_default_name:
+ INIT_WORK(&rdev->mlme_unreg_wk, cfg80211_mlme_unreg_wk);
+ INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
+ cfg80211_dfs_channels_update_work);
+-#ifdef CONFIG_CFG80211_WEXT
+- rdev->wiphy.wext = &cfg80211_wext_handler;
+-#endif
+-
+ device_initialize(&rdev->wiphy.dev);
+ rdev->wiphy.dev.class = &ieee80211_class;
+ rdev->wiphy.dev.platform_data = rdev;
+@@ -1043,6 +1039,15 @@ static int cfg80211_netdev_notifier_call
+ }
+ wdev->netdev = dev;
+ #ifdef CONFIG_CFG80211_WEXT
++#ifdef CONFIG_WIRELESS_EXT
++ if (!dev->wireless_handlers)
++ dev->wireless_handlers = &cfg80211_wext_handler;
++#else
++ printk_once(KERN_WARNING "cfg80211: wext will not work because "
++ "kernel was compiled with CONFIG_WIRELESS_EXT=n. "
++ "Tools using wext interface, like iwconfig will "
++ "not work.\n");
++#endif
+ wdev->wext.default_key = -1;
+ wdev->wext.default_mgmt_key = -1;
+ wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
--- /dev/null
+Some quirks require base kernel updates, these are work
+around for kernels that would not have these quirks.
--- /dev/null
+--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
++++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+@@ -253,6 +253,12 @@ static size_t cw1200_sdio_align_size(str
+ else
+ size = sdio_align_size(self->func, size);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
++ /* A quirk to handle this was committed in 3.2-rc */
++ if (size == SDIO_BLOCK_SIZE)
++ size += SDIO_BLOCK_SIZE; /* HW bug; force use of block mode */
++#endif
++
+ return size;
+ }
+
--- /dev/null
+--- a/net/6lowpan/core.c
++++ b/net/6lowpan/core.c
+@@ -14,6 +14,7 @@
+ #include <linux/module.h>
+
+ #include <net/6lowpan.h>
++#include <linux/if_arp.h>
+
+ #include "6lowpan_i.h"
+
--- /dev/null
+--- a/drivers/net/wireless/ath/ath10k/htt.h
++++ b/drivers/net/wireless/ath/ath10k/htt.h
+@@ -19,6 +19,7 @@
+ #define _HTT_H_
+
+ #include <linux/bug.h>
++#include <linux/idr.h>
+ #include <linux/interrupt.h>
+ #include <linux/dmapool.h>
+ #include <linux/hashtable.h>
--- /dev/null
+--- a/net/bluetooth/6lowpan.c
++++ b/net/bluetooth/6lowpan.c
+@@ -18,6 +18,7 @@
+ #include <linux/debugfs.h>
+
+ #include <net/ipv6.h>
++#include <net/ip6_fib.h>
+ #include <net/ip6_route.h>
+ #include <net/addrconf.h>
+
--- /dev/null
+--- a/include/net/cfg802154.h
++++ b/include/net/cfg802154.h
+@@ -26,6 +26,7 @@
+
+ struct wpan_phy;
+ struct wpan_phy_cca;
++struct wpan_dev;
+
+ #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
+ struct ieee802154_llsec_device_key;
--- /dev/null
+--- a/compat/mm-frame_vector.c
++++ b/compat/mm-frame_vector.c
+@@ -6,6 +6,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/pagemap.h>
+ #include <linux/sched.h>
++#include <linux/export.h>
+
+ /**
+ * get_vaddr_frames() - map virtual addresses to pfns
--- /dev/null
+diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
+index 55a1405c..1409e20 100644
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -34,6 +34,7 @@
+ #include <linux/slab.h>
+ #include <net/checksum.h>
+ #include <net/ip6_checksum.h>
++#include <net/ipv6.h>
+ #include <linux/net_tstamp.h>
+ #include <linux/mii.h>
+ #include <linux/ethtool.h>
--- /dev/null
+--- a/drivers/nfc/mei_phy.c
++++ b/drivers/nfc/mei_phy.c
+@@ -19,6 +19,7 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/module.h>
++#include <linux/sched.h>
+ #include <linux/slab.h>
+ #include <linux/nfc.h>
+
--- /dev/null
+--- a/net/wireless/Makefile
++++ b/net/wireless/Makefile
+@@ -20,6 +20,6 @@ CFLAGS_trace.o := -I$(src)
+ ccflags-y += -D__CHECK_ENDIAN__
+
+ $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk
+- @$(AWK) -f $(srctree)/$(src)/genregdb.awk < $< > $@
++ @$(AWK) -f $(src)/genregdb.awk < $< > $@
+
+ clean-files := regdb.c
--- /dev/null
+--- a/drivers/nfc/st-nci/spi.c
++++ b/drivers/nfc/st-nci/spi.c
+@@ -21,6 +21,7 @@
+ #include <linux/spi/spi.h>
+ #include <linux/gpio.h>
+ #include <linux/gpio/consumer.h>
++#include <linux/of.h>
+ #include <linux/of_irq.h>
+ #include <linux/of_gpio.h>
+ #include <linux/acpi.h>
--- /dev/null
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -6955,7 +6955,9 @@ static int nl80211_dump_scan(struct sk_b
+ spin_lock_bh(&rdev->bss_lock);
+ cfg80211_bss_expire(rdev);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+ cb->seq = rdev->bss_generation;
++#endif
+
+ list_for_each_entry(scan, &rdev->bss_list, list) {
+ if (++idx <= start)
--- /dev/null
+--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
++++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+@@ -175,7 +175,11 @@ that only one external action is invoked
+ #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"
+ #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
++static struct pm_qos_request_list ipw2100_pm_qos_req;
++#else
+ static struct pm_qos_request ipw2100_pm_qos_req;
++#endif
+
+ /* Debugging stuff */
+ #ifdef CONFIG_IPW2100_DEBUG
--- /dev/null
+This section of the libertas driver calls functions that simply don't
+exist before the release of 3.1. This code in question was an addition,
+not a change from any existing code. It is safe to simply remove it for
+older kernels.
+
--- /dev/null
+--- a/drivers/net/wireless/marvell/libertas/if_usb.c
++++ b/drivers/net/wireless/marvell/libertas/if_usb.c
+@@ -960,6 +960,7 @@ static int if_usb_suspend(struct usb_int
+ goto out;
+ }
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+ #ifdef CONFIG_OLPC
+ if (machine_is_olpc()) {
+ if (priv->wol_criteria == EHS_REMOVE_WAKEUP)
+@@ -968,6 +969,7 @@ static int if_usb_suspend(struct usb_int
+ olpc_ec_wakeup_set(EC_SCI_SRC_WLAN);
+ }
+ #endif
++#endif
+
+ ret = lbs_suspend(priv);
+ if (ret)
--- /dev/null
+Linux 3.5 will have get_ts_info to support the Precision Time Protocol.
+
+http://linuxptp.sourceforge.net/
+http://en.wikipedia.org/wiki/Precision_Time_Protocol
+
+We cannot backport this support given that this introduces
+a data structure change on the ethtool_ops.
+
+commit c8f3a8c31069137fe0100e6920558f1a7487ef3c
+Author: Richard Cochran <richardcochran@gmail.com>
+Date: Tue Apr 3 22:59:17 2012 +0000
+
+ ethtool: Introduce a method for getting time stamping capabilities.
+
+ This commit adds a new ethtool ioctl that exposes the SO_TIMESTAMPING
+ capabilities of a network interface. In addition, user space programs
+ can use this ioctl to discover the PTP Hardware Clock (PHC) device
+ associated with the interface.
+
+ Since software receive time stamps are handled by the stack, the generic
+ ethtool code can answer the query correctly in case the MAC or PHY
+ drivers lack special time stamping features.
+
+ Signed-off-by: Richard Cochran <richardcochran@gmail.com>
+ Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
+ Signed-off-by: David S. Miller <davem@davemloft.net>
+
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct ethtool_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+.get_ts_info = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
--- /dev/null
+In recent kernels, %pV will copy the va_list before using it.
+This isn't true for all kernels, so copy the va_list for use
+by the dev_*() functions, otherwise the kernel will crash if
+the message is printed and traced.
+
+This is required for kernels <= 3.1, as otherwise it would
+those kernels would crash.
--- /dev/null
+--- a/drivers/net/wireless/intel/iwlwifi/iwl-debug.c
++++ b/drivers/net/wireless/intel/iwlwifi/iwl-debug.c
+@@ -74,13 +74,16 @@ void __iwl_ ##fn(struct device *dev, con
+ struct va_format vaf = { \
+ .fmt = fmt, \
+ }; \
+- va_list args; \
++ va_list args1, args2; \
+ \
+- va_start(args, fmt); \
+- vaf.va = &args; \
++ va_start(args1, fmt); \
++ va_copy(args2, args1); \
++ vaf.va = &args2; \
+ dev_ ##fn(dev, "%pV", &vaf); \
++ va_end(args2); \
++ vaf.va = &args1; \
+ trace_iwlwifi_ ##fn(&vaf); \
+- va_end(args); \
++ va_end(args1); \
+ }
+
+ __iwl_fn(warn)
+@@ -99,13 +102,18 @@ void __iwl_err(struct device *dev, bool
+ va_list args;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+ if (!trace_only) {
++ va_list args2;
++
++ va_copy(args2, args);
++ vaf.va = &args2;
+ if (rfkill_prefix)
+ dev_err(dev, "(RFKILL) %pV", &vaf);
+ else
+ dev_err(dev, "%pV", &vaf);
++ va_end(args2);
+ }
++ vaf.va = &args;
+ trace_iwlwifi_err(&vaf);
+ va_end(args);
+ }
+@@ -122,13 +130,19 @@ void __iwl_dbg(struct device *dev,
+ va_list args;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+ #ifdef CONFIG_IWLWIFI_DEBUG
+ if (iwl_have_debug_level(level) &&
+- (!limit || net_ratelimit()))
++ (!limit || net_ratelimit())) {
++ va_list args2;
++
++ va_copy(args2, args);
++ vaf.va = &args2;
+ dev_printk(KERN_DEBUG, dev, "%c %s %pV",
+ in_interrupt() ? 'I' : 'U', function, &vaf);
++ va_end(args2);
++ }
+ #endif
++ vaf.va = &args;
+ trace_iwlwifi_dbg(level, in_interrupt(), function, &vaf);
+ va_end(args);
+ }
--- /dev/null
+--- a/net/mac80211/trace.c
++++ b/net/mac80211/trace.c
+@@ -16,12 +16,16 @@ void __sdata_info(const char *fmt, ...)
+ struct va_format vaf = {
+ .fmt = fmt,
+ };
+- va_list args;
++ va_list args, args2;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+
++ va_copy(args2, args);
++ vaf.va = &args2;
+ pr_info("%pV", &vaf);
++ va_end(args2);
++
++ vaf.va = &args;
+ trace_mac80211_info(&vaf);
+ va_end(args);
+ }
+@@ -34,10 +38,16 @@ void __sdata_dbg(bool print, const char
+ va_list args;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+
+- if (print)
++ if (print) {
++ va_list args2;
++
++ va_copy(args2, args);
++ vaf.va = &args2;
+ pr_debug("%pV", &vaf);
++ va_end(args2);
++ }
++ vaf.va = &args;
+ trace_mac80211_dbg(&vaf);
+ va_end(args);
+ }
+@@ -47,12 +57,16 @@ void __sdata_err(const char *fmt, ...)
+ struct va_format vaf = {
+ .fmt = fmt,
+ };
+- va_list args;
++ va_list args, args2;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+
++ va_copy(args2, args);
++ vaf.va = &args2;
+ pr_err("%pV", &vaf);
++ va_end(args2);
++
++ vaf.va = &args;
+ trace_mac80211_err(&vaf);
+ va_end(args);
+ }
+@@ -65,10 +79,16 @@ void __wiphy_dbg(struct wiphy *wiphy, bo
+ va_list args;
+
+ va_start(args, fmt);
+- vaf.va = &args;
+
+- if (print)
+- wiphy_dbg(wiphy, "%pV", &vaf);
++ if (print) {
++ va_list args2;
++
++ va_copy(args2, args);
++ vaf.va = &args2;
++ pr_debug("%pV", &vaf);
++ va_end(args2);
++ }
++ vaf.va = &args;
+ trace_mac80211_dbg(&vaf);
+ va_end(args);
+ }
--- /dev/null
+@@
+identifier backport_driver;
+@@
+struct usb_driver backport_driver = {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+ .disable_hub_initiated_lpm = 1,
++#endif
+...
+};
--- /dev/null
+This patch requires a manual backport:
+
+commit adc8d746caa67fff4b53ba3e5163a6cbacc3b523
+Author: Alan Cox <alan@linux.intel.com>
+Date: Sat Jul 14 15:31:47 2012 +0100
+
+ tty: move the termios object into the tty
+
+ This will let us sort out a whole pile of tty related races. The
+ alternative would be to keep points and refcount the termios objects.
+ However
+ 1. They are tiny anyway
+ 2. Many devices don't use the stored copies
+ 3. We can remove a pty special case
+
+ Signed-off-by: Alan Cox <alan@linux.intel.com>
+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+We cannot use compat.git for this given that the assignment
+was not done through a static inline helper.
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains adc8d746caa67fff4b53ba3e5163a6cbacc3b523
+v3.7-rc1~172^2~187
--- /dev/null
+--- a/drivers/bluetooth/hci_ldisc.c
++++ b/drivers/bluetooth/hci_ldisc.c
+@@ -24,6 +24,7 @@
+ */
+
+ #include <linux/module.h>
++#include <linux/version.h>
+
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -269,7 +270,11 @@ void hci_uart_set_flow_control(struct hc
+
+ if (enable) {
+ /* Disable hardware flow control */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+ ktermios = tty->termios;
++#else
++ ktermios = *tty->termios;
++#endif
+ ktermios.c_cflag &= ~CRTSCTS;
+ status = tty_set_termios(tty, &ktermios);
+ BT_DBG("Disabling hardware flow control: %s",
+@@ -303,7 +308,11 @@ void hci_uart_set_flow_control(struct hc
+ BT_DBG("Setting RTS: %s", status ? "failed" : "success");
+
+ /* Re-enable hardware flow control */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+ ktermios = tty->termios;
++#else
++ ktermios = *tty->termios;
++#endif
+ ktermios.c_cflag |= CRTSCTS;
+ status = tty_set_termios(tty, &ktermios);
+ BT_DBG("Enabling hardware flow control: %s",
+@@ -324,7 +333,11 @@ void hci_uart_init_tty(struct hci_uart *
+ struct ktermios ktermios;
+
+ /* Bring the UART into a known 8 bits no parity hw fc state */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+ ktermios = tty->termios;
++#else
++ ktermios = *tty->termios;
++#endif
+ ktermios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
+ INLCR | IGNCR | ICRNL | IXON);
+ ktermios.c_oflag &= ~OPOST;
+@@ -342,7 +355,11 @@ void hci_uart_set_baudrate(struct hci_ua
+ struct tty_struct *tty = hu->tty;
+ struct ktermios ktermios;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+ ktermios = tty->termios;
++#else
++ ktermios = *tty->termios;
++#endif
+ ktermios.c_cflag &= ~CBAUD;
+ tty_termios_encode_baud_rate(&ktermios, speed, speed);
+
+@@ -350,7 +367,7 @@ void hci_uart_set_baudrate(struct hci_ua
+ tty_set_termios(tty, &ktermios);
+
+ BT_DBG("%s: New tty speeds: %d/%d", hu->hdev->name,
+- tty->termios.c_ispeed, tty->termios.c_ospeed);
++ ktermios.c_ispeed, ktermios.c_ospeed);
+ }
+
+ static int hci_uart_setup(struct hci_dev *hdev)
--- /dev/null
+--- a/net/bluetooth/rfcomm/tty.c
++++ b/net/bluetooth/rfcomm/tty.c
+@@ -869,7 +869,11 @@ static int rfcomm_tty_ioctl(struct tty_s
+
+ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
+ {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+ struct ktermios *new = &tty->termios;
++#else
++ struct ktermios *new = tty->termios;
++#endif
+ int old_baud_rate = tty_termios_baud_rate(old);
+ int new_baud_rate = tty_termios_baud_rate(new);
+
--- /dev/null
+--- a/drivers/net/wireless/ath/ath10k/spectral.c
++++ b/drivers/net/wireless/ath/ath10k/spectral.c
+@@ -477,7 +477,11 @@ static const struct file_operations fops
+
+ static struct dentry *create_buf_file_handler(const char *filename,
+ struct dentry *parent,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+ umode_t mode,
++#else
++ int mode,
++#endif
+ struct rchan_buf *buf,
+ int *is_global)
+ {
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/common-spectral.c
++++ b/drivers/net/wireless/ath/ath9k/common-spectral.c
+@@ -1042,7 +1042,11 @@ static const struct file_operations fops
+
+ static struct dentry *create_buf_file_handler(const char *filename,
+ struct dentry *parent,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+ umode_t mode,
++#else
++ int mode,
++#endif
+ struct rchan_buf *buf,
+ int *is_global)
+ {
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/spectral.c
++++ b/drivers/net/wireless/ath/ath9k/spectral.c
+@@ -478,7 +478,11 @@ static const struct file_operations fops
+
+ static struct dentry *create_buf_file_handler(const char *filename,
+ struct dentry *parent,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+ umode_t mode,
++#else
++ int mode,
++#endif
+ struct rchan_buf *buf,
+ int *is_global)
+ {
--- /dev/null
+For some reason the tracing on older kernels requires
+the tracing to be declared before it's defined; it's
+broken when the trace header is only included to create
+the tracepoints.
+
+Since new kernels don't, add patches for the two places
+that rely on the new behaviour.
+
+The kernel that requires this has not been identified...
--- /dev/null
+--- a/drivers/net/wireless/ath/ath6kl/trace.c
++++ b/drivers/net/wireless/ath/ath6kl/trace.c
+@@ -15,6 +15,9 @@
+ */
+
+ #include <linux/module.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++#include <linux/interrupt.h>
++#endif
+
+ #define CREATE_TRACE_POINTS
+ #include "trace.h"
--- /dev/null
+--- a/net/wireless/trace.c
++++ b/net/wireless/trace.c
+@@ -1,4 +1,7 @@
+ #include <linux/module.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++#include <linux/interrupt.h>
++#endif
+
+ #ifndef __CHECKER__
+ #define CREATE_TRACE_POINTS
--- /dev/null
+--- a/drivers/net/wireless/mediatek/mt7601u/trace.c
++++ b/drivers/net/wireless/mediatek/mt7601u/trace.c
+@@ -13,6 +13,9 @@
+ */
+
+ #include <linux/module.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
++#include <linux/interrupt.h>
++#endif
+
+ #ifndef __CHECKER__
+ #define CREATE_TRACE_POINTS
--- /dev/null
+--- a/drivers/net/wireless/ath/wil6210/trace.c
++++ b/drivers/net/wireless/ath/wil6210/trace.c
+@@ -15,6 +15,9 @@
+ */
+
+ #include <linux/module.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++#include <linux/interrupt.h>
++#endif
+
+ #define CREATE_TRACE_POINTS
+ #include "trace.h"
--- /dev/null
+backports: use old led api on old kernel versions.
+
+Usage of a new led api was introduced in mac80211, this patch make
+backports use the old api on older kernel versions. This could cause a
+problem with the led, the transmit led could stay on if nothing is
+transfered.
+
+This backports the following upstream commit:
+commit e47f2509e5f182f4df144406de6f2bc78179d57e
+Author: Fabio Baltieri <fabio.baltieri@gmail.com>
+Date: Thu Jul 25 12:00:26 2013 +0200
+
+ mac80211: use oneshot blink API for LED triggers
--- /dev/null
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -1255,6 +1255,7 @@ struct ieee80211_local {
+ struct mutex chanctx_mtx;
+
+ #ifdef CONFIG_MAC80211_LEDS
++ int tx_led_counter, rx_led_counter;
+ struct led_trigger tx_led, rx_led, assoc_led, radio_led;
+ struct led_trigger tpt_led;
+ atomic_t tx_led_active, rx_led_active, assoc_led_active;
+--- a/net/mac80211/led.h
++++ b/net/mac80211/led.h
+@@ -16,22 +16,36 @@
+ static inline void ieee80211_led_rx(struct ieee80211_local *local)
+ {
+ #ifdef CONFIG_MAC80211_LEDS
+- unsigned long led_delay = MAC80211_BLINK_DELAY;
++ unsigned long led_delay __maybe_unused = MAC80211_BLINK_DELAY;
+
+ if (!atomic_read(&local->rx_led_active))
+ return;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ led_trigger_blink_oneshot(&local->rx_led, &led_delay, &led_delay, 0);
++#else
++ if (local->rx_led_counter++ % 2 == 0)
++ led_trigger_event(&local->rx_led, LED_OFF);
++ else
++ led_trigger_event(&local->rx_led, LED_FULL);
++#endif
+ #endif
+ }
+
+ static inline void ieee80211_led_tx(struct ieee80211_local *local)
+ {
+ #ifdef CONFIG_MAC80211_LEDS
+- unsigned long led_delay = MAC80211_BLINK_DELAY;
++ unsigned long led_delay __maybe_unused = MAC80211_BLINK_DELAY;
+
+ if (!atomic_read(&local->tx_led_active))
+ return;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ led_trigger_blink_oneshot(&local->tx_led, &led_delay, &led_delay, 0);
++#else
++ if (local->tx_led_counter++ % 2 == 0)
++ led_trigger_event(&local->tx_led, LED_OFF);
++ else
++ led_trigger_event(&local->tx_led, LED_FULL);
++#endif
+ #endif
+ }
+
--- /dev/null
+backports: do not use DMA SG on old kernel versions
+
+the usb net driver now uses the dma sg api which is not available on
+old kernels, this patch removed the usage of the dma sg api for old
+kernel versions.
+
+This backports the following upstream commit:
+commit 638c5115a794981441246fa8fa5d95c1875af5ba
+Author: Ming Lei <ming.lei@canonical.com>
+Date: Thu Aug 8 21:48:24 2013 +0800
+
+ USBNET: support DMA SG
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 638c5115a794981441246fa8fa5d95c1875af5ba
+v3.12-rc1~186^2~110
+
+XXX: this patch seems odd, the kernel versoin used seems off.
--- /dev/null
+--- a/drivers/net/usb/usbnet.c
++++ b/drivers/net/usb/usbnet.c
+@@ -1270,6 +1270,7 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
+
+ /*-------------------------------------------------------------------------*/
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
+ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
+ {
+ unsigned num_sgs, total_len = 0;
+@@ -1302,6 +1303,12 @@ static int build_dma_sg(const struct sk_
+
+ return 1;
+ }
++#else
++static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
++{
++ return -ENXIO;
++}
++#endif
+
+ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
+ struct net_device *net)
+@@ -1358,12 +1365,19 @@ netdev_tx_t usbnet_start_xmit (struct sk
+ if (!(info->flags & FLAG_SEND_ZLP)) {
+ if (!(info->flags & FLAG_MULTI_PACKET)) {
+ length++;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
+ if (skb_tailroom(skb) && !urb->num_sgs) {
+ skb->data[skb->len] = 0;
+ __skb_put(skb, 1);
+ } else if (urb->num_sgs)
+ sg_set_buf(&urb->sg[urb->num_sgs++],
+ dev->padding_pkt, 1);
++#else
++ if (skb_tailroom(skb)) {
++ skb->data[skb->len] = 0;
++ __skb_put(skb, 1);
++ }
++#endif
+ }
+ } else
+ urb->transfer_flags |= URB_ZERO_PACKET;
+@@ -1430,7 +1444,9 @@ not_drop:
+ if (skb)
+ dev_kfree_skb_any (skb);
+ if (urb) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
+ kfree(urb->sg);
++#endif
+ usb_free_urb(urb);
+ }
+ } else
+@@ -1483,7 +1499,9 @@ static void usbnet_bh (unsigned long par
+ rx_process (dev, skb);
+ continue;
+ case tx_done:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
+ kfree(entry->urb->sg);
++#endif
+ case rx_cleanup:
+ usb_free_urb (entry->urb);
+ dev_kfree_skb (skb);
+@@ -1840,7 +1858,9 @@ int usbnet_resume (struct usb_interface
+ retval = usb_submit_urb(res, GFP_ATOMIC);
+ if (retval < 0) {
+ dev_kfree_skb_any(skb);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
+ kfree(res->sg);
++#endif
+ usb_free_urb(res);
+ usb_autopm_put_interface_async(dev->intf);
+ } else {
--- /dev/null
+We can not easily backport ipv6_stub which provides some IPv6 function
+callbacks.
+These patches are removing usage of ipv6_stub which was introduces in
+this commit:
+commit 5f81bd2e5d804ca93f3ec8873451b22d2f454721
+Author: Cong Wang <amwang@redhat.com>
+Date: Sat Aug 31 13:44:30 2013 +0800
+
+ ipv6: export a stub for IPv6 symbols used by vxlan
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 5f81bd2e5d804ca93f3ec8873451b22d2f454721
+v3.12-rc1~132^2~101
--- /dev/null
+--- a/drivers/net/usb/cdc_mbim.c
++++ b/drivers/net/usb/cdc_mbim.c
+@@ -301,6 +301,7 @@ error:
+ return NULL;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ /* Some devices are known to send Neigbor Solicitation messages and
+ * require Neigbor Advertisement replies. The IPv6 core will not
+ * respond since IFF_NOARP is set, so we must handle them ourselves.
+@@ -361,6 +362,7 @@ static bool is_neigh_solicit(u8 *buf, si
+ msg->icmph.icmp6_code == 0 &&
+ msg->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION);
+ }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
+
+
+ static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_t len, u16 tci)
+@@ -377,8 +379,10 @@ static struct sk_buff *cdc_mbim_process_
+ proto = htons(ETH_P_IP);
+ break;
+ case 0x60:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ if (is_neigh_solicit(buf, len))
+ do_neigh_solicit(dev, buf, tci);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
+ proto = htons(ETH_P_IPV6);
+ break;
+ default:
--- /dev/null
+Newer kernels make generic netlink ops and multicast groups
+const, but older can't have that. We therefore introduce
+__genl_const, which can be defined depending on the kernel.
+
+What kernel versions require this?
+
+XXX: try to SmPLify
+
+The struct genl_ops gave the *option* to make it const via:
+mcgrof@ergon ~/linux (git::master)$ git describe --contains f84f771d9
+v3.13-rc1~33^2~32^2~2
+
+The struct genl_multicast_group was *forced* to be const via:
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 2a94fe48f
+v3.13-rc1~33^2^2
--- /dev/null
+@@
+attribute __genl_const;
+@@
+(
+-const struct genl_multicast_group
++__genl_const struct genl_multicast_group
+|
+-const struct genl_ops
++__genl_const struct genl_ops
+)
--- /dev/null
+backports: adapt to changes in netdev select_queue call
+
+This patch reverts the changes done in the following commit for older
+kernel versions:
+commit f663dd9aaf9ed124f25f0f8452edf238f087ad50
+Author: Jason Wang <jasowang@redhat.com>
+Date: Fri Jan 10 16:18:26 2014 +0800
+
+ net: core: explicitly select a txq before doing l2 forwarding
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains f663dd9aaf9ed124f25f0f8452edf238f087ad50
+v3.13-rc8~4^2~2
--- /dev/null
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -1101,10 +1101,20 @@ static void ieee80211_uninit(struct net_
+ ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
++ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
+ static u16 ieee80211_netdev_select_queue(struct net_device *dev,
+ struct sk_buff *skb,
+ void *accel_priv,
+ select_queue_fallback_t fallback)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
++static u16 ieee80211_netdev_select_queue(struct net_device *dev,
++ struct sk_buff *skb,
++ void *accel_priv)
++#else
++static u16 ieee80211_netdev_select_queue(struct net_device *dev,
++ struct sk_buff *skb)
++#endif
+ {
+ return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
+ }
+@@ -1150,10 +1160,20 @@ static const struct net_device_ops ieee8
+ .ndo_get_stats64 = ieee80211_get_stats64,
+ };
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
++ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
+ static u16 ieee80211_monitor_select_queue(struct net_device *dev,
+ struct sk_buff *skb,
+ void *accel_priv,
+ select_queue_fallback_t fallback)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
++static u16 ieee80211_monitor_select_queue(struct net_device *dev,
++ struct sk_buff *skb,
++ void *accel_priv)
++#else
++static u16 ieee80211_monitor_select_queue(struct net_device *dev,
++ struct sk_buff *skb)
++#endif
+ {
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_local *local = sdata->local;
--- /dev/null
+--- a/drivers/net/wireless/marvell/mwifiex/main.c
++++ b/drivers/net/wireless/marvell/mwifiex/main.c
+@@ -1199,9 +1199,19 @@ static struct net_device_stats *mwifiex_
+ return &priv->stats;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
++ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
+ static u16
+ mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
+ void *accel_priv, select_queue_fallback_t fallback)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
++static u16
++mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
++ void *accel_priv)
++#else
++static u16
++mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb)
++#endif
+ {
+ skb->priority = cfg80211_classify8021d(skb, NULL);
+ return mwifiex_1d_to_wmm_queue[skb->priority];
--- /dev/null
+This is backported because of:
+
+commit cd4dc0821bc97947f25c8483a4aa0711bff8619a
+Author: Frank Praznik <frank.praznik@oh.rr.com>
+Date: Wed Jan 22 13:49:41 2014 -0500
+
+ HID: Add transport-driver callbacks to the hid_ll_driver struct
+
+ Add raw_request and output_report callbacks to the hid_ll_driver struct.
+
+ Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
+ Acked-by: David Herrmann <dh.herrmann@gmail.com>
+ Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+
+This did not make it to v3.14, so its only present on linux-next, its
+available for example on next-20140409
--- /dev/null
+--- a/net/bluetooth/hidp/core.c
++++ b/net/bluetooth/hidp/core.c
+@@ -224,6 +224,7 @@ static void hidp_input_report(struct hid
+ input_sync(dev);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ static int hidp_get_raw_report(struct hid_device *hid,
+ unsigned char report_number,
+ unsigned char *data, size_t count,
+@@ -396,6 +397,7 @@ static int hidp_raw_request(struct hid_d
+ return -EIO;
+ }
+ }
++#endif
+
+ static void hidp_idle_timeout(unsigned long arg)
+ {
+@@ -739,8 +741,10 @@ static struct hid_ll_driver hidp_hid_dri
+ .stop = hidp_stop,
+ .open = hidp_open,
+ .close = hidp_close,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ .raw_request = hidp_raw_request,
+ .output_report = hidp_output_report,
++#endif
+ };
+
+ /* This function sets up the hid device. It does not add it
--- /dev/null
+struct net_device got an extension with the member qdisc_tx_busylock
+as of commit 23d3b8bfb. For older kernels we need to ifdef around that
+as its now available.
+
+mcgrof@ergon ~/linux (git::master)$ git describe --contains 23d3b8bfb
+v3.7-rc1~145^2~208
+
+commit 23d3b8bfb8eb20e7d96afa09991e6a5ed1c83164
+Author: Eric Dumazet <edumazet@google.com>
+Date: Wed Sep 5 01:02:56 2012 +0000
+
+ net: qdisc busylock needs lockdep annotations
+
+ It seems we need to provide ability for stacked devices
+ to use specific lock_class_key for sch->busylock
+
+ We could instead default l2tpeth tx_queue_len to 0 (no qdisc), but
+ a user might use a qdisc anyway.
+
+ (So same fixes are probably needed on non LLTX stacked drivers)
+
+[ the commit log goes we only include up to here to help with context ]
--- /dev/null
+--- a/net/bluetooth/6lowpan.c
++++ b/net/bluetooth/6lowpan.c
+@@ -628,7 +628,9 @@ static netdev_tx_t bt_xmit(struct sk_buf
+ return err < 0 ? NET_XMIT_DROP : err;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ static struct lock_class_key bt_tx_busylock;
++#endif
+ static struct lock_class_key bt_netdev_xmit_lock_key;
+
+ static void bt_set_lockdep_class_one(struct net_device *dev,
+@@ -641,7 +643,9 @@ static void bt_set_lockdep_class_one(str
+ static int bt_dev_init(struct net_device *dev)
+ {
+ netdev_for_each_tx_queue(dev, bt_set_lockdep_class_one, NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ dev->qdisc_tx_busylock = &bt_tx_busylock;
++#endif
+
+ return 0;
+ }
--- /dev/null
+--- a/net/ieee802154/6lowpan_rtnl.c
++++ b/net/ieee802154/6lowpan_rtnl.c
+@@ -428,7 +428,9 @@ static struct header_ops lowpan_header_o
+ .create = lowpan_header_create,
+ };
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ static struct lock_class_key lowpan_tx_busylock;
++#endif
+ static struct lock_class_key lowpan_netdev_xmit_lock_key;
+
+ static void lowpan_set_lockdep_class_one(struct net_device *dev,
+@@ -442,7 +444,9 @@ static void lowpan_set_lockdep_class_one
+ static int lowpan_dev_init(struct net_device *dev)
+ {
+ netdev_for_each_tx_queue(dev, lowpan_set_lockdep_class_one, NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ dev->qdisc_tx_busylock = &lowpan_tx_busylock;
++#endif
+ return 0;
+ }
+
--- /dev/null
+/*
+Commit 676d2369 by David removed the skb->len arguments passed onto
+the struct sock sk_data_ready() callback. This was done as its racy,
+a few drivers were passing 0 to it, and it was not really used.
+By removing it the raciness is addresed but to backport this we are
+going to have to deal with the races as-is on older kernels. This was
+merged as of v3.15:
+
+mcgrof@ergon ~/linux-next (git::master)$ git describe --contains 676d2369
+v3.15-rc1~8^2~10
+
+Since this is not a define or static inline we can't easily replace this with
+the backports module or header files, instead we use SmPL grammar to generalize
+the backport for all use cases. Note that in order to backport this we won't
+know what older kernel drivers were using before this change, it could have
+been 0 or skb->len for the length parameter, since we have to infer something
+we choose skb->len *iff* skb_queue_tail() was used right before it, otherwise
+we infer to throw 0.
+
+commit 676d23690fb62b5d51ba5d659935e9f7d9da9f8e
+Author: David S. Miller <davem@davemloft.net>
+Date: Fri Apr 11 16:15:36 2014 -0400
+
+ net: Fix use after free by removing length arg from sk_data_ready callbacks.
+
+ Several spots in the kernel perform a sequence like:
+
+ skb_queue_tail(&sk->s_receive_queue, skb);
+ sk->sk_data_ready(sk, skb->len);
+
+ But at the moment we place the SKB onto the socket receive queue it
+ can be consumed and freed up. So this skb->len access is potentially
+ to freed up memory.
+
+ Furthermore, the skb->len can be modified by the consumer so it is
+ possible that the value isn't accurate.
+
+ And finally, no actual implementation of this callback actually uses
+ the length argument. And since nobody actually cared about it's
+ value, lots of call sites pass arbitrary values in such as '0' and
+ even '1'.
+
+ So just remove the length argument from the callback, that way there
+ is no confusion whatsoever and all of these use-after-free cases get
+ fixed as a side effect.
+
+ Based upon a patch by Eric Dumazet and his suggestion to audit this
+ issue tree-wide.
+
+ Signed-off-by: David S. Miller <davem@davemloft.net>
+*/
+
+@ sk_data_ready_assigned @
+expression E;
+identifier drv_data_ready;
+@@
+
+ E->sk_data_ready = drv_data_ready;
+
+@ sk_data_ready_declared depends on sk_data_ready_assigned @
+identifier sk;
+identifier sk_data_ready_assigned.drv_data_ready;
+fresh identifier backport_drv_data_ready = "backport_" ## drv_data_ready;
+@@
+
+drv_data_ready(struct sock *sk)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
++static void backport_drv_data_ready(struct sock *sk, int unused)
++{
++ drv_data_ready(sk);
++}
++#endif
+
+@ sk_data_ready_assigned_mod_e depends on sk_data_ready_assigned @
+expression E;
+identifier sk_data_ready_assigned.drv_data_ready;
+fresh identifier backport_drv_data_ready = "backport_" ## drv_data_ready;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ E->sk_data_ready = drv_data_ready;
++#else
++ E->sk_data_ready = backport_drv_data_ready;
++#endif
+
+@ sk_data_ready_found @
+expression E;
+struct sock *sk;
+@@
+
+ E->sk_data_ready(sk);
+
+@ sk_data_ready_skips_skb_queue_tail_E depends on sk_data_ready_found @
+expression E;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ E->sk_data_ready(E);
++#else
++ E->sk_data_ready(E, 0);
++#endif
+
+@ sk_data_ready_uses_skb_queue_tail depends on sk_data_ready_found && !sk_data_ready_skips_skb_queue_tail_E @
+struct sock *sk;
+struct sk_buff *skb;
+identifier sk_data_ready;
+@@
+
+ skb_queue_tail(&sk->sk_receive_queue, skb);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ sk->sk_data_ready(sk);
++#else
++ sk->sk_data_ready(sk, skb->len);
++#endif
+
--- /dev/null
+In kernel 3.8 struct pci_driver got a new function pointer sriov_configure.
+Address this by putting ifdef around the code.
+
+
+commit 1789382a72a537447d65ea4131d8bcc1ad85ce7b
+Author: Donald Dutile <ddutile@redhat.com>
+Date: Mon Nov 5 15:20:36 2012 -0500
+
+ PCI: SRIOV control and status via sysfs
+
+git describe --contains 1789382a72a537447d65ea4131d8bcc1ad85ce7b
+v3.8-rc1~128^2~6^2~4
+
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -7682,6 +7682,7 @@ static int igb_sriov_reinit(struct pci_d
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+ static int igb_pci_disable_sriov(struct pci_dev *dev)
+ {
+ int err = igb_disable_sriov(dev);
+@@ -7691,6 +7692,7 @@ static int igb_pci_disable_sriov(struct
+
+ return err;
+ }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
+
+ static int igb_pci_enable_sriov(struct pci_dev *dev, int num_vfs)
+ {
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct pci_driver s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+.sriov_configure = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
--- /dev/null
+In kernel 3.3 and 3.10 struct net_device_ops function pointers
+ndo_vlan_rx_add_vid and ndo_vlan_rx_kill_vid changed.
+Address this by putting ifdef around the code.
+
+
+commit 8e586137e6b63af1e881b328466ab5ffbe562510
+Author: Jiri Pirko <jpirko@redhat.com>
+Date: Thu Dec 8 19:52:37 2011 -0500
+
+ net: make vlan ndo_vlan_rx_[add/kill]_vid return error value
+
+git describe --contains 8e586137e6b63af1e881b328466ab5ffbe562510
+v3.3-rc1~182^2~291
+
+
+commit 80d5c3689b886308247da295a228a54df49a44f6
+Author: Patrick McHardy <kaber@trash.net>
+Date: Fri Apr 19 02:04:28 2013 +0000
+
+ net: vlan: prepare for 802.1ad VLAN filtering offload
+
+git describe --contains 80d5c3689b886308247da295a228a54df49a44f6
+v3.10-rc1~66^2~97^2~4
--- /dev/null
+--- a/drivers/net/usb/cdc_mbim.c
++++ b/drivers/net/usb/cdc_mbim.c
+@@ -70,7 +70,13 @@ static int cdc_mbim_wdm_manage_power(str
+ return cdc_mbim_manage_power(dev, status);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++static int cdc_mbim_rx_add_vid(struct net_device *netdev, u16 vid)
++#else
++static void cdc_mbim_rx_add_vid(struct net_device *netdev, u16 vid)
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+ {
+ struct usbnet *dev = netdev_priv(netdev);
+ struct cdc_mbim_state *info = (void *)&dev->data;
+@@ -78,13 +84,21 @@ static int cdc_mbim_rx_add_vid(struct ne
+ /* creation of this VLAN is a request to tag IP session 0 */
+ if (vid == MBIM_IPS0_VID)
+ info->flags |= FLAG_IPS0_VLAN;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ else
+ if (vid >= 512) /* we don't map these to MBIM session */
+ return -EINVAL;
+ return 0;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ static int cdc_mbim_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++static int cdc_mbim_rx_kill_vid(struct net_device *netdev, u16 vid)
++#else
++static void cdc_mbim_rx_kill_vid(struct net_device *netdev, u16 vid)
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+ {
+ struct usbnet *dev = netdev_priv(netdev);
+ struct cdc_mbim_state *info = (void *)&dev->data;
+@@ -92,7 +106,9 @@ static int cdc_mbim_rx_kill_vid(struct n
+ /* this is a request for an untagged IP session 0 */
+ if (vid == MBIM_IPS0_VID)
+ info->flags &= ~FLAG_IPS0_VLAN;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ return 0;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+ }
+
+ static const struct net_device_ops cdc_mbim_netdev_ops = {
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -158,8 +158,16 @@ static void igb_tx_timeout(struct net_de
+ static void igb_reset_task(struct work_struct *);
+ static void igb_vlan_mode(struct net_device *netdev,
+ netdev_features_t features);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ static int igb_vlan_rx_add_vid(struct net_device *, __be16, u16);
+ static int igb_vlan_rx_kill_vid(struct net_device *, __be16, u16);
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++static int igb_vlan_rx_add_vid(struct net_device *, u16);
++static int igb_vlan_rx_kill_vid(struct net_device *, u16);
++#else
++static void igb_vlan_rx_add_vid(struct net_device *, u16);
++static void igb_vlan_rx_kill_vid(struct net_device *, u16);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+ static void igb_restore_vlan(struct igb_adapter *);
+ static void igb_rar_set_qsel(struct igb_adapter *, u8 *, u32 , u8);
+ static void igb_ping_all_vfs(struct igb_adapter *);
+@@ -7349,8 +7357,14 @@ static void igb_vlan_mode(struct net_dev
+ igb_set_vf_vlan_strip(adapter, adapter->vfs_allocated_count, enable);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ static int igb_vlan_rx_add_vid(struct net_device *netdev,
+ __be16 proto, u16 vid)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++static int igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
++#else
++static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
++#endif
+ {
+ struct igb_adapter *adapter = netdev_priv(netdev);
+ struct e1000_hw *hw = &adapter->hw;
+@@ -7362,11 +7376,19 @@ static int igb_vlan_rx_add_vid(struct ne
+
+ set_bit(vid, adapter->active_vlans);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ return 0;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ static int igb_vlan_rx_kill_vid(struct net_device *netdev,
+ __be16 proto, u16 vid)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++static int igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
++#else
++static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+ {
+ struct igb_adapter *adapter = netdev_priv(netdev);
+ int pf_id = adapter->vfs_allocated_count;
+@@ -7378,7 +7400,9 @@ static int igb_vlan_rx_kill_vid(struct n
+
+ clear_bit(vid, adapter->active_vlans);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ return 0;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+ }
+
+ static void igb_restore_vlan(struct igb_adapter *adapter)
+@@ -7386,10 +7410,18 @@ static void igb_restore_vlan(struct igb_
+ u16 vid = 1;
+
+ igb_vlan_mode(adapter->netdev, adapter->netdev->features);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0);
++#else
++ igb_vlan_rx_add_vid(adapter->netdev, 0);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+
+ for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid);
++#else
++ igb_vlan_rx_add_vid(adapter->netdev, vid);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
+ }
+
+ int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx)
--- /dev/null
+In kernel 3.2 struct net_device_ops got a new function pointer
+ndo_set_vf_spoofchk. Address this by putting ifdef around the code.
+
+
+commit 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
+Author: Greg Rose <gregory.v.rose@intel.com>
+Date: Sat Oct 8 03:05:24 2011 +0000
+
+ if_link: Add additional parameter to IFLA_VF_INFO for spoof checking
+
+git describe --contains 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
+v3.2-rc1~129^2~87
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct net_device_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+.ndo_set_vf_spoofchk = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+};
+
+@r2@
+identifier s, func2;
+@@
+
+struct net_device_ops s = {
+.ndo_get_vf_config = func2,
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+
+@@
+identifier r2.func2, ivi;
+expression assign;
+@@
+
+func2(... ,struct ifla_vf_info *ivi)
+{
+ <...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+ ivi->spoofchk = assign;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+ ...>
+}
--- /dev/null
+In kernel 3.4 a new field no_fcs was introduced to struct sk_buff.
+Address this by putting ifdef around the code.
+
+
+commit 3bdc0eba0b8b47797f4a76e377dd8360f317450f
+Author: Ben Greear <greearb@candelatech.com>
+Date: Sat Feb 11 15:39:30 2012 +0000
+
+ net: Add framework to allow sending packets with customized CRC.
+
+git describe --contains 3bdc0eba0b8b47797f4a76e377dd8360f317450f
+v3.4-rc1~177^2~207
--- /dev/null
+@r1@
+expression E1,E2;
+struct sk_buff *skb;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ E1 ^= E2(..., skb->no_fcs, ...)
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) */
--- /dev/null
+In kernel 3.6 struct ethtool_ops received 2 new function pointers get_eee
+and set_eee. Address this by putting ifdef around the code.
+
+
+commit 80f12eccce775dc6bb93dba9b52529740f929237
+Author: Yuval Mintz <yuvalmin@broadcom.com>
+Date: Wed Jun 6 17:13:06 2012 +0000
+
+ Added kernel support in EEE Ethtool commands
+
+git describe --contains 80f12eccce775dc6bb93dba9b52529740f929237
+v3.6-rc1~125^2~587
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct ethtool_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+.get_eee = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+};
+
+@r2@
+identifier s, func;
+@@
+
+struct ethtool_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+.set_eee = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+
+@@
+identifier r2.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
--- /dev/null
+In kernel 3.5 struct ethtool_ops received 2 new function pointers
+get_module_info and get_module_eeprom. Address this by putting ifdef around
+the code.
+
+
+commit 41c3cb6d20f0252308e9796fa4f3dacb4960de91
+Author: Stuart Hodgson <smhodgson@solarflare.com>
+Date: Thu Apr 19 09:44:42 2012 +0100
+
+ ethtool: Extend the ethtool API to obtain plugin module eeprom data
+
+git describe --contains 41c3cb6d20f0252308e9796fa4f3dacb4960de91
+v3.5-rc1~109^2~124^2~2
+
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct ethtool_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+.get_module_info = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+};
+
+@r2@
+identifier s, func;
+@@
+
+struct ethtool_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+.get_module_eeprom = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+
+@@
+identifier r2.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
--- /dev/null
+In kernel 3.3 struct ethtool_ops received 3 new function pointers
+get_rxfh_indir_size, get_rxfh_indir, set_rxfh_indir.
+Address this by putting ifdef around the code.
+
+
+commit 7850f63f1620512631445b901ae11cd149e7375c
+Author: Ben Hutchings <bhutchings@solarflare.com>
+Date: Thu Dec 15 13:55:01 2011 +0000
+
+ ethtool: Centralise validation of ETHTOOL_{G, S}RXFHINDIR parameters
+
+git describe --contains 7850f63f1620512631445b901ae11cd149e7375c
+v3.3-rc1~182^2~192
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
++++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
+@@ -2860,19 +2860,28 @@ static void igb_ethtool_complete(struct
+ pm_runtime_put(&adapter->pdev->dev);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ static u32 igb_get_rxfh_indir_size(struct net_device *netdev)
+ {
+ return IGB_RETA_SIZE;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
+ u8 *hfunc)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
++static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
++#else
++static int igb_get_rxfh(struct net_device *netdev, u32 *indir)
++#endif
+ {
+ struct igb_adapter *adapter = netdev_priv(netdev);
+ int i;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ if (hfunc)
+ *hfunc = ETH_RSS_HASH_TOP;
++#endif
+ if (!indir)
+ return 0;
+ for (i = 0; i < IGB_RETA_SIZE; i++)
+@@ -2880,6 +2889,7 @@ static int igb_get_rxfh(struct net_devic
+
+ return 0;
+ }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+
+ void igb_write_rss_indir_tbl(struct igb_adapter *adapter)
+ {
+@@ -2916,18 +2926,28 @@ void igb_write_rss_indir_tbl(struct igb_
+ }
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
+ const u8 *key, const u8 hfunc)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
++static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
++ const u8 *key)
++#else
++static int igb_set_rxfh(struct net_device *netdev, const u32 *indir)
++#endif
+ {
+ struct igb_adapter *adapter = netdev_priv(netdev);
+ struct e1000_hw *hw = &adapter->hw;
+ int i;
+ u32 num_queues;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ /* We do not allow change in unsupported parameters */
+ if (key ||
+ (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
+ return -EOPNOTSUPP;
++#endif
+ if (!indir)
+ return 0;
+
+@@ -2956,6 +2976,7 @@ static int igb_set_rxfh(struct net_devic
+
+ return 0;
+ }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+
+ static unsigned int igb_max_channels(struct igb_adapter *adapter)
+ {
+@@ -3075,9 +3096,15 @@ static const struct ethtool_ops igb_etht
+ .set_eee = igb_set_eee,
+ .get_module_info = igb_get_module_info,
+ .get_module_eeprom = igb_get_module_eeprom,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+ .get_rxfh_indir_size = igb_get_rxfh_indir_size,
+ .get_rxfh = igb_get_rxfh,
+ .set_rxfh = igb_set_rxfh,
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
++ .get_rxfh_indir_size = igb_get_rxfh_indir_size,
++ .get_rxfh_indir = igb_get_rxfh,
++ .set_rxfh_indir = igb_set_rxfh,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+ .get_channels = igb_get_channels,
+ .set_channels = igb_set_channels,
+ .begin = igb_ethtool_begin,
--- /dev/null
+In kernel 3.2 an argument type of function pointer get_rxnfc in
+struct ethtool_ops changed from void to u32.
+Address this by putting ifdef around the code.
+
+
+commit 815c7db5c809ea3d5735de3131ecdf758b0e14ff
+Author: Ben Hutchings <bhutchings@solarflare.com>
+Date: Tue Sep 6 13:49:12 2011 +0000
+
+ ethtool: Clean up definitions of rule location arrays in RX NFC
+
+git describe --contains 815c7db5c809ea3d5735de3131ecdf758b0e14ff
+v3.2-rc1~129^2~272
+
--- /dev/null
+@r@
+identifier s,func;
+@@
+
+struct ethtool_ops s = {
+.get_rxnfc = func,
+};
+
+@@
+identifier r.func,rule_locs;
+typedef u32;
+@@
+
+// ----------------------------------------------------------------------
+
+func(...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+,u32 *rule_locs
++#else
++,void *rule_locs
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+ ) { ... }
--- /dev/null
+In kernel 3.7 struct ethtool_cmd received eth_tp_mdix and eth_tp_mdix_ctrl.
+Address this by putting ifdef around the code using these struct components.
+
+
+commit 6f6bbc186dc8e4e0c628db7decbd1a5e02cb5fd8
+Author: Jesse Brandeburg <jesse.brandeburg@intel.com>
+Date: Thu Jul 26 02:30:53 2012 +0000
+
+ ethtool.h: MDI setting support
+
+git describe --contains 6f6bbc186dc8e4e0c628db7decbd1a5e02cb5fd8
+v3.7-rc1~145^2~300^2~5
+
--- /dev/null
+@r1@
+expression E1;
+struct ethtool_cmd *ecmd;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ ecmd->eth_tp_mdix_ctrl = E1;
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
+
+@r2@
+struct ethtool_cmd *ecmd;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ if (ecmd->eth_tp_mdix_ctrl) {...}
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
--- /dev/null
+In kernel 3.7 struct pci_driver changed pci_error_handlers to const.
+Address this by putting ifdef around the code.
+
+
+commit 494530284f16298050ab99f54b7b12dd7d1418a1
+Author: Stephen Hemminger <shemminger@vyatta.com>
+Date: Fri Sep 7 09:33:14 2012 -0700
+
+ PCI: Make pci_error_handlers const
+
+git describe --contains 494530284f16298050ab99f54b7b12dd7d1418a1
+v3.7-rc1~177^2~9^2~3
--- /dev/null
+--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
++++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+@@ -2555,7 +2555,11 @@ static void atl1e_io_resume(struct pci_d
+ netif_device_attach(netdev);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ static const struct pci_error_handlers atl1e_err_handler = {
++#else
++static struct pci_error_handlers atl1e_err_handler = {
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
+ .error_detected = atl1e_io_error_detected,
+ .slot_reset = atl1e_io_slot_reset,
+ .resume = atl1e_io_resume,
--- /dev/null
+@@
+identifier s;
+@@
+
+static
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+const
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
+struct pci_error_handlers s = { ... };
--- /dev/null
+In kernel 3.16 struct net_device_ops changed and renamed pointer
+ndo_set_vf_tx_rate to ndo_set_vf_rate.
+
+commit ed616689a3d95eb6c9bdbb1ef74b0f50cbdf276a
+Author: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
+Date: Thu May 22 09:59:05 2014 -0400
+
+ net-next:v4: Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool.
+
+commit 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
+Author: Greg Rose <gregory.v.rose@intel.com>
+Date: Sat Oct 8 03:05:24 2011 +0000
+
+ if_link: Add additional parameter to IFLA_VF_INFO for spoof checking
+
+git describe --contains ed616689a3d95eb6c9bdbb1ef74b0f50cbdf276a
+v3.16-rc1~27^2~151
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -8013,6 +8013,7 @@ static int igb_ndo_set_vf_bw(struct net_
+ if (hw->mac.type != e1000_82576)
+ return -EOPNOTSUPP;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+ if (min_tx_rate)
+ return -EINVAL;
+
+@@ -8026,7 +8027,17 @@ static int igb_ndo_set_vf_bw(struct net_
+ adapter->vf_rate_link_speed = actual_link_speed;
+ adapter->vf_data[vf].tx_rate = (u16)max_tx_rate;
+ igb_set_vf_rate_limit(hw, vf, max_tx_rate, actual_link_speed);
++#else
++ actual_link_speed = igb_link_mbps(adapter->link_speed);
++ if ((vf >= adapter->vfs_allocated_count) ||
++ (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) ||
++ (tx_rate < 0) || (tx_rate > actual_link_speed))
++ return -EINVAL;
+
++ adapter->vf_rate_link_speed = actual_link_speed;
++ adapter->vf_data[vf].tx_rate = (u16)tx_rate;
++ igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
+ return 0;
+ }
+
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct net_device_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+.ndo_set_vf_rate = func,
++#else
++.ndo_set_vf_tx_rate = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
+};
+
+@r2@
+identifier s, func2;
+@@
+
+struct net_device_ops s = {
+.ndo_get_vf_config = func2,
+};
+
+// ----------------------------------------------------------------------
+
+@@
+identifier r1.func, min_tx_rate, max_tx_rate;
+@@
+
+func(...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+ ,int min_tx_rate, int max_tx_rate
++#else
++,int tx_rate
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
+ ) { ... }
+
+@@
+identifier r2.func2, ivi;
+expression assign, assign2;
+@@
+
+func2(... ,struct ifla_vf_info *ivi)
+{
+ <...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+ ivi->max_tx_rate = assign;
+ ivi->min_tx_rate = assign2;
++#else
++ivi->tx_rate = assign;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
+ ...>
+}
--- /dev/null
+--- a/net/ieee802154/dgram.c
++++ b/net/ieee802154/dgram.c
+@@ -480,8 +480,13 @@ static int dgram_setsockopt(struct sock
+ ro->want_ack = !!val;
+ break;
+ case WPAN_SECURITY:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
+ !ns_capable(net->user_ns, CAP_NET_RAW)) {
++#else
++ if (!capable(CAP_NET_ADMIN) &&
++ !capable(CAP_NET_RAW)) {
++#endif
+ err = -EPERM;
+ break;
+ }
+@@ -504,8 +509,13 @@ static int dgram_setsockopt(struct sock
+ }
+ break;
+ case WPAN_SECURITY_LEVEL:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+ if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
+ !ns_capable(net->user_ns, CAP_NET_RAW)) {
++#else
++ if (!capable(CAP_NET_ADMIN) &&
++ !capable(CAP_NET_RAW)) {
++#endif
+ err = -EPERM;
+ break;
+ }
--- /dev/null
+--- a/drivers/bluetooth/hci_vhci.c
++++ b/drivers/bluetooth/hci_vhci.c
+@@ -151,6 +151,7 @@ static int vhci_create_device(struct vhc
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ static inline ssize_t vhci_get_user(struct vhci_data *data,
+ struct iov_iter *from)
+ {
+@@ -158,6 +159,17 @@ static inline ssize_t vhci_get_user(stru
+ struct sk_buff *skb;
+ __u8 pkt_type, opcode;
+ int ret;
++#else
++static inline ssize_t vhci_get_user(struct vhci_data *data,
++ const struct iovec *iov,
++ unsigned long count)
++{
++ size_t len = iov_length(iov, count);
++ struct sk_buff *skb;
++ __u8 pkt_type, opcode;
++ unsigned long i;
++ int ret;
++#endif
+
+ if (len < 2 || len > HCI_MAX_FRAME_SIZE)
+ return -EINVAL;
+@@ -166,10 +178,20 @@ static inline ssize_t vhci_get_user(stru
+ if (!skb)
+ return -ENOMEM;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ if (copy_from_iter(skb_put(skb, len), len, from) != len) {
+ kfree_skb(skb);
+ return -EFAULT;
+ }
++#else
++ for (i = 0; i < count; i++) {
++ if (copy_from_user(skb_put(skb, iov[i].iov_len),
++ iov[i].iov_base, iov[i].iov_len)) {
++ kfree_skb(skb);
++ return -EFAULT;
++ }
++ }
++#endif
+
+ pkt_type = *((__u8 *) skb->data);
+ skb_pull(skb, 1);
+@@ -281,12 +303,21 @@ static ssize_t vhci_read(struct file *fi
+ return ret;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ static ssize_t vhci_write(struct kiocb *iocb, struct iov_iter *from)
++#else
++static ssize_t vhci_write(struct kiocb *iocb, const struct iovec *iov,
++ unsigned long count, loff_t pos)
++#endif
+ {
+ struct file *file = iocb->ki_filp;
+ struct vhci_data *data = file->private_data;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ return vhci_get_user(data, from);
++#else
++ return vhci_get_user(data, iov, count);
++#endif
+ }
+
+ static unsigned int vhci_poll(struct file *file, poll_table *wait)
+@@ -351,7 +382,11 @@ static int vhci_release(struct inode *in
+ static const struct file_operations vhci_fops = {
+ .owner = THIS_MODULE,
+ .read = vhci_read,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ .write_iter = vhci_write,
++#else
++ .aio_write = vhci_write,
++#endif
+ .poll = vhci_poll,
+ .open = vhci_open,
+ .release = vhci_release,
--- /dev/null
+@r1@
+struct page *page;
+expression E1;
+@@
+ return E1
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ || page_is_pfmemalloc(page)
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+ ;
--- /dev/null
+--- a/include/net/bluetooth/l2cap.h
++++ b/include/net/bluetooth/l2cap.h
+@@ -619,6 +619,12 @@ struct l2cap_ops {
+ struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
+ unsigned long hdr_len,
+ unsigned long len, int nb);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ int (*memcpy_fromiovec) (struct l2cap_chan *chan,
++ unsigned char *kdata,
++ struct iovec *iov,
++ int len);
++#endif
+ };
+
+ struct l2cap_conn {
+@@ -912,6 +918,33 @@ static inline long l2cap_chan_no_get_snd
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan,
++ unsigned char *kdata,
++ struct iovec *iov,
++ int len)
++{
++ /* Following is safe since for compiler definitions of kvec and
++ * iovec are identical, yielding the same in-core layout and alignment
++ */
++ struct kvec *vec = (struct kvec *)iov;
++
++ while (len > 0) {
++ if (vec->iov_len) {
++ int copy = min_t(unsigned int, len, vec->iov_len);
++ memcpy(kdata, vec->iov_base, copy);
++ len -= copy;
++ kdata += copy;
++ vec->iov_base += copy;
++ vec->iov_len -= copy;
++ }
++ vec++;
++ }
++
++ return 0;
++}
++#endif
++
+ extern bool disable_ertm;
+
+ int l2cap_init_sockets(void);
+--- a/net/bluetooth/6lowpan.c
++++ b/net/bluetooth/6lowpan.c
+@@ -515,11 +515,18 @@ static int send_pkt(struct l2cap_chan *c
+ */
+ chan->data = skb;
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ memset(&msg, 0, sizeof(msg));
++ msg.msg_iov = (struct iovec *) &iv;
++ msg.msg_iovlen = 1;
++#endif
+ iv.iov_base = skb->data;
+ iv.iov_len = skb->len;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ memset(&msg, 0, sizeof(msg));
+ iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len);
++#endif
+
+ err = l2cap_chan_send(chan, &msg, skb->len);
+ if (err > 0) {
+@@ -1017,6 +1024,9 @@ static const struct l2cap_ops bt_6lowpan
+ .suspend = chan_suspend_cb,
+ .get_sndtimeo = chan_get_sndtimeo_cb,
+ .alloc_skb = chan_alloc_skb_cb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
++#endif
+
+ .teardown = l2cap_chan_no_teardown,
+ .defer = l2cap_chan_no_defer,
+--- a/net/bluetooth/a2mp.c
++++ b/net/bluetooth/a2mp.c
+@@ -63,7 +63,12 @@ static void a2mp_send(struct amp_mgr *mg
+
+ memset(&msg, 0, sizeof(msg));
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, total_len);
++#else
++ msg.msg_iov = (struct iovec *) &iv;
++ msg.msg_iovlen = 1;
++#endif
+
+ l2cap_chan_send(chan, &msg, total_len);
+
+@@ -753,6 +758,9 @@ static const struct l2cap_ops a2mp_chan_
+ .resume = l2cap_chan_no_resume,
+ .set_shutdown = l2cap_chan_no_set_shutdown,
+ .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
++#endif
+ };
+
+ static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
+--- a/net/bluetooth/l2cap_core.c
++++ b/net/bluetooth/l2cap_core.c
+@@ -2126,7 +2126,12 @@ static inline int l2cap_skbuff_fromiovec
+ struct sk_buff **frag;
+ int sent = 0;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
++#else
++ if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
++ msg->msg_iov, count))
++#endif
+ return -EFAULT;
+
+ sent += count;
+@@ -2146,8 +2151,13 @@ static inline int l2cap_skbuff_fromiovec
+
+ *frag = tmp;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ if (copy_from_iter(skb_put(*frag, count), count,
+ &msg->msg_iter) != count)
++#else
++ if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
++ msg->msg_iov, count))
++#endif
+ return -EFAULT;
+
+ sent += count;
+--- a/net/bluetooth/l2cap_sock.c
++++ b/net/bluetooth/l2cap_sock.c
+@@ -1383,6 +1383,15 @@ static struct sk_buff *l2cap_sock_alloc_
+ return skb;
+ }
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++static int l2cap_sock_memcpy_fromiovec_cb(struct l2cap_chan *chan,
++ unsigned char *kdata,
++ struct iovec *iov, int len)
++{
++ return memcpy_fromiovec(kdata, iov, len);
++}
++#endif
++
+ static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
+ {
+ struct sock *sk = chan->data;
+@@ -1467,6 +1476,9 @@ static const struct l2cap_ops l2cap_chan
+ .set_shutdown = l2cap_sock_set_shutdown_cb,
+ .get_sndtimeo = l2cap_sock_get_sndtimeo_cb,
+ .alloc_skb = l2cap_sock_alloc_skb_cb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ .memcpy_fromiovec = l2cap_sock_memcpy_fromiovec_cb,
++#endif
+ };
+
+ static void l2cap_sock_destruct(struct sock *sk)
+--- a/net/bluetooth/smp.c
++++ b/net/bluetooth/smp.c
+@@ -612,7 +612,12 @@ static void smp_send_cmd(struct l2cap_co
+
+ memset(&msg, 0, sizeof(msg));
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iv, 2, 1 + len);
++#else
++ msg.msg_iov = (struct iovec *) &iv;
++ msg.msg_iovlen = 2;
++#endif
+
+ l2cap_chan_send(chan, &msg, 1 + len);
+
+@@ -3066,6 +3071,9 @@ static const struct l2cap_ops smp_chan_o
+ .suspend = l2cap_chan_no_suspend,
+ .set_shutdown = l2cap_chan_no_set_shutdown,
+ .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
++#endif
+ };
+
+ static inline struct l2cap_chan *smp_new_conn_cb(struct l2cap_chan *pchan)
+@@ -3114,6 +3122,9 @@ static const struct l2cap_ops smp_root_c
+ .resume = l2cap_chan_no_resume,
+ .set_shutdown = l2cap_chan_no_set_shutdown,
+ .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
++#endif
+ };
+
+ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
--- /dev/null
+--- a/drivers/ssb/pcihost_wrapper.c
++++ b/drivers/ssb/pcihost_wrapper.c
+@@ -33,7 +33,9 @@ static int ssb_pcihost_suspend(struct de
+
+ /* if there is a wakeup enabled child device on ssb bus,
+ enable pci wakeup posibility. */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+ device_set_wakeup_enable(d, d->power.wakeup_path);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+
+ pci_prepare_to_sleep(dev);
+
--- /dev/null
+Programmable pins were introduced in the ptp subsystem in kernel 3.15
+and igb makes use of them now. These patches are removing the code
+accessing these new functions.
+
+These patches are needed for every kernel which does not have this
+commit:
+commit 6092315dfdec5185881605d15a0e200d6e90eb66
+Author: Richard Cochran <richardcochran@gmail.com>
+Date: Thu Mar 20 22:21:52 2014 +0100
+
+ ptp: introduce programmable pins.
+
+ This patch adds a pair of new ioctls to the PTP Hardware Clock device
+ interface. Using the ioctls, user space programs can query each pin to
+ find out its current function and also reprogram a different function
+ if desired.
+
+ Signed-off-by: Richard Cochran <richardcochran@gmail.com>
+ Signed-off-by: David S. Miller <davem@davemloft.net>
+
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb.h
++++ b/drivers/net/ethernet/intel/igb/igb.h
+@@ -443,7 +443,9 @@ struct igb_adapter {
+ u32 tx_hwtstamp_timeouts;
+ u32 rx_hwtstamp_cleared;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ struct ptp_pin_desc sdp_config[IGB_N_SDP];
++#endif
+ struct {
+ struct timespec64 start;
+ struct timespec64 period;
+--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
+@@ -115,6 +115,7 @@ static cycle_t igb_ptp_read_82580(const
+ return val;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ /* SYSTIM read access for I210/I211 */
+ static void igb_ptp_read_i210(struct igb_adapter *adapter,
+ struct timespec64 *ts)
+@@ -133,6 +134,7 @@ static void igb_ptp_read_i210(struct igb
+ ts->tv_sec = sec;
+ ts->tv_nsec = nsec;
+ }
++#endif
+
+ static void igb_ptp_write_i210(struct igb_adapter *adapter,
+ const struct timespec64 *ts)
+@@ -265,6 +267,7 @@ static int igb_ptp_adjtime_82576(struct
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
+ {
+ struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
+@@ -282,6 +285,7 @@ static int igb_ptp_adjtime_i210(struct p
+
+ return 0;
+ }
++#endif
+
+ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
+ struct timespec64 *ts)
+@@ -302,6 +306,7 @@ static int igb_ptp_gettime_82576(struct
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp,
+ struct timespec64 *ts)
+ {
+@@ -317,6 +322,7 @@ static int igb_ptp_gettime_i210(struct p
+
+ return 0;
+ }
++#endif
+
+ static int igb_ptp_settime_82576(struct ptp_clock_info *ptp,
+ const struct timespec64 *ts)
+@@ -337,6 +343,7 @@ static int igb_ptp_settime_82576(struct
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ static int igb_ptp_settime_i210(struct ptp_clock_info *ptp,
+ const struct timespec64 *ts)
+ {
+@@ -598,6 +605,7 @@ static int igb_ptp_feature_enable_i210(s
+
+ return -EOPNOTSUPP;
+ }
++#endif
+
+ static int igb_ptp_feature_enable(struct ptp_clock_info *ptp,
+ struct ptp_clock_request *rq, int on)
+@@ -605,6 +613,7 @@ static int igb_ptp_feature_enable(struct
+ return -EOPNOTSUPP;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ static int igb_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
+ enum ptp_pin_function func, unsigned int chan)
+ {
+@@ -618,6 +627,7 @@ static int igb_ptp_verify_pin(struct ptp
+ }
+ return 0;
+ }
++#endif
+
+ /**
+ * igb_ptp_tx_work
+@@ -1010,7 +1020,9 @@ void igb_ptp_init(struct igb_adapter *ad
+ {
+ struct e1000_hw *hw = &adapter->hw;
+ struct net_device *netdev = adapter->netdev;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ int i;
++#endif
+
+ switch (hw->mac.type) {
+ case e1000_82576:
+@@ -1051,6 +1063,7 @@ void igb_ptp_init(struct igb_adapter *ad
+ /* Enable the timer functions by clearing bit 31. */
+ wr32(E1000_TSAUXC, 0x0);
+ break;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ case e1000_i210:
+ case e1000_i211:
+ for (i = 0; i < IGB_N_SDP; i++) {
+@@ -1077,6 +1090,7 @@ void igb_ptp_init(struct igb_adapter *ad
+ /* Enable the timer functions by clearing bit 31. */
+ wr32(E1000_TSAUXC, 0x0);
+ break;
++#endif
+ default:
+ adapter->ptp_clock = NULL;
+ return;
+@@ -1088,11 +1102,14 @@ void igb_ptp_init(struct igb_adapter *ad
+ INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
+
+ /* Initialize the clock and overflow work for devices that need it. */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+ if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) {
+ struct timespec64 ts = ktime_to_timespec64(ktime_get_real());
+
+ igb_ptp_settime_i210(&adapter->ptp_caps, &ts);
+- } else {
++ } else
++#endif
++ {
+ timecounter_init(&adapter->tc, &adapter->cc,
+ ktime_to_ns(ktime_get_real()));
+
--- /dev/null
+diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
+index 04e5785..a251da1 100644
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -3350,12 +3350,12 @@ struct wiphy {
+
+ static inline struct net *wiphy_net(struct wiphy *wiphy)
+ {
+- return read_pnet(&wiphy->_net);
++ return possible_read_pnet(&wiphy->_net);
+ }
+
+ static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
+ {
+- write_pnet(&wiphy->_net, net);
++ possible_write_pnet(&wiphy->_net, net);
+ }
+
+ /**
--- /dev/null
+--- a/drivers/bluetooth/btusb.c
++++ b/drivers/bluetooth/btusb.c
+@@ -1845,8 +1845,12 @@ static void btusb_intel_bootup(struct bt
+ return;
+
+ if (test_and_clear_bit(BTUSB_BOOTING, &data->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&data->flags, BTUSB_BOOTING);
++#else
++ wake_up_interruptible(&data->hdev->req_wait_q);
++#endif
+ }
+ }
+
+@@ -1863,8 +1867,12 @@ static void btusb_intel_secure_send_resu
+
+ if (test_and_clear_bit(BTUSB_DOWNLOADING, &data->flags) &&
+ test_bit(BTUSB_FIRMWARE_LOADED, &data->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&data->flags, BTUSB_DOWNLOADING);
++#else
++ wake_up_interruptible(&data->hdev->req_wait_q);
++#endif
+ }
+ }
+
+@@ -2208,6 +2216,7 @@ static int btusb_setup_intel_new(struct
+ * and thus just timeout if that happens and fail the setup
+ * of this device.
+ */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
+ TASK_INTERRUPTIBLE,
+ msecs_to_jiffies(5000));
+@@ -2222,6 +2231,31 @@ static int btusb_setup_intel_new(struct
+ err = -ETIMEDOUT;
+ goto done;
+ }
++#else
++ if (test_bit(BTUSB_DOWNLOADING, &data->flags)) {
++ DECLARE_WAITQUEUE(wait, current);
++ signed long timeout;
++
++ add_wait_queue(&hdev->req_wait_q, &wait);
++ set_current_state(TASK_INTERRUPTIBLE);
++
++ timeout = schedule_timeout(msecs_to_jiffies(5000));
++
++ remove_wait_queue(&hdev->req_wait_q, &wait);
++
++ if (signal_pending(current)) {
++ BT_ERR("%s: Firmware loading interrupted", hdev->name);
++ err = -EINTR;
++ goto done;
++ }
++
++ if (!timeout) {
++ BT_ERR("%s: Firmware loading timeout", hdev->name);
++ err = -ETIMEDOUT;
++ goto done;
++ }
++ }
++#endif
+
+ if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) {
+ BT_ERR("%s: Firmware loading failed", hdev->name);
+@@ -2261,6 +2295,7 @@ done:
+ */
+ BT_INFO("%s: Waiting for device to boot", hdev->name);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
+ TASK_INTERRUPTIBLE,
+ msecs_to_jiffies(1000));
+@@ -2274,6 +2309,33 @@ done:
+ BT_ERR("%s: Device boot timeout", hdev->name);
+ return -ETIMEDOUT;
+ }
++#else
++ if (test_bit(BTUSB_BOOTING, &data->flags)) {
++ DECLARE_WAITQUEUE(wait, current);
++ signed long timeout;
++
++ add_wait_queue(&hdev->req_wait_q, &wait);
++ set_current_state(TASK_INTERRUPTIBLE);
++
++ /* Booting into operational firmware should not take
++ * longer than 1 second. However if that happens, then
++ * just fail the setup since something went wrong.
++ */
++ timeout = schedule_timeout(msecs_to_jiffies(1000));
++
++ remove_wait_queue(&hdev->req_wait_q, &wait);
++
++ if (signal_pending(current)) {
++ BT_ERR("%s: Device boot interrupted", hdev->name);
++ return -EINTR;
++ }
++
++ if (!timeout) {
++ BT_ERR("%s: Device boot timeout", hdev->name);
++ return -ETIMEDOUT;
++ }
++ }
++#endif
+
+ rettime = ktime_get();
+ delta = ktime_sub(rettime, calltime);
--- /dev/null
+--- a/drivers/bluetooth/hci_intel.c
++++ b/drivers/bluetooth/hci_intel.c
+@@ -122,8 +122,9 @@ static u8 intel_convert_speed(unsigned i
+ static int intel_wait_booting(struct hci_uart *hu)
+ {
+ struct intel_data *intel = hu->priv;
+- int err;
++ int err = 0;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ err = wait_on_bit_timeout(&intel->flags, STATE_BOOTING,
+ TASK_INTERRUPTIBLE,
+ msecs_to_jiffies(1000));
+@@ -137,6 +138,33 @@ static int intel_wait_booting(struct hci
+ bt_dev_err(hu->hdev, "Device boot timeout");
+ return -ETIMEDOUT;
+ }
++#else
++ if (test_bit(STATE_BOOTING, &intel->flags)) {
++ DECLARE_WAITQUEUE(wait, current);
++ signed long timeout;
++
++ add_wait_queue(&hu->hdev->req_wait_q, &wait);
++ set_current_state(TASK_INTERRUPTIBLE);
++
++ /* Booting into operational firmware should not take
++ * longer than 1 second. However if that happens, then
++ * just fail the setup since something went wrong.
++ */
++ timeout = schedule_timeout(msecs_to_jiffies(1000));
++
++ remove_wait_queue(&hu->hdev->req_wait_q, &wait);
++
++ if (signal_pending(current)) {
++ BT_ERR("%s: Device boot interrupted", hu->hdev->name);
++ return -EINTR;
++ }
++
++ if (!timeout) {
++ BT_ERR("%s: Device boot timeout", hu->hdev->name);
++ return -ETIMEDOUT;
++ }
++ }
++#endif
+
+ return err;
+ }
+@@ -145,8 +173,9 @@ static int intel_wait_booting(struct hci
+ static int intel_wait_lpm_transaction(struct hci_uart *hu)
+ {
+ struct intel_data *intel = hu->priv;
+- int err;
++ int err = 0;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ err = wait_on_bit_timeout(&intel->flags, STATE_LPM_TRANSACTION,
+ TASK_INTERRUPTIBLE,
+ msecs_to_jiffies(1000));
+@@ -160,6 +189,29 @@ static int intel_wait_lpm_transaction(st
+ bt_dev_err(hu->hdev, "LPM transaction timeout");
+ return -ETIMEDOUT;
+ }
++#else
++ if (test_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
++ DECLARE_WAITQUEUE(wait, current);
++ signed long timeout;
++
++ add_wait_queue(&hu->hdev->req_wait_q, &wait);
++ set_current_state(TASK_INTERRUPTIBLE);
++
++ timeout = schedule_timeout(msecs_to_jiffies(1000));
++
++ remove_wait_queue(&hu->hdev->req_wait_q, &wait);
++
++ if (signal_pending(current)) {
++ BT_ERR("%s: LPM transaction interrupted", hu->hdev->name);
++ return -EINTR;
++ }
++
++ if (!timeout) {
++ BT_ERR("%s: LPM transaction timeout", hu->hdev->name);
++ return -ETIMEDOUT;
++ }
++ }
++#endif
+
+ return err;
+ }
+@@ -812,6 +864,7 @@ static int intel_setup(struct hci_uart *
+ * and thus just timeout if that happens and fail the setup
+ * of this device.
+ */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ err = wait_on_bit_timeout(&intel->flags, STATE_DOWNLOADING,
+ TASK_INTERRUPTIBLE,
+ msecs_to_jiffies(5000));
+@@ -826,6 +879,33 @@ static int intel_setup(struct hci_uart *
+ err = -ETIMEDOUT;
+ goto done;
+ }
++#else
++ if (test_bit(STATE_DOWNLOADING, &intel->flags)) {
++ DECLARE_WAITQUEUE(wait, current);
++ signed long timeout;
++
++ add_wait_queue(&hdev->req_wait_q, &wait);
++ set_current_state(TASK_INTERRUPTIBLE);
++
++ /* Booting into operational firmware should not take
++ * longer than 1 second. However if that happens, then
++ * just fail the setup since something went wrong.
++ */
++ timeout = schedule_timeout(msecs_to_jiffies(5000));
++
++ remove_wait_queue(&hdev->req_wait_q, &wait);
++
++ if (signal_pending(current)) {
++ BT_ERR("%s: Firmware loading interrupted", hdev->name);
++ return -EINTR;
++ }
++
++ if (!timeout) {
++ BT_ERR("%s: Firmware loading timeout", hdev->name);
++ return -ETIMEDOUT;
++ }
++ }
++#endif
+
+ if (test_bit(STATE_FIRMWARE_FAILED, &intel->flags)) {
+ bt_dev_err(hdev, "Firmware loading failed");
+@@ -957,8 +1037,12 @@ static int intel_recv_event(struct hci_d
+
+ if (test_and_clear_bit(STATE_DOWNLOADING, &intel->flags) &&
+ test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&intel->flags, STATE_DOWNLOADING);
++#else
++ wake_up_interruptible(&hu->hdev->req_wait_q);
++#endif
+ }
+
+ /* When switching to the operational firmware the device
+@@ -968,8 +1052,12 @@ static int intel_recv_event(struct hci_d
+ } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
+ skb->data[2] == 0x02) {
+ if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&intel->flags, STATE_BOOTING);
++#else
++ wake_up_interruptible(&hu->hdev->req_wait_q);
++#endif
+ }
+ }
+ recv:
+@@ -1008,15 +1096,23 @@ static int intel_recv_lpm(struct hci_dev
+ case LPM_OP_SUSPEND_ACK:
+ set_bit(STATE_SUSPENDED, &intel->flags);
+ if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
++#else
++ wake_up_interruptible(&hu->hdev->req_wait_q);
++#endif
+ }
+ break;
+ case LPM_OP_RESUME_ACK:
+ clear_bit(STATE_SUSPENDED, &intel->flags);
+ if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ smp_mb__after_atomic();
+ wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
++#else
++ wake_up_interruptible(&hu->hdev->req_wait_q);
++#endif
+ }
+ break;
+ default:
--- /dev/null
+/*
+This provides the backport for the collateral evolution introduced
+via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
+"net: Remove iocb argument from sendmsg and recvmsg".
+
+The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
+relied historically on using an argument passed on the struct proto_ops
+and struct proto sendmsg and recvmsg callbacks to determine if it needed
+to perform a lock within its own code. Commit 1b784140474e4 removed replaced
+the locking functionality to require the argument and instead moved all
+the necessary heuristics into net/tipc. Other subsystems just passed NULL.
+After the net/tipc code was cleaned up from the locking (see commmit
+39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
+argument in socket layer") we no longer needed the extra argument on the
+struct proto_ops and struct proto callbacks.
+
+To backport non-tipc subsystems we then just need to modify the upstream
+code which declares these callbacks and add the extra argument again, but
+the same routine can be used from upstream code. The grammar we use below
+declares routines which can be pegged to struct proto_ops and struct proto
+callbacks that simply call the same upstream code, the extra argument is
+ignored. The argument can be ignored as it was only used within the
+net/tipc subsystem for locking purposes.
+*/
+
+@ proto_ops @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto_ops s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ mod_send depends on proto_ops @
+identifier proto_ops.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
++{
++ return send_func(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_recv depends on proto_ops @
+identifier proto_ops.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int flags)
++{
++ return recv_func(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_ops_tx depends on proto_ops && mod_send @
+identifier s, proto_ops.send_func, mod_send.backport_send;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_ops_rx depends on proto_ops && mod_recv @
+identifier s, proto_ops.recv_func, mod_recv.backport_recv;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_sock_send_callers depends on proto_ops@
+identifier proto_ops.send_func;
+identifier sock, msg, len, sk;
+@@
+
+send_func(struct socket *sock, struct msghdr *msg, size_t len)
+{
+ ...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ return sk->sk_prot->sendmsg(sk, msg, len);
++#else
++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+}
+
+@ proto @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ proto_mod_send depends on proto @
+identifier proto.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct sock *sk,
++ struct msghdr *msg, size_t len)
++{
++ return send_func(sk, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ proto_mod_recv depends on proto @
+identifier proto.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct sock *sk,
++ struct msghdr *msg, size_t len,
++ int noblock, int flags, int *addr_len)
++{
++ return recv_func(sk, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_tx depends on proto && proto_mod_send @
+identifier s, proto.send_func, proto_mod_send.backport_send;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_rx depends on proto && proto_mod_recv @
+identifier s, proto.recv_func, proto_mod_recv.backport_recv;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
--- /dev/null
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+@@ -2208,7 +2208,9 @@ struct wireless_dev *brcmf_p2p_add_vif(s
+ }
+
+ strncpy(ifp->ndev->name, name, sizeof(ifp->ndev->name) - 1);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ ifp->ndev->name_assign_type = name_assign_type;
++#endif /* >= 3.17.0 */
+ err = brcmf_net_attach(ifp, true);
+ if (err) {
+ brcmf_err("Registering netdevice failed\n");
--- /dev/null
+@@
+struct net_device *dev;
+expression E;
+@@
+-dev->tstats = E;
++netdev_assign_tstats(dev, E);
+@@
+struct net_device *dev;
+@@
+-dev->tstats
++netdev_tstats(dev)
--- /dev/null
+In kernel 3.19 function pointer ndo_gso_check is changed into
+ndo_features_check in struct net_device_ops.
+Address this by putting ifdef around the code.
+
+commit 5f35227ea34bb616c436d9da47fc325866c428f3
+Author: Jesse Gross <jesse@nicira.com>
+Date: Tue Dec 23 22:37:26 2014 -0800
+
+ net: Generalize ndo_gso_check to ndo_features_check
+
+git describe --contains 5f35227ea34bb616c436d9da47fc325866c428f3
+v3.19-rc3~16^2~7
--- /dev/null
+@r1@
+identifier s, func;
+@@
+
+struct net_device_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+.ndo_features_check = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@r2@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
--- /dev/null
+In kernel 4.1 struct ptp_clock_info changes function pointers gettime,
+settime to gettime64, settime64.
+
+commit 92f1719407b90475b3be0b7b9c983dec2ff8351e
+Author: Richard Cochran <richardcochran@gmail.com>
+Date: Sun Mar 29 23:11:51 2015 +0200
+
+ ptp: introduce get/set time methods with explicit 64 bit seconds.
+
+git describe --contains 92f1719407b90475b3be0b7b9c983dec2ff8351e
+next-20150401~92^2~18^2~22
--- /dev/null
+// ----------------------------------------------------------------------------
+// handle gettime64 to gettime function assignments
+@r1@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.gettime64 = E2;
++#else
++E1.gettime = E2;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
+// ----------------------------------------------------------------------------
+// handle calls to gettime64 as calls to gettime
+@r2@
+expression E1, E2, E3;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.gettime64(E2, E3);
++#else
++E1.gettime(E2, E3);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
+// ----------------------------------------------------------------------------
+// handle settime64 to settime function assignments
+@r3@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.settime64 = E2;
++#else
++E1.settime = E2;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
--- /dev/null
+In kernel 3.18 __u8 xmit_more is added to struct sk_buff.
+
+commit 0b725a2ca61bedc33a2a63d0451d528b268cf975
+Author: David S. Miller <davem@davemloft.net>
+Date: Mon Aug 25 15:51:53 2014 -0700
+
+ net: Remove ndo_xmit_flush netdev operation, use signalling instead.
+
+git describe --contains 0b725a2ca61bedc33a2a63d0451d528b268cf975
+v3.18-rc1~52^2~228
--- /dev/null
+@r1@
+struct sk_buff *skb;
+expression E1;
+@@
+ if (E1
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
+ || !skb->xmit_more
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) */
+ ) {...}
--- /dev/null
+The uuid member was added to the struct mei_cl_device_id in this commit:
+commit c93b76b34b4d8dbe8e3443eb27e49ac60034342b
+Author: Tomas Winkler <tomas.winkler@intel.com>
+Date: Thu May 7 15:54:02 2015 +0300
+
+ mei: bus: report also uuid in module alias
+
--- /dev/null
+--- a/drivers/nfc/microread/mei.c
++++ b/drivers/nfc/microread/mei.c
+@@ -67,7 +67,13 @@ static int microread_mei_remove(struct m
+ }
+
+ static struct mei_cl_device_id microread_mei_tbl[] = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
+ { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
++ { MICROREAD_DRIVER_NAME, MEI_NFC_UUID},
++#else
++ { MICROREAD_DRIVER_NAME},
++#endif
+
+ /* required last entry */
+ { }
+--- a/drivers/nfc/pn544/mei.c
++++ b/drivers/nfc/pn544/mei.c
+@@ -67,7 +67,13 @@ static int pn544_mei_remove(struct mei_c
+ }
+
+ static struct mei_cl_device_id pn544_mei_tbl[] = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
+ { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
++ { PN544_DRIVER_NAME, MEI_NFC_UUID},
++#else
++ { PN544_DRIVER_NAME},
++#endif
+
+ /* required last entry */
+ { }
--- /dev/null
+deactivate struct tracing
+
+__field_struct was added in Linux commit 4d4c9cc83. It is hard to backport
+this feature, so just remove the code using it on kernel version < 3.16.
+
+commit 4d4c9cc839a308be3289a361ccba4447ee140552
+Author: Steven Rostedt <rostedt@goodmis.org>
+Date: Tue Jun 17 08:59:16 2014 -0400
+
+ tracing: Add __field_struct macro for TRACE_EVENT()
+
--- /dev/null
+diff --git a/drivers/net/wireless/mediatek/mt7601u/trace.h b/drivers/net/wireless/mediatek/mt7601u/trace.h
+index 2898973..7fa1b96 100644
+--- a/drivers/net/wireless/mediatek/mt7601u/trace.h
++++ b/drivers/net/wireless/mediatek/mt7601u/trace.h
+@@ -252,6 +252,7 @@ TRACE_EVENT(freq_cal_offset,
+ DEV_PR_ARG, __entry->phy_mode, __entry->freq_off)
+ );
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
+ TRACE_EVENT(mt_rx,
+ TP_PROTO(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi, u32 f),
+ TP_ARGS(dev, rxwi, f),
+@@ -306,6 +307,20 @@ TRACE_EVENT(mt_tx,
+ __entry->h.ack_ctl, __entry->h.wcid,
+ le16_to_cpu(__entry->h.len_ctl))
+ );
++#else
++#ifndef __BACKPORT_MT7601U_TRACE_H_EXTRA
++#define __BACKPORT_MT7601U_TRACE_H_EXTRA
++static inline void trace_mt_rx(struct mt7601u_dev *dev,
++ struct mt7601u_rxwi *rxwi,
++ u32 f)
++{
++}
++static inline void trace_mt_tx(struct mt7601u_dev *dev, struct sk_buff *skb,
++ struct mt76_sta *sta, struct mt76_txwi *h)
++{
++}
++#endif /* __BACKPORT_MT7601U_TRACE_H_EXTRA */
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
+
+ TRACE_EVENT(mt_tx_dma_done,
+ TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb),
--- /dev/null
+use old locking for struct tty_struct
+
+With kernel 3.12 a new locking was added to struct tty_struct. This
+patch makes the code use the old locking.
+
+The new locking was added in this commit:
+commit 6a1c0680cf3ba94356ecd58833e1540c93472a57
+Author: Peter Hurley <peter@hurleysoftware.com>
+Date: Sat Jun 15 09:14:23 2013 -0400
+
+ tty: Convert termios_mutex to termios_rwsem
--- /dev/null
+--- a/net/nfc/nci/uart.c
++++ b/net/nfc/nci/uart.c
+@@ -439,9 +439,17 @@ void nci_uart_set_config(struct nci_uart
+ if (!nu->tty)
+ return;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ down_read(&nu->tty->termios_rwsem);
++#else
++ mutex_lock(&nu->tty->termios_mutex);
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
+ new_termios = nu->tty->termios;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ up_read(&nu->tty->termios_rwsem);
++#else
++ mutex_unlock(&nu->tty->termios_mutex);
++#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
+ tty_termios_encode_baud_rate(&new_termios, baudrate, baudrate);
+
+ if (flow_ctrl)
--- /dev/null
+--- a/drivers/bluetooth/hci_bcm.c
++++ b/drivers/bluetooth/hci_bcm.c
+@@ -29,7 +29,9 @@
+ #include <linux/acpi.h>
+ #include <linux/platform_device.h>
+ #include <linux/clk.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ #include <linux/gpio/consumer.h>
++#endif
+ #include <linux/tty.h>
+ #include <linux/interrupt.h>
+ #include <linux/dmi.h>
+@@ -148,8 +150,10 @@ static int bcm_gpio_set_power(struct bcm
+ if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled)
+ clk_enable(dev->clk);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ gpiod_set_value(dev->shutdown, powered);
+ gpiod_set_value(dev->device_wakeup, powered);
++#endif
+
+ if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled)
+ clk_disable(dev->clk);
+@@ -520,7 +524,9 @@ static int bcm_suspend_device(struct dev
+
+ /* Suspend the device */
+ if (bdev->device_wakeup) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ gpiod_set_value(bdev->device_wakeup, false);
++#endif
+ bt_dev_dbg(bdev, "suspend, delaying 15 ms");
+ mdelay(15);
+ }
+@@ -535,7 +541,9 @@ static int bcm_resume_device(struct devi
+ bt_dev_dbg(bdev, "");
+
+ if (bdev->device_wakeup) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ gpiod_set_value(bdev->device_wakeup, true);
++#endif
+ bt_dev_dbg(bdev, "resume, delaying 15 ms");
+ mdelay(15);
+ }
+@@ -618,6 +626,7 @@ unlock:
+ }
+ #endif
+
++#if defined(CONFIG_ACPI) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ static const struct acpi_gpio_params device_wakeup_gpios = { 0, 0, false };
+ static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
+ static const struct acpi_gpio_params host_wakeup_gpios = { 2, 0, false };
+@@ -629,7 +638,6 @@ static const struct acpi_gpio_mapping ac
+ { },
+ };
+
+-#ifdef CONFIG_ACPI
+ static u8 acpi_active_low = ACPI_ACTIVE_LOW;
+
+ /* IRQ polarity of some chipsets are not defined correctly in ACPI table. */
+@@ -812,7 +820,7 @@ static const struct hci_uart_proto bcm_p
+ .dequeue = bcm_dequeue,
+ };
+
+-#ifdef CONFIG_ACPI
++#if defined(CONFIG_ACPI) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ static const struct acpi_device_id bcm_acpi_match[] = {
+ { "BCM2E1A", 0 },
+ { "BCM2E39", 0 },
+@@ -843,7 +851,9 @@ static struct platform_driver bcm_driver
+ .remove = bcm_remove,
+ .driver = {
+ .name = "hci_bcm",
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ .acpi_match_table = ACPI_PTR(bcm_acpi_match),
++#endif
+ .pm = &bcm_pm_ops,
+ },
+ };
--- /dev/null
+--- a/drivers/bluetooth/hci_intel.c
++++ b/drivers/bluetooth/hci_intel.c
+@@ -29,7 +29,9 @@
+ #include <linux/wait.h>
+ #include <linux/tty.h>
+ #include <linux/platform_device.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ #include <linux/gpio/consumer.h>
++#endif
+ #include <linux/acpi.h>
+ #include <linux/interrupt.h>
+ #include <linux/pm_runtime.h>
+@@ -379,7 +381,9 @@ static int intel_set_power(struct hci_ua
+ BT_INFO("hu %p, Switching compatible pm device (%s) to %u",
+ hu, dev_name(&idev->pdev->dev), powered);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ gpiod_set_value(idev->reset, powered);
++#endif
+
+ /* Provide to idev a hu reference which is used to run LPM
+ * transactions (lpm suspend/resume) from PM callbacks.
+@@ -1306,14 +1310,17 @@ static int intel_probe(struct platform_d
+
+ idev->pdev = pdev;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(idev->reset)) {
+ dev_err(&pdev->dev, "Unable to retrieve gpio\n");
+ return PTR_ERR(idev->reset);
+ }
++#endif
+
+ idev->irq = platform_get_irq(pdev, 0);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ if (idev->irq < 0) {
+ struct gpio_desc *host_wake;
+
+@@ -1332,12 +1339,15 @@ static int intel_probe(struct platform_d
+ goto no_irq;
+ }
+ }
++#endif
+
+ /* Only enable wake-up/irq when controller is powered */
+ device_set_wakeup_capable(&pdev->dev, true);
+ device_wakeup_disable(&pdev->dev);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ no_irq:
++#endif
+ platform_set_drvdata(pdev, idev);
+
+ /* Place this instance on the device list */
+@@ -1345,8 +1355,10 @@ no_irq:
+ list_add_tail(&idev->list, &intel_device_list);
+ mutex_unlock(&intel_device_list_lock);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ dev_info(&pdev->dev, "registered, gpio(%d)/irq(%d).\n",
+ desc_to_gpio(idev->reset), idev->irq);
++#endif
+
+ return 0;
+ }
--- /dev/null
+@@
+expression E;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
+ E->priv_flags |= IFF_NO_QUEUE;
++#else
++E->tx_queue_len = 0;
++#endif
--- /dev/null
+@@
+identifier ndisc_send_na;
+expression netdev, saddr, target, router, solicited, override, inc_opt;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
+ ipv6_stub->ndisc_send_na(netdev, saddr, target, router, solicited, override, inc_opt);
++#else
++ipv6_stub->ndisc_send_na(netdev, NULL, saddr, target, router, solicited, override, inc_opt);
++#endif
--- /dev/null
+--- a/include/net/cfg802154.h
++++ b/include/net/cfg802154.h
+@@ -359,6 +359,7 @@ struct wpan_dev {
+
+ #define to_phy(_dev) container_of(_dev, struct wpan_phy, dev)
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ static inline int
+ wpan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
+ const struct ieee802154_addr *daddr,
+@@ -369,6 +370,7 @@ wpan_dev_hard_header(struct sk_buff *skb
+
+ return wpan_dev->header_ops->create(skb, dev, daddr, saddr, len);
+ }
++#endif /* >= 3.19 */
+
+ struct wpan_phy *
+ wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size);
--- /dev/null
+@ r1 @
+struct phy_device *phydev;
+@@
+-phydev->mdio.addr
++phydev_get_addr(phydev)
--- /dev/null
+diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
+index e0bd013..9e78921 100644
+--- a/net/ieee802154/socket.c
++++ b/net/ieee802154/socket.c
+@@ -182,14 +182,20 @@ static int ieee802154_sock_ioctl(struct
+ static HLIST_HEAD(raw_head);
+ static DEFINE_RWLOCK(raw_lock);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+ static int raw_hash(struct sock *sk)
++#else
++static void raw_hash(struct sock *sk)
++#endif
+ {
+ write_lock_bh(&raw_lock);
+ sk_add_node(sk, &raw_head);
+ sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
+ write_unlock_bh(&raw_lock);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+ return 0;
++#endif
+ }
+
+ static void raw_unhash(struct sock *sk)
+@@ -464,14 +470,20 @@ static inline struct dgram_sock *dgram_s
+ return container_of(sk, struct dgram_sock, sk);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+ static int dgram_hash(struct sock *sk)
++#else
++static void dgram_hash(struct sock *sk)
++#endif
+ {
+ write_lock_bh(&dgram_lock);
+ sk_add_node(sk, &dgram_head);
+ sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
+ write_unlock_bh(&dgram_lock);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+ return 0;
++#endif
+ }
+
+ static void dgram_unhash(struct sock *sk)
+@@ -1031,11 +1043,15 @@ static int ieee802154_create(struct net
+ sock_set_flag(sk, SOCK_ZAPPED);
+
+ if (sk->sk_prot->hash) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+ rc = sk->sk_prot->hash(sk);
+ if (rc) {
+ sk_common_release(sk);
+ goto out;
+ }
++#else
++ sk->sk_prot->hash(sk);
++#endif
+ }
+
+ if (sk->sk_prot->init) {
--- /dev/null
+--- a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
++++ b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
+@@ -2422,12 +2422,23 @@ int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir)
+ */
+ if (priv->mac80211_registered) {
+ char buf[100];
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ struct dentry *mac80211_dir, *dev_dir;
+
+ dev_dir = dbgfs_dir->d_parent;
+ mac80211_dir = priv->hw->wiphy->debugfsdir;
+
+ snprintf(buf, 100, "../../%pd2", dev_dir);
++#else
++ struct dentry *mac80211_dir, *dev_dir, *root_dir;
++
++ dev_dir = dbgfs_dir->d_parent;
++ root_dir = dev_dir->d_parent;
++ mac80211_dir = priv->hw->wiphy->debugfsdir;
++
++ snprintf(buf, 100, "../../%s/%s", root_dir->d_name.name,
++ dev_dir->d_name.name);
++#endif
+
+ if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf))
+ goto err;
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+@@ -1731,8 +1731,13 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+ mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
+
+ if (!mvmvif->dbgfs_dir) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
+ dbgfs_dir);
++#else
++ IWL_ERR(mvm, "Failed to create debugfs directory under %s\n",
++ dbgfs_dir->d_name.name);
++#endif
+ return;
+ }
+
+@@ -1800,15 +1805,28 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+ * find
+ * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
+ */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ snprintf(buf, 100, "../../../%pd3/%pd",
+ dbgfs_dir,
+ mvmvif->dbgfs_dir);
++#else
++ snprintf(buf, 100, "../../../%s/%s/%s/%s",
++ dbgfs_dir->d_parent->d_parent->d_name.name,
++ dbgfs_dir->d_parent->d_name.name,
++ dbgfs_dir->d_name.name,
++ mvmvif->dbgfs_dir->d_name.name);
++#endif
+
+ mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
+ mvm->debugfs_dir, buf);
+ if (!mvmvif->dbgfs_slink)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ IWL_ERR(mvm, "Can't create debugfs symbolic link under %pd\n",
+ dbgfs_dir);
++#else
++ IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n",
++ dbgfs_dir->d_name.name);
++#endif
+ return;
+ err:
+ IWL_ERR(mvm, "Can't create debugfs entity\n");
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+@@ -1942,7 +1942,13 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
+ * Create a symlink with mac80211. It will be removed when mac80211
+ * exists (before the opmode exists which removes the target.)
+ */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+ snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent);
++#else
++ snprintf(buf, 100, "../../%s/%s",
++ dbgfs_dir->d_parent->d_parent->d_name.name,
++ dbgfs_dir->d_parent->d_name.name);
++#endif
+ if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
+ goto err;
+
--- /dev/null
+--- a/drivers/bcma/main.c
++++ b/drivers/bcma/main.c
+@@ -156,6 +156,7 @@ static struct device_node *bcma_of_find_
+ return NULL;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ static int bcma_of_irq_parse(struct device *parent,
+ struct bcma_device *core,
+ struct of_phandle_args *out_irq, int num)
+@@ -195,6 +196,13 @@ static unsigned int bcma_of_get_irq(stru
+
+ return irq_create_of_mapping(&out_irq);
+ }
++#else
++static unsigned int bcma_of_get_irq(struct device *parent,
++ struct bcma_device *core, int num)
++{
++ return 0;
++}
++#endif
+
+ static void bcma_of_fill_device(struct platform_device *parent,
+ struct bcma_device *core)
--- /dev/null
+diff --git a/net/mac80211/fils_aead.c b/net/mac80211/fils_aead.c
+index ecfdd97758a3..95fc9669ea4f 100644
+--- a/net/mac80211/fils_aead.c
++++ b/net/mac80211/fils_aead.c
+@@ -1,3 +1,4 @@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
+ /*
+ * FILS AEAD for (Re)Association Request/Response frames
+ * Copyright 2016, Qualcomm Atheros, Inc.
+@@ -340,3 +341,4 @@ int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
+ *frame_len -= AES_BLOCK_SIZE;
+ return 0;
+ }
++#endif
+diff --git a/net/mac80211/fils_aead.h b/net/mac80211/fils_aead.h
+index fbc65232f0b3..482bc5fcdd18 100644
+--- a/net/mac80211/fils_aead.h
++++ b/net/mac80211/fils_aead.h
+@@ -10,10 +10,27 @@
+ #ifndef FILS_AEAD_H
+ #define FILS_AEAD_H
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
+ int fils_encrypt_assoc_req(struct sk_buff *skb,
+ struct ieee80211_mgd_assoc_data *assoc_data);
+ int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
+ u8 *frame, size_t *frame_len,
+ struct ieee80211_mgd_assoc_data *assoc_data);
++#else
++static inline
++int fils_encrypt_assoc_req(struct sk_buff *skb,
++ struct ieee80211_mgd_assoc_data *assoc_data)
++{
++ return -EOPNOTSUPP;
++}
++
++static inline
++int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
++ u8 *frame, size_t *frame_len,
++ struct ieee80211_mgd_assoc_data *assoc_data)
++{
++ return -EOPNOTSUPP;
++}
++#endif
+
+ #endif /* FILS_AEAD_H */
+diff --git a/net/mac80211/main.c b/net/mac80211/main.c
+index a6ecbbf0f47f..afc1517e9729 100644
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -553,7 +553,9 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
+ NL80211_FEATURE_MAC_ON_CREATE |
+ NL80211_FEATURE_USERSPACE_MPM |
+ NL80211_FEATURE_FULL_AP_CLIENT_STATE;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
+ wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_STA);
++#endif
+
+ if (!ops->hw_scan)
+ wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
--- /dev/null
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+@@ -637,7 +637,11 @@ send:
+ }
+
+ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
++ unsigned long *temperature)
++#else
+ int *temperature)
++#endif
+ {
+ struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+ int ret;
+@@ -662,7 +666,11 @@ out:
+ }
+
+ static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
++ int trip, unsigned long *temp)
++#else
+ int trip, int *temp)
++#endif
+ {
+ struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+
+@@ -685,8 +693,13 @@ static int iwl_mvm_tzone_get_trip_type(s
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
++ int trip, unsigned long temp)
++#else
+ int trip, int temp)
++#endif
+ {
+ struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+ struct iwl_mvm_thermal_device *tzone;
+@@ -739,12 +752,15 @@ out:
+ mutex_unlock(&mvm->mutex);
+ return ret;
+ }
++#endif /* >= 3.6 */
+
+ static struct thermal_zone_device_ops tzone_ops = {
+ .get_temp = iwl_mvm_tzone_get_temp,
+ .get_trip_temp = iwl_mvm_tzone_get_trip_temp,
+ .get_trip_type = iwl_mvm_tzone_get_trip_type,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
++#endif
+ };
+
+ /* make all trips writable */
--- /dev/null
+--- a/net/wireless/util.c
++++ b/net/wireless/util.c
+@@ -746,7 +746,11 @@ void ieee80211_amsdu_to_8023s(struct sk_
+ u8 *payload;
+ int offset = 0, remaining, err;
+ struct ethhdr eth;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
++ bool reuse_frag = 0;
++#else
+ bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb);
++#endif
+ bool reuse_skb = false;
+ bool last = false;
+
--- /dev/null
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -2078,7 +2078,11 @@ static int igb_set_features(struct net_d
+
+ static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+ struct net_device *dev,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
++ const unsigned char *addr,
++#else
+ const unsigned char *addr, u16 vid,
++#endif
+ u16 flags)
+ {
+ /* guarantee we can provide a unique filter for the unicast address */
--- /dev/null
+@initialize:python@
+@@
+
+first_ops = 0
+
+@r@
+identifier OPS;
+position p;
+@@
+
+struct net_device_ops OPS@p = { ... };
+
+@script:python depends on r@
+@@
+
+first_ops = 0
+
+@script:python@
+p << r.p;
+@@
+
+ln = int(p[0].line)
+if first_ops == 0 or ln < first_ops:
+ first_ops = ln
+
+@script:python@
+p << r.p;
+@@
+
+ln = int(p[0].line)
+if not(first_ops == ln):
+ cocci.include_match(False)
+
+@r1 exists@
+expression ndevexp, e1, e2;
+identifier func;
+@@
+func(...) {
+ <+...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
+ ndevexp->min_mtu = e1;
+ ndevexp->max_mtu = e2;
++#endif
+ ...+>
+}
+
+@r2@
+expression r1.e1,r1.e2;
+identifier r.OPS;
+@@
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
++ static int __change_mtu(struct net_device *ndev, int new_mtu)
++ {
++ if (new_mtu < e1 || new_mtu > e2)
++ return -EINVAL;
++ ndev->mtu = new_mtu;
++ return 0;
++ }
++#endif
++
+struct net_device_ops OPS = {
+ ...
+};
+
+@depends on r2@
+identifier OPS;
+@@
+
+struct net_device_ops OPS = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
++ .ndo_change_mtu = __change_mtu,
++#endif
+ ...
+};
+
--- /dev/null
+@@
+expression SKB;
+expression A, V;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+SKB->wifi_acked_valid = V;
+SKB->wifi_acked = A;
++#endif
+++ /dev/null
---- a/compat/crypto-ccm.c
-+++ b/compat/crypto-ccm.c
-@@ -13,13 +13,44 @@
- #include <crypto/internal/aead.h>
- #include <crypto/internal/skcipher.h>
- #include <crypto/scatterwalk.h>
-+#include <crypto/algapi.h>
- #include <linux/err.h>
- #include <linux/init.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/slab.h>
-+#include <linux/version.h>
-
--#include "internal.h"
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
-+/* consider properly backporting this? */
-+static int crypto_memneq(const void *a, const void *b, size_t size)
-+{
-+ unsigned long neq = 0;
-+
-+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-+ while (size >= sizeof(unsigned long)) {
-+ neq |= *(unsigned long *)a ^ *(unsigned long *)b;
-+ /* OPTIMIZER_HIDE_VAR(neq); */
-+ barrier();
-+ a += sizeof(unsigned long);
-+ b += sizeof(unsigned long);
-+ size -= sizeof(unsigned long);
-+ }
-+#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
-+ while (size > 0) {
-+ neq |= *(unsigned char *)a ^ *(unsigned char *)b;
-+ /* OPTIMIZER_HIDE_VAR(neq); */
-+ barrier();
-+ a += 1;
-+ b += 1;
-+ size -= 1;
-+ }
-+ return neq != 0UL ? 1 : 0;
-+}
-+#endif
-+
-+/* from internal.h */
-+struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
-
- struct ccm_instance_ctx {
- struct crypto_skcipher_spawn ctr;
-@@ -897,7 +928,7 @@ static struct crypto_template crypto_rfc
- .module = THIS_MODULE,
- };
-
--static int __init crypto_ccm_module_init(void)
-+int __init crypto_ccm_module_init(void)
- {
- int err;
-
-@@ -923,18 +954,9 @@ out_undo_base:
- goto out;
- }
-
--static void __exit crypto_ccm_module_exit(void)
-+void __exit crypto_ccm_module_exit(void)
- {
- crypto_unregister_template(&crypto_rfc4309_tmpl);
- crypto_unregister_template(&crypto_ccm_tmpl);
- crypto_unregister_template(&crypto_ccm_base_tmpl);
- }
--
--module_init(crypto_ccm_module_init);
--module_exit(crypto_ccm_module_exit);
--
--MODULE_LICENSE("GPL");
--MODULE_DESCRIPTION("Counter with CBC MAC");
--MODULE_ALIAS_CRYPTO("ccm_base");
--MODULE_ALIAS_CRYPTO("rfc4309");
--MODULE_ALIAS_CRYPTO("ccm");
+++ /dev/null
---- a/compat/crypto-skcipher.c
-+++ b/compat/crypto-skcipher.c
-@@ -18,7 +18,28 @@
- #include <linux/bug.h>
- #include <linux/module.h>
-
--#include "internal.h"
-+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
-+ u32 mask);
-+
-+void *crypto_alloc_tfm(const char *alg_name,
-+ const struct crypto_type *frontend, u32 type, u32 mask);
-+
-+struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
-+
-+static inline void *crypto_skcipher_ctx(struct crypto_skcipher *tfm)
-+{
-+ return crypto_tfm_ctx(&tfm->base);
-+}
-+
-+static inline void *skcipher_request_ctx(struct skcipher_request *req)
-+{
-+ return req->__ctx;
-+}
-+
-+static inline u32 skcipher_request_flags(struct skcipher_request *req)
-+{
-+ return req->base.flags;
-+}
-
- static unsigned int crypto_skcipher_extsize(struct crypto_alg *alg)
- {
+++ /dev/null
---- a/compat/drivers-base-devcoredump.c
-+++ b/compat/drivers-base-devcoredump.c
-@@ -30,6 +30,7 @@
- #include <linux/slab.h>
- #include <linux/fs.h>
- #include <linux/workqueue.h>
-+#include "backports.h"
-
- static struct class devcd_class;
-
-@@ -39,6 +40,10 @@ static bool devcd_disabled;
- /* if data isn't read by userspace after 5 minutes then delete it */
- #define DEVCD_TIMEOUT (HZ * 60 * 5)
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
-+static struct bin_attribute devcd_attr_data;
-+#endif
-+
- struct devcd_entry {
- struct device devcd_dev;
- const void *data;
-@@ -68,8 +73,7 @@ static void devcd_dev_release(struct dev
- * a struct device to know when it goes away?
- */
- if (devcd->failing_dev->kobj.sd)
-- sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj,
-- "devcoredump");
-+ sysfs_remove_link(&devcd->failing_dev->kobj, "devcoredump");
-
- put_device(devcd->failing_dev);
- kfree(devcd);
-@@ -81,6 +85,9 @@ static void devcd_del(struct work_struct
-
- devcd = container_of(wk, struct devcd_entry, del_wk.work);
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
-+ device_remove_bin_file(&devcd->devcd_dev, &devcd_attr_data);
-+#endif
- device_del(&devcd->devcd_dev);
- put_device(&devcd->devcd_dev);
- }
-@@ -114,6 +121,7 @@ static struct bin_attribute devcd_attr_d
- .write = devcd_data_write,
- };
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
- static struct bin_attribute *devcd_dev_bin_attrs[] = {
- &devcd_attr_data, NULL,
- };
-@@ -125,6 +133,7 @@ static const struct attribute_group devc
- static const struct attribute_group *devcd_dev_groups[] = {
- &devcd_dev_group, NULL,
- };
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) */
-
- static int devcd_free(struct device *dev, void *data)
- {
-@@ -169,7 +178,9 @@ static struct class devcd_class = {
- .name = "devcoredump",
- .owner = THIS_MODULE,
- .dev_release = devcd_dev_release,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
- .dev_groups = devcd_dev_groups,
-+#endif
- .class_groups = devcd_class_groups,
- };
-
-@@ -270,6 +281,11 @@ void dev_coredumpm(struct device *dev, s
- if (device_add(&devcd->devcd_dev))
- goto put_device;
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
-+ if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
-+ goto put_device;
-+#endif
-+
- if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
- "failing_device"))
- /* nothing - symlink will be missing */;
-@@ -291,15 +307,13 @@ void dev_coredumpm(struct device *dev, s
- }
- EXPORT_SYMBOL_GPL(dev_coredumpm);
-
--static int __init devcoredump_init(void)
-+int __init devcoredump_init(void)
- {
- return class_register(&devcd_class);
- }
--__initcall(devcoredump_init);
-
--static void __exit devcoredump_exit(void)
-+void __exit devcoredump_exit(void)
- {
- class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
- class_unregister(&devcd_class);
- }
--__exitcall(devcoredump_exit);
---- a/include/linux/backport-devcoredump.h
-+++ b/include/linux/backport-devcoredump.h
-@@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(struct scatterlist *tab
- }
-
-
--#ifdef CONFIG_DEV_COREDUMP
-+#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP
- void dev_coredumpv(struct device *dev, void *data, size_t datalen,
- gfp_t gfp);
-
-@@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct device *dev, struct
- {
- _devcd_free_sgtable(table);
- }
--#endif /* CONFIG_DEV_COREDUMP */
-+#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */
-
- #endif /* __DEVCOREDUMP_H */
---- a/include/linux/devcoredump.h
-+++ b/include/linux/devcoredump.h
-@@ -1,6 +1,7 @@
- /* Automatically created during backport process */
- #ifndef CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP
- #include_next <linux/devcoredump.h>
-+#include <linux/bp-devcoredump.h>
- #else
- #undef dev_coredumpv
- #define dev_coredumpv LINUX_BACKPORT(dev_coredumpv)
+++ /dev/null
---- a/compat/net-core-flow_dissector.c
-+++ b/compat/net-core-flow_dissector.c
-@@ -177,229 +177,10 @@ ipv6:
-
- flow->ip_proto = ip_proto;
- flow->ports = skb_flow_get_ports(skb, nhoff, ip_proto);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
- flow->thoff = (u16) nhoff;
-+#endif
-
- return true;
- }
- EXPORT_SYMBOL(skb_flow_dissect);
--
--static u32 hashrnd __read_mostly;
--static __always_inline void __flow_hash_secret_init(void)
--{
-- net_get_random_once(&hashrnd, sizeof(hashrnd));
--}
--
--static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
--{
-- __flow_hash_secret_init();
-- return jhash_3words(a, b, c, hashrnd);
--}
--
--static __always_inline u32 __flow_hash_1word(u32 a)
--{
-- __flow_hash_secret_init();
-- return jhash_1word(a, hashrnd);
--}
--
--/*
-- * __skb_get_hash: calculate a flow hash based on src/dst addresses
-- * and src/dst port numbers. Sets hash in skb to non-zero hash value
-- * on success, zero indicates no valid hash. Also, sets l4_hash in skb
-- * if hash is a canonical 4-tuple hash over transport ports.
-- */
--void __skb_get_hash(struct sk_buff *skb)
--{
-- struct flow_keys keys;
-- u32 hash;
--
-- if (!skb_flow_dissect(skb, &keys))
-- return;
--
-- if (keys.ports)
-- skb->l4_hash = 1;
--
-- /* get a consistent hash (same value on both flow directions) */
-- if (((__force u32)keys.dst < (__force u32)keys.src) ||
-- (((__force u32)keys.dst == (__force u32)keys.src) &&
-- ((__force u16)keys.port16[1] < (__force u16)keys.port16[0]))) {
-- swap(keys.dst, keys.src);
-- swap(keys.port16[0], keys.port16[1]);
-- }
--
-- hash = __flow_hash_3words((__force u32)keys.dst,
-- (__force u32)keys.src,
-- (__force u32)keys.ports);
-- if (!hash)
-- hash = 1;
--
-- skb->hash = hash;
--}
--EXPORT_SYMBOL(__skb_get_hash);
--
--/*
-- * Returns a Tx hash based on the given packet descriptor a Tx queues' number
-- * to be used as a distribution range.
-- */
--u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
-- unsigned int num_tx_queues)
--{
-- u32 hash;
-- u16 qoffset = 0;
-- u16 qcount = num_tx_queues;
--
-- if (skb_rx_queue_recorded(skb)) {
-- hash = skb_get_rx_queue(skb);
-- while (unlikely(hash >= num_tx_queues))
-- hash -= num_tx_queues;
-- return hash;
-- }
--
-- if (dev->num_tc) {
-- u8 tc = netdev_get_prio_tc_map(dev, skb->priority);
-- qoffset = dev->tc_to_txq[tc].offset;
-- qcount = dev->tc_to_txq[tc].count;
-- }
--
-- if (skb->sk && skb->sk->sk_hash)
-- hash = skb->sk->sk_hash;
-- else
-- hash = (__force u16) skb->protocol;
-- hash = __flow_hash_1word(hash);
--
-- return (u16) (((u64) hash * qcount) >> 32) + qoffset;
--}
--EXPORT_SYMBOL(__skb_tx_hash);
--
--/* __skb_get_poff() returns the offset to the payload as far as it could
-- * be dissected. The main user is currently BPF, so that we can dynamically
-- * truncate packets without needing to push actual payload to the user
-- * space and can analyze headers only, instead.
-- */
--u32 __skb_get_poff(const struct sk_buff *skb)
--{
-- struct flow_keys keys;
-- u32 poff = 0;
--
-- if (!skb_flow_dissect(skb, &keys))
-- return 0;
--
-- poff += keys.thoff;
-- switch (keys.ip_proto) {
-- case IPPROTO_TCP: {
-- const struct tcphdr *tcph;
-- struct tcphdr _tcph;
--
-- tcph = skb_header_pointer(skb, poff, sizeof(_tcph), &_tcph);
-- if (!tcph)
-- return poff;
--
-- poff += max_t(u32, sizeof(struct tcphdr), tcph->doff * 4);
-- break;
-- }
-- case IPPROTO_UDP:
-- case IPPROTO_UDPLITE:
-- poff += sizeof(struct udphdr);
-- break;
-- /* For the rest, we do not really care about header
-- * extensions at this point for now.
-- */
-- case IPPROTO_ICMP:
-- poff += sizeof(struct icmphdr);
-- break;
-- case IPPROTO_ICMPV6:
-- poff += sizeof(struct icmp6hdr);
-- break;
-- case IPPROTO_IGMP:
-- poff += sizeof(struct igmphdr);
-- break;
-- case IPPROTO_DCCP:
-- poff += sizeof(struct dccp_hdr);
-- break;
-- case IPPROTO_SCTP:
-- poff += sizeof(struct sctphdr);
-- break;
-- }
--
-- return poff;
--}
--
--static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
--{
--#ifdef CONFIG_XPS
-- struct xps_dev_maps *dev_maps;
-- struct xps_map *map;
-- int queue_index = -1;
--
-- rcu_read_lock();
-- dev_maps = rcu_dereference(dev->xps_maps);
-- if (dev_maps) {
-- map = rcu_dereference(
-- dev_maps->cpu_map[raw_smp_processor_id()]);
-- if (map) {
-- if (map->len == 1)
-- queue_index = map->queues[0];
-- else {
-- u32 hash;
-- if (skb->sk && skb->sk->sk_hash)
-- hash = skb->sk->sk_hash;
-- else
-- hash = (__force u16) skb->protocol ^
-- skb->hash;
-- hash = __flow_hash_1word(hash);
-- queue_index = map->queues[
-- ((u64)hash * map->len) >> 32];
-- }
-- if (unlikely(queue_index >= dev->real_num_tx_queues))
-- queue_index = -1;
-- }
-- }
-- rcu_read_unlock();
--
-- return queue_index;
--#else
-- return -1;
--#endif
--}
--
--static u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
--{
-- struct sock *sk = skb->sk;
-- int queue_index = sk_tx_queue_get(sk);
--
-- if (queue_index < 0 || skb->ooo_okay ||
-- queue_index >= dev->real_num_tx_queues) {
-- int new_index = get_xps_queue(dev, skb);
-- if (new_index < 0)
-- new_index = skb_tx_hash(dev, skb);
--
-- if (queue_index != new_index && sk &&
-- rcu_access_pointer(sk->sk_dst_cache))
-- sk_tx_queue_set(sk, new_index);
--
-- queue_index = new_index;
-- }
--
-- return queue_index;
--}
--
--struct netdev_queue *netdev_pick_tx(struct net_device *dev,
-- struct sk_buff *skb,
-- void *accel_priv)
--{
-- int queue_index = 0;
--
-- if (dev->real_num_tx_queues != 1) {
-- const struct net_device_ops *ops = dev->netdev_ops;
-- if (ops->ndo_select_queue)
-- queue_index = ops->ndo_select_queue(dev, skb, accel_priv,
-- __netdev_pick_tx);
-- else
-- queue_index = __netdev_pick_tx(dev, skb);
--
-- if (!accel_priv)
-- queue_index = netdev_cap_txqueue(dev, queue_index);
-- }
--
-- skb_set_queue_mapping(skb, queue_index);
-- return netdev_get_tx_queue(dev, queue_index);
--}
+++ /dev/null
-/*
-The new attribute sysfs group was added onto struct class via
-commit d05a6f96c
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains d05a6f96c
-v3.11-rc2~18^2~3
-
-This backpoort makes use of the helpers to backport this more efficiently.
-Refer to the INFO file for documentation there on that.
-
-commit d05a6f96c76062b5f25858ac02cf677602076f7e
-Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Date: Sun Jul 14 16:05:58 2013 -0700
-
- driver core: add default groups to struct class
-
- We should be using groups, not attribute lists, for classes to allow
- subdirectories, and soon, binary files. Groups are just more flexible
- overall, so add them.
-
- The dev_attrs list will go away after all in-kernel users are converted
- to use dev_groups.
-
- Reviewed-by: Guenter Roeck <linux@roeck-us.net>
- Tested-by: Guenter Roeck <linux@roeck-us.net>
- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-*/
-
-@ attribute_group @
-identifier group;
-declarer name ATTRIBUTE_GROUPS;
-@@
-
-ATTRIBUTE_GROUPS(group);
-
-@script:python attribute_groups_name@
-group << attribute_group.group;
-groups;
-@@
-coccinelle.groups = group + "_groups"
-
-@ class_group @
-identifier group_class;
-identifier attribute_groups_name.groups;
-fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
-@@
-
-struct class group_class = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
- .dev_groups = groups,
-+#else
-+ .dev_attrs = group_dev_attr,
-+#endif
-};
-
-@ attribute_group_mod depends on class_group @
-declarer name ATTRIBUTE_GROUPS_BACKPORT;
-identifier attribute_group.group;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
-ATTRIBUTE_GROUPS(group);
-+#else
-+#define BP_ATTR_GRP_STRUCT device_attribute
-+ATTRIBUTE_GROUPS_BACKPORT(group);
-+#endif
-
-@ class_registering @
-identifier class_register, ret;
-identifier class_group.group_class;
-fresh identifier group_class_init = "init_" ## attribute_group.group ## "_attrs";
-@@
-
-(
-+ group_class_init();
- return class_register(&group_class);
-|
-+ group_class_init();
- ret = class_register(&group_class);
-)
+++ /dev/null
-/*
-The new attribute sysfs group was added onto struct bus_type via
-commit fa6fdb33b
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains fa6fdb33b
-v3.12-rc1~184^2~89
-
-This backport makes use of the helpers to backport this more efficiently.
-Refer to the INFO file for documentation there on that.
-
-commit fa6fdb33b486a8afc5439c504da8d581e142c77d
-Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Date: Thu Aug 8 15:22:55 2013 -0700
-
- driver core: bus_type: add dev_groups
-
- attribute groups are much more flexible than just a list of attributes,
- due to their support for visibility of the attributes, and binary
- attributes. Add dev_groups to struct bus_type which should be used
- instead of dev_attrs.
-
- dev_attrs will be removed from the structure soon.
-
- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-*/
-
-@ attribute_group @
-identifier group;
-declarer name ATTRIBUTE_GROUPS;
-@@
-
-ATTRIBUTE_GROUPS(group);
-
-@script:python attribute_groups_name@
-group << attribute_group.group;
-groups;
-@@
-coccinelle.groups = group + "_groups"
-
-@ bus_group @
-identifier group_bus;
-identifier attribute_groups_name.groups;
-fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
-@@
-
-struct bus_type group_bus = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- .dev_groups = groups,
-+#else
-+ .dev_attrs = group_dev_attr,
-+#endif
-};
-
-@ attribute_group_mod depends on bus_group @
-declarer name ATTRIBUTE_GROUPS_BACKPORT;
-identifier attribute_group.group;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
-ATTRIBUTE_GROUPS(group);
-+#else
-+#define BP_ATTR_GRP_STRUCT device_attribute
-+ATTRIBUTE_GROUPS_BACKPORT(group);
-+#endif
-
-@ bus_registering @
-identifier bus_register, ret;
-identifier bus_group.group_bus;
-fresh identifier group_bus_init = "init_" ## attribute_group.group ## "_attrs";
-@@
-
-(
-+ group_bus_init();
- return bus_register(&group_bus);
-|
-+ group_bus_init();
- ret = bus_register(&group_bus);
-)
+++ /dev/null
-/* see upstream commit ced6473e74867 */
-
-@ attribute_group @
-identifier group;
-declarer name ATTRIBUTE_GROUPS;
-@@
-
-ATTRIBUTE_GROUPS(group);
-
-@script:python attribute_groups_name@
-group << attribute_group.group;
-groups;
-@@
-coccinelle.groups = group + "_groups"
-
-@ class_group @
-identifier group_class;
-identifier attribute_groups_name.groups;
-fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
-@@
-
-struct class group_class = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
- .class_groups = groups,
-+#else
-+ .class_attrs = group_dev_attr,
-+#endif
-};
-
-@ attribute_group_mod depends on class_group @
-declarer name ATTRIBUTE_GROUPS_BACKPORT;
-identifier attribute_group.group;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
-ATTRIBUTE_GROUPS(group);
-+#else
-+#define BP_ATTR_GRP_STRUCT class_attribute
-+ATTRIBUTE_GROUPS_BACKPORT(group);
-+#endif
-
-@ class_registering @
-identifier class_register, ret;
-identifier class_group.group_class;
-fresh identifier group_class_init = "init_" ## attribute_group.group ## "_attrs";
-@@
-
-(
-+ group_class_init();
- return class_register(&group_class);
-|
-+ group_class_init();
- ret = class_register(&group_class);
-)
+++ /dev/null
-The new attribute sysfs group was added via these commits:
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains f2f37f58b
-v3.11-rc2~18^2~9
-mcgrof@ergon ~/linux (git::master)$ git describe --contains 3493f69f4
-v3.11-rc2~18^2~2
-
-We backport them with our own respective set of helpers. Each new data
-structure that gets an attribute group needs a respective SmPL set of
-rules for the transformation. We might be able to share the rules for
-lookup / indexing between rules some how. These lookup reveal would
-be used for inherent structural searches, pivots, if you will.
-
-The changes that added the new APIs:
-
-commit f2f37f58b1b933b06d6d84e80a31a1b500fb0db2
-Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Date: Sun Jul 14 16:05:52 2013 -0700
-
- sysfs.h: add ATTRIBUTE_GROUPS() macro
-
- To make it easier for driver subsystems to work with attribute groups,
- create the ATTRIBUTE_GROUPS macro to remove some of the repetitive
- typing for the most common use for attribute groups.
-
- Reviewed-by: Guenter Roeck <linux@roeck-us.net>
- Tested-by: Guenter Roeck <linux@roeck-us.net>
- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
-commit 3493f69f4c4e8703961919a9a56c2d2e6a25b46f
-Author: Oliver Schinagl <oliver@schinagl.nl>
-Date: Sun Jul 14 16:05:59 2013 -0700
-
- sysfs: add more helper macro's for (bin_)attribute(_groups)
-
- With the recent changes to sysfs there's various helper macro's.
- However there's no RW, RO BIN_ helper macro's. This patch adds them.
-
- Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+++ /dev/null
-/* convert gpio: change member .dev to .parent
- *
- * add semantic patch which uses the dev member of struct gpio_chip on
- * kenrel version < 4.5 This change was done in upstream kernel commit
- * 58383c78 "gpio: change member .dev to .parent".
- */
-
-@r1@
-struct gpio_chip *chip;
-expression E1;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
- chip->parent = E1;
-+#else
-+chip->dev = E1;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) */
-@r2@
-struct gpio_chip chip;
-expression E2;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
- chip.parent = E2;
-+#else
-+chip.dev = E2;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) */
+++ /dev/null
-This holds collateral evolutions that apply to any driver we backport
+++ /dev/null
-Commit c60520fa needs to be reverted for older kernels because
-although we can backport some new DMA changes some other
-larger changes ended up extending some core dma data
-structures, for details see bca0fa5f as an example. We're
-aided with this revert by having added vb2_mmap_pfn_range() to
-compat. The main reason to revert is usage of the new
-dma_mmap_coherent() and core changes required via
-bca0fa5f.
-
-commit c60520fa50cd86d64bc8ebb34300ddc4ca91393d
-Author: Marek Szyprowski <m.szyprowski@samsung.com>
-Date: Thu Jun 14 11:32:21 2012 -0300
-
- [media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
-
- Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes
- vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent
- Pinchart. The function is no longer used in vb2 code.
-
- Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
- Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
- Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
- Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
- Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-
---- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
-+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
-@@ -177,6 +177,52 @@ static void *vb2_dc_alloc(void *alloc_ct
- return buf;
- }
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-+static int
-+backport_vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
-+ unsigned long size,
-+ const struct vm_operations_struct *vm_ops,
-+ void *priv)
-+{
-+ int ret;
-+
-+ size = min_t(unsigned long, vma->vm_end - vma->vm_start, size);
-+
-+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-+ ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT,
-+ size, vma->vm_page_prot);
-+ if (ret) {
-+ printk(KERN_ERR "Remapping memory failed, error: %d\n", ret);
-+ return ret;
-+ }
-+
-+ vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
-+ vma->vm_private_data = priv;
-+ vma->vm_ops = vm_ops;
-+
-+ vma->vm_ops->open(vma);
-+
-+ pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n",
-+ __func__, paddr, vma->vm_start, size);
-+
-+ return 0;
-+}
-+
-+static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
-+{
-+ struct vb2_dc_buf *buf = buf_priv;
-+
-+ if (!buf) {
-+ printk(KERN_ERR "No buffer to map\n");
-+ return -EINVAL;
-+ }
-+
-+ return backport_vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,
-+ &vb2_common_vm_ops, &buf->handler);
-+}
-+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
-+#else
- static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
- {
- struct vb2_dc_buf *buf = buf_priv;
-@@ -213,6 +259,7 @@ static int vb2_dc_mmap(void *buf_priv, s
-
- return 0;
- }
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
-
- /*********************************************/
- /* DMABUF ops for exporters */
+++ /dev/null
-@@
-struct netlink_notify *notify;
-@@
--notify->portid
-+netlink_notify_portid(notify)
-
-@@
-struct genl_info *info;
-@@
--info->snd_portid
-+genl_info_snd_portid(info)
-
-@@
-expression skb;
-@@
--NETLINK_CB(skb).portid
-+NETLINK_CB_PORTID(skb)
+++ /dev/null
-On older kernels, we can't do this workaround, so if you use
-an old 64-bit kernel with compat you'd better upgrade.
-
-For more details of this work around refer to this commit
-upstream that deals with the code added:
-
-commit 645e77def93f1dd0e211c7244fbe152dac8a7100
-Author: Johannes Berg <johannes.berg@intel.com>
-Date: Fri Mar 1 14:03:49 2013 +0100
-
- nl80211: increase wiphy dump size dynamically
-
- Given a device with many channels capabilities the wiphy
- information can still overflow even though its size in
- 3.9 was reduced to 3.8 levels. For new userspace and
- kernel 3.10 we're going to implement a new "split dump"
- protocol that can use multiple messages per wiphy.
-
- For now though, add a workaround to be able to send more
- information to userspace. Since generic netlink doesn't
- have a way to set the minimum dump size globally, and we
- wouldn't really want to set it globally anyway, increase
- the size only when needed, as described in the comments.
- As userspace might not be prepared for large buffers, we
- can only use 4k.
-
- Also increase the size for the get_wiphy command.
-
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -1846,6 +1846,7 @@ static int nl80211_dump_wiphy(struct sk_
- cb->nlh->nlmsg_seq,
- NLM_F_MULTI, state);
- if (ret < 0) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- /*
- * If sending the wiphy data didn't fit (ENOBUFS
- * or EMSGSIZE returned), this SKB is still
-@@ -1867,6 +1868,7 @@ static int nl80211_dump_wiphy(struct sk_
- rtnl_unlock();
- return 1;
- }
-+#endif
- idx--;
- break;
- }
+++ /dev/null
-This is a tricky one.
-
-Consider a kernel that has this code in net/wireless/wext-core.c:
-
-#ifdef CONFIG_CFG80211_WEXT
- if (dev->ieee80211_ptr && dev->ieee80211_ptr->wiphy)
- handlers = dev->ieee80211_ptr->wiphy->wext;
-#endif
-#ifdef CONFIG_WIRELESS_EXT
- if (dev->wireless_handlers)
- handlers = dev->wireless_handlers;
-#endif
-
-If a kernel is compiled without CONFIG_WIRELESS_EXT then
-compat-drivers can't do wireless extensions against it.
-However, if the kernel is compiled with CONFIG_CFG80211_WEXT
-then it will try to get the wext handlers from struct wiphy.
-
-Now, struct wiphy in the base kernel and struct wiphy in
-compat-drivers don't match, so the kernel crashes!!
-
-To fix this, add lots of padding to compat-drivers's
-struct wiphy so that the "wext" pointer is guaranteed
-to be NULL.
-
-Make sure the padding is larger than the struct so we
-don't ever run into this again because the wext pointer
-moved due to struct enlargements.
-
-
+++ /dev/null
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -3222,6 +3222,9 @@ struct wiphy_vendor_command {
- struct wiphy {
- /* assign these fields before you register the wiphy */
-
-+#define WIPHY_COMPAT_PAD_SIZE 2048
-+ u8 padding[WIPHY_COMPAT_PAD_SIZE];
-+
- /* permanent MAC address(es) */
- u8 perm_addr[ETH_ALEN];
- u8 addr_mask[ETH_ALEN];
+++ /dev/null
---- a/net/wireless/core.c
-+++ b/net/wireless/core.c
-@@ -344,6 +344,17 @@ struct wiphy *wiphy_new_nm(const struct
- struct cfg80211_registered_device *rdev;
- int alloc_size;
-
-+ /*
-+ * Make sure the padding is >= the rest of the struct so that we
-+ * always keep it large enough to pad out the entire original
-+ * kernel's struct. We really only need to make sure it's larger
-+ * than the kernel compat is compiled against, but since it'll
-+ * only increase in size make sure it's larger than the current
-+ * version of it. Subtract since it's included.
-+ */
-+ BUILD_BUG_ON(WIPHY_COMPAT_PAD_SIZE <
-+ sizeof(struct wiphy) - WIPHY_COMPAT_PAD_SIZE);
-+
- WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
- WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
- WARN_ON(ops->connect && !ops->disconnect);
+++ /dev/null
-There's no way to build wireless extensions out of tree
-so remove the Kconfig options for them.
-
---- a/net/wireless/Kconfig
-+++ b/net/wireless/Kconfig
-@@ -1,21 +1,3 @@
--config WIRELESS_EXT
-- bool
--
--config WEXT_CORE
-- def_bool y
-- depends on CFG80211_WEXT || WIRELESS_EXT
--
--config WEXT_PROC
-- def_bool y
-- depends on PROC_FS
-- depends on WEXT_CORE
--
--config WEXT_SPY
-- bool
--
--config WEXT_PRIV
-- bool
--
- config CFG80211
- tristate "cfg80211 - wireless configuration API"
- depends on RFKILL || !RFKILL
-@@ -174,7 +156,7 @@ config CFG80211_CRDA_SUPPORT
- config CFG80211_WEXT
- bool "cfg80211 wireless extensions compatibility" if !CFG80211_WEXT_EXPORT
- depends on CFG80211
-- select WEXT_CORE
-+ depends on WEXT_CORE
- default y if CFG80211_WEXT_EXPORT
- help
- Enable this option if you need old userspace for wireless
+++ /dev/null
---- a/drivers/net/usb/Makefile
-+++ b/drivers/net/usb/Makefile
-@@ -10,7 +10,6 @@ obj-$(CONFIG_USB_RTL8152) += r8152.o
- obj-$(CONFIG_USB_HSO) += hso.o
- obj-$(CONFIG_USB_LAN78XX) += lan78xx.o
- obj-$(CONFIG_USB_NET_AX8817X) += asix.o
--asix-y := asix_devices.o asix_common.o ax88172a.o
- obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o
- obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
- obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o
+++ /dev/null
-This is required unless we add some macro wrappers for this
-type of static work upstream but not sure if that is a good
-idea yet.
-
---- a/net/ieee802154/reassembly.c
-+++ b/net/ieee802154/reassembly.c
-@@ -97,7 +97,11 @@ static void lowpan_frag_expire(unsigned
- struct net *net;
-
- fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
-+#else
-+ net = &init_net;
-+#endif
-
- spin_lock(&fq->q.lock);
-
-@@ -395,24 +399,44 @@ static int zero;
- static struct ctl_table lowpan_frags_ns_ctl_table[] = {
- {
- .procname = "6lowpanfrag_high_thresh",
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- .data = &init_net.ieee802154_lowpan.frags.high_thresh,
-+#else
-+ .data = &ieee802154_lowpan.frags.high_thresh,
-+#endif
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- .extra1 = &init_net.ieee802154_lowpan.frags.low_thresh
-+#else
-+ .extra1 = &ieee802154_lowpan.frags.low_thresh
-+#endif
- },
- {
- .procname = "6lowpanfrag_low_thresh",
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- .data = &init_net.ieee802154_lowpan.frags.low_thresh,
-+#else
-+ .data = &ieee802154_lowpan.frags.low_thresh,
-+#endif
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = &zero,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- .extra2 = &init_net.ieee802154_lowpan.frags.high_thresh
-+#else
-+ .extra2 = &ieee802154_lowpan.frags.high_thresh
-+#endif
- },
- {
- .procname = "6lowpanfrag_time",
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
- .data = &init_net.ieee802154_lowpan.frags.timeout,
-+#else
-+ .data = &ieee802154_lowpan.frags.timeout,
-+#endif
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec_jiffies,
+++ /dev/null
-Domain specific backport for inet_frag_lru_move()
-This requires two parts, the data structure changes
-and then domain specific inet_frag_lru_move() define.
-
---- a/net/ieee802154/reassembly.c
-+++ b/net/ieee802154/reassembly.c
-@@ -89,6 +89,9 @@ static void lowpan_frag_init(struct inet
- fq->d_size = arg->d_size;
- fq->saddr = *arg->src;
- fq->daddr = *arg->dst;
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-+ spin_lock_init(&fq->lru_lock);
-+#endif
- }
-
- static void lowpan_frag_expire(unsigned long data)
---- a/net/ieee802154/reassembly.h
-+++ b/net/ieee802154/reassembly.h
-@@ -2,6 +2,7 @@
- #define __IEEE802154_6LOWPAN_REASSEMBLY_H__
-
- #include <net/inet_frag.h>
-+#include <linux/spinlock.h>
-
- struct lowpan_create_arg {
- u16 tag;
-@@ -19,8 +20,32 @@ struct lowpan_frag_queue {
- u16 d_size;
- struct ieee802154_addr saddr;
- struct ieee802154_addr daddr;
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-+ spinlock_t lru_lock;
-+#endif
- };
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-+/*
-+ * XXX: this is a *domain* specific inet_frag_lru_move backport,
-+ * note the added lowpan_ prefix, this requires a respective patch
-+ * which extends struct lowpan_frag_queue with an lru_lock and
-+ * initializes it. We add this helper here to reduce the backport.
-+ * There is no way to generalize the other changes in the patch.
-+ */
-+#define inet_frag_lru_move LINUX_BACKPORT(lowpan_inet_frag_lru_move)
-+static inline void inet_frag_lru_move(struct inet_frag_queue *q)
-+{
-+ struct lowpan_frag_queue *fq;
-+
-+ fq = container_of(q, struct lowpan_frag_queue, q);
-+
-+ spin_lock(&fq->lru_lock);
-+ list_move_tail(&q->lru_list, &q->net->lru_list);
-+ spin_unlock(&fq->lru_lock);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) */
-+
- static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
- {
- switch (a->mode) {
+++ /dev/null
-network namespaces didn't get usernamespaces pegged until 3.8
-via commit 038e7332b8.
-
---- a/net/ieee802154/reassembly.c
-+++ b/net/ieee802154/reassembly.c
-@@ -481,9 +481,11 @@ static int __net_init lowpan_frags_ns_sy
- table[1].extra2 = &ieee802154_lowpan->frags.high_thresh;
- table[2].data = &ieee802154_lowpan->frags.timeout;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
- /* Don't export sysctls to unprivileged users */
- if (net->user_ns != &init_user_ns)
- table[0].procname = NULL;
-+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,8,0) */
- }
-
- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
+++ /dev/null
-The patch "wext: refactor" by Johannes Berg refactored
-wext code so that new kernels no longer get the wext
-handlers through struct netdevice, instead they get
-it through the struct wiphy which is cfg80211 specific.
-
-For old kernels this means you get not wext handlers
-anymore when backporting code, this adds the wext handler
-back to the netdevice wireless_handlers to let compat
-users use wext again.
-
-We do this for every kernel version because the struct wiphy
-is changing from kernel version to version. At least the
-struct from kernel 2.6.33 and 2.6.34 are incompatible and
-the kernel would dereference some wrong type in the struct
-and oops. The old interface is not affected by this. This
-will cause that CONFIG_CFG80211_WEXT still depends on
-CONFIG_WIRELESS_EXT in compat-drivers.
-
+++ /dev/null
---- a/net/wireless/core.c
-+++ b/net/wireless/core.c
-@@ -433,10 +433,6 @@ use_default_name:
- INIT_WORK(&rdev->mlme_unreg_wk, cfg80211_mlme_unreg_wk);
- INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
- cfg80211_dfs_channels_update_work);
--#ifdef CONFIG_CFG80211_WEXT
-- rdev->wiphy.wext = &cfg80211_wext_handler;
--#endif
--
- device_initialize(&rdev->wiphy.dev);
- rdev->wiphy.dev.class = &ieee80211_class;
- rdev->wiphy.dev.platform_data = rdev;
-@@ -1043,6 +1039,15 @@ static int cfg80211_netdev_notifier_call
- }
- wdev->netdev = dev;
- #ifdef CONFIG_CFG80211_WEXT
-+#ifdef CONFIG_WIRELESS_EXT
-+ if (!dev->wireless_handlers)
-+ dev->wireless_handlers = &cfg80211_wext_handler;
-+#else
-+ printk_once(KERN_WARNING "cfg80211: wext will not work because "
-+ "kernel was compiled with CONFIG_WIRELESS_EXT=n. "
-+ "Tools using wext interface, like iwconfig will "
-+ "not work.\n");
-+#endif
- wdev->wext.default_key = -1;
- wdev->wext.default_mgmt_key = -1;
- wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+++ /dev/null
-Some quirks require base kernel updates, these are work
-around for kernels that would not have these quirks.
+++ /dev/null
---- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
-+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
-@@ -253,6 +253,12 @@ static size_t cw1200_sdio_align_size(str
- else
- size = sdio_align_size(self->func, size);
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
-+ /* A quirk to handle this was committed in 3.2-rc */
-+ if (size == SDIO_BLOCK_SIZE)
-+ size += SDIO_BLOCK_SIZE; /* HW bug; force use of block mode */
-+#endif
-+
- return size;
- }
-
+++ /dev/null
---- a/net/6lowpan/core.c
-+++ b/net/6lowpan/core.c
-@@ -14,6 +14,7 @@
- #include <linux/module.h>
-
- #include <net/6lowpan.h>
-+#include <linux/if_arp.h>
-
- #include "6lowpan_i.h"
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath10k/htt.h
-+++ b/drivers/net/wireless/ath/ath10k/htt.h
-@@ -19,6 +19,7 @@
- #define _HTT_H_
-
- #include <linux/bug.h>
-+#include <linux/idr.h>
- #include <linux/interrupt.h>
- #include <linux/dmapool.h>
- #include <linux/hashtable.h>
+++ /dev/null
---- a/net/bluetooth/6lowpan.c
-+++ b/net/bluetooth/6lowpan.c
-@@ -18,6 +18,7 @@
- #include <linux/debugfs.h>
-
- #include <net/ipv6.h>
-+#include <net/ip6_fib.h>
- #include <net/ip6_route.h>
- #include <net/addrconf.h>
-
+++ /dev/null
---- a/include/net/cfg802154.h
-+++ b/include/net/cfg802154.h
-@@ -26,6 +26,7 @@
-
- struct wpan_phy;
- struct wpan_phy_cca;
-+struct wpan_dev;
-
- #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
- struct ieee802154_llsec_device_key;
+++ /dev/null
---- a/compat/mm-frame_vector.c
-+++ b/compat/mm-frame_vector.c
-@@ -6,6 +6,7 @@
- #include <linux/vmalloc.h>
- #include <linux/pagemap.h>
- #include <linux/sched.h>
-+#include <linux/export.h>
-
- /**
- * get_vaddr_frames() - map virtual addresses to pfns
+++ /dev/null
-diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
-index 55a1405c..1409e20 100644
---- a/drivers/net/ethernet/intel/igb/igb_main.c
-+++ b/drivers/net/ethernet/intel/igb/igb_main.c
-@@ -34,6 +34,7 @@
- #include <linux/slab.h>
- #include <net/checksum.h>
- #include <net/ip6_checksum.h>
-+#include <net/ipv6.h>
- #include <linux/net_tstamp.h>
- #include <linux/mii.h>
- #include <linux/ethtool.h>
+++ /dev/null
---- a/drivers/nfc/mei_phy.c
-+++ b/drivers/nfc/mei_phy.c
-@@ -19,6 +19,7 @@
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
- #include <linux/module.h>
-+#include <linux/sched.h>
- #include <linux/slab.h>
- #include <linux/nfc.h>
-
+++ /dev/null
---- a/net/wireless/Makefile
-+++ b/net/wireless/Makefile
-@@ -20,6 +20,6 @@ CFLAGS_trace.o := -I$(src)
- ccflags-y += -D__CHECK_ENDIAN__
-
- $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk
-- @$(AWK) -f $(srctree)/$(src)/genregdb.awk < $< > $@
-+ @$(AWK) -f $(src)/genregdb.awk < $< > $@
-
- clean-files := regdb.c
+++ /dev/null
---- a/drivers/nfc/st-nci/spi.c
-+++ b/drivers/nfc/st-nci/spi.c
-@@ -21,6 +21,7 @@
- #include <linux/spi/spi.h>
- #include <linux/gpio.h>
- #include <linux/gpio/consumer.h>
-+#include <linux/of.h>
- #include <linux/of_irq.h>
- #include <linux/of_gpio.h>
- #include <linux/acpi.h>
+++ /dev/null
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -6955,7 +6955,9 @@ static int nl80211_dump_scan(struct sk_b
- spin_lock_bh(&rdev->bss_lock);
- cfg80211_bss_expire(rdev);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
- cb->seq = rdev->bss_generation;
-+#endif
-
- list_for_each_entry(scan, &rdev->bss_list, list) {
- if (++idx <= start)
+++ /dev/null
---- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
-+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
-@@ -175,7 +175,11 @@ that only one external action is invoked
- #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"
- #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
-+static struct pm_qos_request_list ipw2100_pm_qos_req;
-+#else
- static struct pm_qos_request ipw2100_pm_qos_req;
-+#endif
-
- /* Debugging stuff */
- #ifdef CONFIG_IPW2100_DEBUG
+++ /dev/null
-This section of the libertas driver calls functions that simply don't
-exist before the release of 3.1. This code in question was an addition,
-not a change from any existing code. It is safe to simply remove it for
-older kernels.
-
+++ /dev/null
---- a/drivers/net/wireless/marvell/libertas/if_usb.c
-+++ b/drivers/net/wireless/marvell/libertas/if_usb.c
-@@ -960,6 +960,7 @@ static int if_usb_suspend(struct usb_int
- goto out;
- }
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
- #ifdef CONFIG_OLPC
- if (machine_is_olpc()) {
- if (priv->wol_criteria == EHS_REMOVE_WAKEUP)
-@@ -968,6 +969,7 @@ static int if_usb_suspend(struct usb_int
- olpc_ec_wakeup_set(EC_SCI_SRC_WLAN);
- }
- #endif
-+#endif
-
- ret = lbs_suspend(priv);
- if (ret)
+++ /dev/null
-Linux 3.5 will have get_ts_info to support the Precision Time Protocol.
-
-http://linuxptp.sourceforge.net/
-http://en.wikipedia.org/wiki/Precision_Time_Protocol
-
-We cannot backport this support given that this introduces
-a data structure change on the ethtool_ops.
-
-commit c8f3a8c31069137fe0100e6920558f1a7487ef3c
-Author: Richard Cochran <richardcochran@gmail.com>
-Date: Tue Apr 3 22:59:17 2012 +0000
-
- ethtool: Introduce a method for getting time stamping capabilities.
-
- This commit adds a new ethtool ioctl that exposes the SO_TIMESTAMPING
- capabilities of a network interface. In addition, user space programs
- can use this ioctl to discover the PTP Hardware Clock (PHC) device
- associated with the interface.
-
- Since software receive time stamps are handled by the stack, the generic
- ethtool code can answer the query correctly in case the MAC or PHY
- drivers lack special time stamping features.
-
- Signed-off-by: Richard Cochran <richardcochran@gmail.com>
- Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
- Signed-off-by: David S. Miller <davem@davemloft.net>
-
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct ethtool_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-.get_ts_info = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+++ /dev/null
-In recent kernels, %pV will copy the va_list before using it.
-This isn't true for all kernels, so copy the va_list for use
-by the dev_*() functions, otherwise the kernel will crash if
-the message is printed and traced.
-
-This is required for kernels <= 3.1, as otherwise it would
-those kernels would crash.
+++ /dev/null
---- a/drivers/net/wireless/intel/iwlwifi/iwl-debug.c
-+++ b/drivers/net/wireless/intel/iwlwifi/iwl-debug.c
-@@ -74,13 +74,16 @@ void __iwl_ ##fn(struct device *dev, con
- struct va_format vaf = { \
- .fmt = fmt, \
- }; \
-- va_list args; \
-+ va_list args1, args2; \
- \
-- va_start(args, fmt); \
-- vaf.va = &args; \
-+ va_start(args1, fmt); \
-+ va_copy(args2, args1); \
-+ vaf.va = &args2; \
- dev_ ##fn(dev, "%pV", &vaf); \
-+ va_end(args2); \
-+ vaf.va = &args1; \
- trace_iwlwifi_ ##fn(&vaf); \
-- va_end(args); \
-+ va_end(args1); \
- }
-
- __iwl_fn(warn)
-@@ -99,13 +102,18 @@ void __iwl_err(struct device *dev, bool
- va_list args;
-
- va_start(args, fmt);
-- vaf.va = &args;
- if (!trace_only) {
-+ va_list args2;
-+
-+ va_copy(args2, args);
-+ vaf.va = &args2;
- if (rfkill_prefix)
- dev_err(dev, "(RFKILL) %pV", &vaf);
- else
- dev_err(dev, "%pV", &vaf);
-+ va_end(args2);
- }
-+ vaf.va = &args;
- trace_iwlwifi_err(&vaf);
- va_end(args);
- }
-@@ -122,13 +130,19 @@ void __iwl_dbg(struct device *dev,
- va_list args;
-
- va_start(args, fmt);
-- vaf.va = &args;
- #ifdef CONFIG_IWLWIFI_DEBUG
- if (iwl_have_debug_level(level) &&
-- (!limit || net_ratelimit()))
-+ (!limit || net_ratelimit())) {
-+ va_list args2;
-+
-+ va_copy(args2, args);
-+ vaf.va = &args2;
- dev_printk(KERN_DEBUG, dev, "%c %s %pV",
- in_interrupt() ? 'I' : 'U', function, &vaf);
-+ va_end(args2);
-+ }
- #endif
-+ vaf.va = &args;
- trace_iwlwifi_dbg(level, in_interrupt(), function, &vaf);
- va_end(args);
- }
+++ /dev/null
---- a/net/mac80211/trace.c
-+++ b/net/mac80211/trace.c
-@@ -16,12 +16,16 @@ void __sdata_info(const char *fmt, ...)
- struct va_format vaf = {
- .fmt = fmt,
- };
-- va_list args;
-+ va_list args, args2;
-
- va_start(args, fmt);
-- vaf.va = &args;
-
-+ va_copy(args2, args);
-+ vaf.va = &args2;
- pr_info("%pV", &vaf);
-+ va_end(args2);
-+
-+ vaf.va = &args;
- trace_mac80211_info(&vaf);
- va_end(args);
- }
-@@ -34,10 +38,16 @@ void __sdata_dbg(bool print, const char
- va_list args;
-
- va_start(args, fmt);
-- vaf.va = &args;
-
-- if (print)
-+ if (print) {
-+ va_list args2;
-+
-+ va_copy(args2, args);
-+ vaf.va = &args2;
- pr_debug("%pV", &vaf);
-+ va_end(args2);
-+ }
-+ vaf.va = &args;
- trace_mac80211_dbg(&vaf);
- va_end(args);
- }
-@@ -47,12 +57,16 @@ void __sdata_err(const char *fmt, ...)
- struct va_format vaf = {
- .fmt = fmt,
- };
-- va_list args;
-+ va_list args, args2;
-
- va_start(args, fmt);
-- vaf.va = &args;
-
-+ va_copy(args2, args);
-+ vaf.va = &args2;
- pr_err("%pV", &vaf);
-+ va_end(args2);
-+
-+ vaf.va = &args;
- trace_mac80211_err(&vaf);
- va_end(args);
- }
-@@ -65,10 +79,16 @@ void __wiphy_dbg(struct wiphy *wiphy, bo
- va_list args;
-
- va_start(args, fmt);
-- vaf.va = &args;
-
-- if (print)
-- wiphy_dbg(wiphy, "%pV", &vaf);
-+ if (print) {
-+ va_list args2;
-+
-+ va_copy(args2, args);
-+ vaf.va = &args2;
-+ pr_debug("%pV", &vaf);
-+ va_end(args2);
-+ }
-+ vaf.va = &args;
- trace_mac80211_dbg(&vaf);
- va_end(args);
- }
+++ /dev/null
-@@
-identifier backport_driver;
-@@
-struct usb_driver backport_driver = {
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
- .disable_hub_initiated_lpm = 1,
-+#endif
-...
-};
+++ /dev/null
-This patch requires a manual backport:
-
-commit adc8d746caa67fff4b53ba3e5163a6cbacc3b523
-Author: Alan Cox <alan@linux.intel.com>
-Date: Sat Jul 14 15:31:47 2012 +0100
-
- tty: move the termios object into the tty
-
- This will let us sort out a whole pile of tty related races. The
- alternative would be to keep points and refcount the termios objects.
- However
- 1. They are tiny anyway
- 2. Many devices don't use the stored copies
- 3. We can remove a pty special case
-
- Signed-off-by: Alan Cox <alan@linux.intel.com>
- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
-We cannot use compat.git for this given that the assignment
-was not done through a static inline helper.
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains adc8d746caa67fff4b53ba3e5163a6cbacc3b523
-v3.7-rc1~172^2~187
+++ /dev/null
---- a/drivers/bluetooth/hci_ldisc.c
-+++ b/drivers/bluetooth/hci_ldisc.c
-@@ -24,6 +24,7 @@
- */
-
- #include <linux/module.h>
-+#include <linux/version.h>
-
- #include <linux/kernel.h>
- #include <linux/init.h>
-@@ -269,7 +270,11 @@ void hci_uart_set_flow_control(struct hc
-
- if (enable) {
- /* Disable hardware flow control */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
- ktermios = tty->termios;
-+#else
-+ ktermios = *tty->termios;
-+#endif
- ktermios.c_cflag &= ~CRTSCTS;
- status = tty_set_termios(tty, &ktermios);
- BT_DBG("Disabling hardware flow control: %s",
-@@ -303,7 +308,11 @@ void hci_uart_set_flow_control(struct hc
- BT_DBG("Setting RTS: %s", status ? "failed" : "success");
-
- /* Re-enable hardware flow control */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
- ktermios = tty->termios;
-+#else
-+ ktermios = *tty->termios;
-+#endif
- ktermios.c_cflag |= CRTSCTS;
- status = tty_set_termios(tty, &ktermios);
- BT_DBG("Enabling hardware flow control: %s",
-@@ -324,7 +333,11 @@ void hci_uart_init_tty(struct hci_uart *
- struct ktermios ktermios;
-
- /* Bring the UART into a known 8 bits no parity hw fc state */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
- ktermios = tty->termios;
-+#else
-+ ktermios = *tty->termios;
-+#endif
- ktermios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
- INLCR | IGNCR | ICRNL | IXON);
- ktermios.c_oflag &= ~OPOST;
-@@ -342,7 +355,11 @@ void hci_uart_set_baudrate(struct hci_ua
- struct tty_struct *tty = hu->tty;
- struct ktermios ktermios;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
- ktermios = tty->termios;
-+#else
-+ ktermios = *tty->termios;
-+#endif
- ktermios.c_cflag &= ~CBAUD;
- tty_termios_encode_baud_rate(&ktermios, speed, speed);
-
-@@ -350,7 +367,7 @@ void hci_uart_set_baudrate(struct hci_ua
- tty_set_termios(tty, &ktermios);
-
- BT_DBG("%s: New tty speeds: %d/%d", hu->hdev->name,
-- tty->termios.c_ispeed, tty->termios.c_ospeed);
-+ ktermios.c_ispeed, ktermios.c_ospeed);
- }
-
- static int hci_uart_setup(struct hci_dev *hdev)
+++ /dev/null
---- a/net/bluetooth/rfcomm/tty.c
-+++ b/net/bluetooth/rfcomm/tty.c
-@@ -869,7 +869,11 @@ static int rfcomm_tty_ioctl(struct tty_s
-
- static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
- {
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
- struct ktermios *new = &tty->termios;
-+#else
-+ struct ktermios *new = tty->termios;
-+#endif
- int old_baud_rate = tty_termios_baud_rate(old);
- int new_baud_rate = tty_termios_baud_rate(new);
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath10k/spectral.c
-+++ b/drivers/net/wireless/ath/ath10k/spectral.c
-@@ -477,7 +477,11 @@ static const struct file_operations fops
-
- static struct dentry *create_buf_file_handler(const char *filename,
- struct dentry *parent,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
- umode_t mode,
-+#else
-+ int mode,
-+#endif
- struct rchan_buf *buf,
- int *is_global)
- {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/common-spectral.c
-+++ b/drivers/net/wireless/ath/ath9k/common-spectral.c
-@@ -1042,7 +1042,11 @@ static const struct file_operations fops
-
- static struct dentry *create_buf_file_handler(const char *filename,
- struct dentry *parent,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
- umode_t mode,
-+#else
-+ int mode,
-+#endif
- struct rchan_buf *buf,
- int *is_global)
- {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/spectral.c
-+++ b/drivers/net/wireless/ath/ath9k/spectral.c
-@@ -478,7 +478,11 @@ static const struct file_operations fops
-
- static struct dentry *create_buf_file_handler(const char *filename,
- struct dentry *parent,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
- umode_t mode,
-+#else
-+ int mode,
-+#endif
- struct rchan_buf *buf,
- int *is_global)
- {
+++ /dev/null
-For some reason the tracing on older kernels requires
-the tracing to be declared before it's defined; it's
-broken when the trace header is only included to create
-the tracepoints.
-
-Since new kernels don't, add patches for the two places
-that rely on the new behaviour.
-
-The kernel that requires this has not been identified...
+++ /dev/null
---- a/drivers/net/wireless/ath/ath6kl/trace.c
-+++ b/drivers/net/wireless/ath/ath6kl/trace.c
-@@ -15,6 +15,9 @@
- */
-
- #include <linux/module.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+#include <linux/interrupt.h>
-+#endif
-
- #define CREATE_TRACE_POINTS
- #include "trace.h"
+++ /dev/null
---- a/net/wireless/trace.c
-+++ b/net/wireless/trace.c
-@@ -1,4 +1,7 @@
- #include <linux/module.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+#include <linux/interrupt.h>
-+#endif
-
- #ifndef __CHECKER__
- #define CREATE_TRACE_POINTS
+++ /dev/null
---- a/drivers/net/wireless/mediatek/mt7601u/trace.c
-+++ b/drivers/net/wireless/mediatek/mt7601u/trace.c
-@@ -13,6 +13,9 @@
- */
-
- #include <linux/module.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
-+#include <linux/interrupt.h>
-+#endif
-
- #ifndef __CHECKER__
- #define CREATE_TRACE_POINTS
+++ /dev/null
---- a/drivers/net/wireless/ath/wil6210/trace.c
-+++ b/drivers/net/wireless/ath/wil6210/trace.c
-@@ -15,6 +15,9 @@
- */
-
- #include <linux/module.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+#include <linux/interrupt.h>
-+#endif
-
- #define CREATE_TRACE_POINTS
- #include "trace.h"
+++ /dev/null
-backports: use old led api on old kernel versions.
-
-Usage of a new led api was introduced in mac80211, this patch make
-backports use the old api on older kernel versions. This could cause a
-problem with the led, the transmit led could stay on if nothing is
-transfered.
-
-This backports the following upstream commit:
-commit e47f2509e5f182f4df144406de6f2bc78179d57e
-Author: Fabio Baltieri <fabio.baltieri@gmail.com>
-Date: Thu Jul 25 12:00:26 2013 +0200
-
- mac80211: use oneshot blink API for LED triggers
+++ /dev/null
---- a/net/mac80211/ieee80211_i.h
-+++ b/net/mac80211/ieee80211_i.h
-@@ -1255,6 +1255,7 @@ struct ieee80211_local {
- struct mutex chanctx_mtx;
-
- #ifdef CONFIG_MAC80211_LEDS
-+ int tx_led_counter, rx_led_counter;
- struct led_trigger tx_led, rx_led, assoc_led, radio_led;
- struct led_trigger tpt_led;
- atomic_t tx_led_active, rx_led_active, assoc_led_active;
---- a/net/mac80211/led.h
-+++ b/net/mac80211/led.h
-@@ -16,22 +16,36 @@
- static inline void ieee80211_led_rx(struct ieee80211_local *local)
- {
- #ifdef CONFIG_MAC80211_LEDS
-- unsigned long led_delay = MAC80211_BLINK_DELAY;
-+ unsigned long led_delay __maybe_unused = MAC80211_BLINK_DELAY;
-
- if (!atomic_read(&local->rx_led_active))
- return;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- led_trigger_blink_oneshot(&local->rx_led, &led_delay, &led_delay, 0);
-+#else
-+ if (local->rx_led_counter++ % 2 == 0)
-+ led_trigger_event(&local->rx_led, LED_OFF);
-+ else
-+ led_trigger_event(&local->rx_led, LED_FULL);
-+#endif
- #endif
- }
-
- static inline void ieee80211_led_tx(struct ieee80211_local *local)
- {
- #ifdef CONFIG_MAC80211_LEDS
-- unsigned long led_delay = MAC80211_BLINK_DELAY;
-+ unsigned long led_delay __maybe_unused = MAC80211_BLINK_DELAY;
-
- if (!atomic_read(&local->tx_led_active))
- return;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- led_trigger_blink_oneshot(&local->tx_led, &led_delay, &led_delay, 0);
-+#else
-+ if (local->tx_led_counter++ % 2 == 0)
-+ led_trigger_event(&local->tx_led, LED_OFF);
-+ else
-+ led_trigger_event(&local->tx_led, LED_FULL);
-+#endif
- #endif
- }
-
+++ /dev/null
-backports: do not use DMA SG on old kernel versions
-
-the usb net driver now uses the dma sg api which is not available on
-old kernels, this patch removed the usage of the dma sg api for old
-kernel versions.
-
-This backports the following upstream commit:
-commit 638c5115a794981441246fa8fa5d95c1875af5ba
-Author: Ming Lei <ming.lei@canonical.com>
-Date: Thu Aug 8 21:48:24 2013 +0800
-
- USBNET: support DMA SG
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains 638c5115a794981441246fa8fa5d95c1875af5ba
-v3.12-rc1~186^2~110
-
-XXX: this patch seems odd, the kernel versoin used seems off.
+++ /dev/null
---- a/drivers/net/usb/usbnet.c
-+++ b/drivers/net/usb/usbnet.c
-@@ -1270,6 +1270,7 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
-
- /*-------------------------------------------------------------------------*/
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
- static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
- {
- unsigned num_sgs, total_len = 0;
-@@ -1302,6 +1303,12 @@ static int build_dma_sg(const struct sk_
-
- return 1;
- }
-+#else
-+static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
-+{
-+ return -ENXIO;
-+}
-+#endif
-
- netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
- struct net_device *net)
-@@ -1358,12 +1365,19 @@ netdev_tx_t usbnet_start_xmit (struct sk
- if (!(info->flags & FLAG_SEND_ZLP)) {
- if (!(info->flags & FLAG_MULTI_PACKET)) {
- length++;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
- if (skb_tailroom(skb) && !urb->num_sgs) {
- skb->data[skb->len] = 0;
- __skb_put(skb, 1);
- } else if (urb->num_sgs)
- sg_set_buf(&urb->sg[urb->num_sgs++],
- dev->padding_pkt, 1);
-+#else
-+ if (skb_tailroom(skb)) {
-+ skb->data[skb->len] = 0;
-+ __skb_put(skb, 1);
-+ }
-+#endif
- }
- } else
- urb->transfer_flags |= URB_ZERO_PACKET;
-@@ -1430,7 +1444,9 @@ not_drop:
- if (skb)
- dev_kfree_skb_any (skb);
- if (urb) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
- kfree(urb->sg);
-+#endif
- usb_free_urb(urb);
- }
- } else
-@@ -1483,7 +1499,9 @@ static void usbnet_bh (unsigned long par
- rx_process (dev, skb);
- continue;
- case tx_done:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
- kfree(entry->urb->sg);
-+#endif
- case rx_cleanup:
- usb_free_urb (entry->urb);
- dev_kfree_skb (skb);
-@@ -1840,7 +1858,9 @@ int usbnet_resume (struct usb_interface
- retval = usb_submit_urb(res, GFP_ATOMIC);
- if (retval < 0) {
- dev_kfree_skb_any(skb);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,35,0)
- kfree(res->sg);
-+#endif
- usb_free_urb(res);
- usb_autopm_put_interface_async(dev->intf);
- } else {
+++ /dev/null
-We can not easily backport ipv6_stub which provides some IPv6 function
-callbacks.
-These patches are removing usage of ipv6_stub which was introduces in
-this commit:
-commit 5f81bd2e5d804ca93f3ec8873451b22d2f454721
-Author: Cong Wang <amwang@redhat.com>
-Date: Sat Aug 31 13:44:30 2013 +0800
-
- ipv6: export a stub for IPv6 symbols used by vxlan
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains 5f81bd2e5d804ca93f3ec8873451b22d2f454721
-v3.12-rc1~132^2~101
+++ /dev/null
---- a/drivers/net/usb/cdc_mbim.c
-+++ b/drivers/net/usb/cdc_mbim.c
-@@ -301,6 +301,7 @@ error:
- return NULL;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- /* Some devices are known to send Neigbor Solicitation messages and
- * require Neigbor Advertisement replies. The IPv6 core will not
- * respond since IFF_NOARP is set, so we must handle them ourselves.
-@@ -361,6 +362,7 @@ static bool is_neigh_solicit(u8 *buf, si
- msg->icmph.icmp6_code == 0 &&
- msg->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION);
- }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
-
-
- static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_t len, u16 tci)
-@@ -377,8 +379,10 @@ static struct sk_buff *cdc_mbim_process_
- proto = htons(ETH_P_IP);
- break;
- case 0x60:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- if (is_neigh_solicit(buf, len))
- do_neigh_solicit(dev, buf, tci);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
- proto = htons(ETH_P_IPV6);
- break;
- default:
+++ /dev/null
-Newer kernels make generic netlink ops and multicast groups
-const, but older can't have that. We therefore introduce
-__genl_const, which can be defined depending on the kernel.
-
-What kernel versions require this?
-
-XXX: try to SmPLify
-
-The struct genl_ops gave the *option* to make it const via:
-mcgrof@ergon ~/linux (git::master)$ git describe --contains f84f771d9
-v3.13-rc1~33^2~32^2~2
-
-The struct genl_multicast_group was *forced* to be const via:
-mcgrof@ergon ~/linux (git::master)$ git describe --contains 2a94fe48f
-v3.13-rc1~33^2^2
+++ /dev/null
-@@
-attribute __genl_const;
-@@
-(
--const struct genl_multicast_group
-+__genl_const struct genl_multicast_group
-|
--const struct genl_ops
-+__genl_const struct genl_ops
-)
+++ /dev/null
-backports: adapt to changes in netdev select_queue call
-
-This patch reverts the changes done in the following commit for older
-kernel versions:
-commit f663dd9aaf9ed124f25f0f8452edf238f087ad50
-Author: Jason Wang <jasowang@redhat.com>
-Date: Fri Jan 10 16:18:26 2014 +0800
-
- net: core: explicitly select a txq before doing l2 forwarding
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains f663dd9aaf9ed124f25f0f8452edf238f087ad50
-v3.13-rc8~4^2~2
+++ /dev/null
---- a/net/mac80211/iface.c
-+++ b/net/mac80211/iface.c
-@@ -1101,10 +1101,20 @@ static void ieee80211_uninit(struct net_
- ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
-+ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
- static u16 ieee80211_netdev_select_queue(struct net_device *dev,
- struct sk_buff *skb,
- void *accel_priv,
- select_queue_fallback_t fallback)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
-+static u16 ieee80211_netdev_select_queue(struct net_device *dev,
-+ struct sk_buff *skb,
-+ void *accel_priv)
-+#else
-+static u16 ieee80211_netdev_select_queue(struct net_device *dev,
-+ struct sk_buff *skb)
-+#endif
- {
- return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
- }
-@@ -1150,10 +1160,20 @@ static const struct net_device_ops ieee8
- .ndo_get_stats64 = ieee80211_get_stats64,
- };
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
-+ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
- static u16 ieee80211_monitor_select_queue(struct net_device *dev,
- struct sk_buff *skb,
- void *accel_priv,
- select_queue_fallback_t fallback)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
-+static u16 ieee80211_monitor_select_queue(struct net_device *dev,
-+ struct sk_buff *skb,
-+ void *accel_priv)
-+#else
-+static u16 ieee80211_monitor_select_queue(struct net_device *dev,
-+ struct sk_buff *skb)
-+#endif
- {
- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- struct ieee80211_local *local = sdata->local;
+++ /dev/null
---- a/drivers/net/wireless/marvell/mwifiex/main.c
-+++ b/drivers/net/wireless/marvell/mwifiex/main.c
-@@ -1199,9 +1199,19 @@ static struct net_device_stats *mwifiex_
- return &priv->stats;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0) || \
-+ (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
- static u16
- mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
- void *accel_priv, select_queue_fallback_t fallback)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
-+static u16
-+mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
-+ void *accel_priv)
-+#else
-+static u16
-+mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb)
-+#endif
- {
- skb->priority = cfg80211_classify8021d(skb, NULL);
- return mwifiex_1d_to_wmm_queue[skb->priority];
+++ /dev/null
-This is backported because of:
-
-commit cd4dc0821bc97947f25c8483a4aa0711bff8619a
-Author: Frank Praznik <frank.praznik@oh.rr.com>
-Date: Wed Jan 22 13:49:41 2014 -0500
-
- HID: Add transport-driver callbacks to the hid_ll_driver struct
-
- Add raw_request and output_report callbacks to the hid_ll_driver struct.
-
- Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
- Acked-by: David Herrmann <dh.herrmann@gmail.com>
- Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-
-This did not make it to v3.14, so its only present on linux-next, its
-available for example on next-20140409
+++ /dev/null
---- a/net/bluetooth/hidp/core.c
-+++ b/net/bluetooth/hidp/core.c
-@@ -224,6 +224,7 @@ static void hidp_input_report(struct hid
- input_sync(dev);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- static int hidp_get_raw_report(struct hid_device *hid,
- unsigned char report_number,
- unsigned char *data, size_t count,
-@@ -396,6 +397,7 @@ static int hidp_raw_request(struct hid_d
- return -EIO;
- }
- }
-+#endif
-
- static void hidp_idle_timeout(unsigned long arg)
- {
-@@ -739,8 +741,10 @@ static struct hid_ll_driver hidp_hid_dri
- .stop = hidp_stop,
- .open = hidp_open,
- .close = hidp_close,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- .raw_request = hidp_raw_request,
- .output_report = hidp_output_report,
-+#endif
- };
-
- /* This function sets up the hid device. It does not add it
+++ /dev/null
-struct net_device got an extension with the member qdisc_tx_busylock
-as of commit 23d3b8bfb. For older kernels we need to ifdef around that
-as its now available.
-
-mcgrof@ergon ~/linux (git::master)$ git describe --contains 23d3b8bfb
-v3.7-rc1~145^2~208
-
-commit 23d3b8bfb8eb20e7d96afa09991e6a5ed1c83164
-Author: Eric Dumazet <edumazet@google.com>
-Date: Wed Sep 5 01:02:56 2012 +0000
-
- net: qdisc busylock needs lockdep annotations
-
- It seems we need to provide ability for stacked devices
- to use specific lock_class_key for sch->busylock
-
- We could instead default l2tpeth tx_queue_len to 0 (no qdisc), but
- a user might use a qdisc anyway.
-
- (So same fixes are probably needed on non LLTX stacked drivers)
-
-[ the commit log goes we only include up to here to help with context ]
+++ /dev/null
---- a/net/bluetooth/6lowpan.c
-+++ b/net/bluetooth/6lowpan.c
-@@ -628,7 +628,9 @@ static netdev_tx_t bt_xmit(struct sk_buf
- return err < 0 ? NET_XMIT_DROP : err;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- static struct lock_class_key bt_tx_busylock;
-+#endif
- static struct lock_class_key bt_netdev_xmit_lock_key;
-
- static void bt_set_lockdep_class_one(struct net_device *dev,
-@@ -641,7 +643,9 @@ static void bt_set_lockdep_class_one(str
- static int bt_dev_init(struct net_device *dev)
- {
- netdev_for_each_tx_queue(dev, bt_set_lockdep_class_one, NULL);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- dev->qdisc_tx_busylock = &bt_tx_busylock;
-+#endif
-
- return 0;
- }
+++ /dev/null
---- a/net/ieee802154/6lowpan_rtnl.c
-+++ b/net/ieee802154/6lowpan_rtnl.c
-@@ -428,7 +428,9 @@ static struct header_ops lowpan_header_o
- .create = lowpan_header_create,
- };
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- static struct lock_class_key lowpan_tx_busylock;
-+#endif
- static struct lock_class_key lowpan_netdev_xmit_lock_key;
-
- static void lowpan_set_lockdep_class_one(struct net_device *dev,
-@@ -442,7 +444,9 @@ static void lowpan_set_lockdep_class_one
- static int lowpan_dev_init(struct net_device *dev)
- {
- netdev_for_each_tx_queue(dev, lowpan_set_lockdep_class_one, NULL);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- dev->qdisc_tx_busylock = &lowpan_tx_busylock;
-+#endif
- return 0;
- }
-
+++ /dev/null
-/*
-Commit 676d2369 by David removed the skb->len arguments passed onto
-the struct sock sk_data_ready() callback. This was done as its racy,
-a few drivers were passing 0 to it, and it was not really used.
-By removing it the raciness is addresed but to backport this we are
-going to have to deal with the races as-is on older kernels. This was
-merged as of v3.15:
-
-mcgrof@ergon ~/linux-next (git::master)$ git describe --contains 676d2369
-v3.15-rc1~8^2~10
-
-Since this is not a define or static inline we can't easily replace this with
-the backports module or header files, instead we use SmPL grammar to generalize
-the backport for all use cases. Note that in order to backport this we won't
-know what older kernel drivers were using before this change, it could have
-been 0 or skb->len for the length parameter, since we have to infer something
-we choose skb->len *iff* skb_queue_tail() was used right before it, otherwise
-we infer to throw 0.
-
-commit 676d23690fb62b5d51ba5d659935e9f7d9da9f8e
-Author: David S. Miller <davem@davemloft.net>
-Date: Fri Apr 11 16:15:36 2014 -0400
-
- net: Fix use after free by removing length arg from sk_data_ready callbacks.
-
- Several spots in the kernel perform a sequence like:
-
- skb_queue_tail(&sk->s_receive_queue, skb);
- sk->sk_data_ready(sk, skb->len);
-
- But at the moment we place the SKB onto the socket receive queue it
- can be consumed and freed up. So this skb->len access is potentially
- to freed up memory.
-
- Furthermore, the skb->len can be modified by the consumer so it is
- possible that the value isn't accurate.
-
- And finally, no actual implementation of this callback actually uses
- the length argument. And since nobody actually cared about it's
- value, lots of call sites pass arbitrary values in such as '0' and
- even '1'.
-
- So just remove the length argument from the callback, that way there
- is no confusion whatsoever and all of these use-after-free cases get
- fixed as a side effect.
-
- Based upon a patch by Eric Dumazet and his suggestion to audit this
- issue tree-wide.
-
- Signed-off-by: David S. Miller <davem@davemloft.net>
-*/
-
-@ sk_data_ready_assigned @
-expression E;
-identifier drv_data_ready;
-@@
-
- E->sk_data_ready = drv_data_ready;
-
-@ sk_data_ready_declared depends on sk_data_ready_assigned @
-identifier sk;
-identifier sk_data_ready_assigned.drv_data_ready;
-fresh identifier backport_drv_data_ready = "backport_" ## drv_data_ready;
-@@
-
-drv_data_ready(struct sock *sk)
-{
- ...
-}
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
-+static void backport_drv_data_ready(struct sock *sk, int unused)
-+{
-+ drv_data_ready(sk);
-+}
-+#endif
-
-@ sk_data_ready_assigned_mod_e depends on sk_data_ready_assigned @
-expression E;
-identifier sk_data_ready_assigned.drv_data_ready;
-fresh identifier backport_drv_data_ready = "backport_" ## drv_data_ready;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- E->sk_data_ready = drv_data_ready;
-+#else
-+ E->sk_data_ready = backport_drv_data_ready;
-+#endif
-
-@ sk_data_ready_found @
-expression E;
-struct sock *sk;
-@@
-
- E->sk_data_ready(sk);
-
-@ sk_data_ready_skips_skb_queue_tail_E depends on sk_data_ready_found @
-expression E;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- E->sk_data_ready(E);
-+#else
-+ E->sk_data_ready(E, 0);
-+#endif
-
-@ sk_data_ready_uses_skb_queue_tail depends on sk_data_ready_found && !sk_data_ready_skips_skb_queue_tail_E @
-struct sock *sk;
-struct sk_buff *skb;
-identifier sk_data_ready;
-@@
-
- skb_queue_tail(&sk->sk_receive_queue, skb);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- sk->sk_data_ready(sk);
-+#else
-+ sk->sk_data_ready(sk, skb->len);
-+#endif
-
+++ /dev/null
-In kernel 3.8 struct pci_driver got a new function pointer sriov_configure.
-Address this by putting ifdef around the code.
-
-
-commit 1789382a72a537447d65ea4131d8bcc1ad85ce7b
-Author: Donald Dutile <ddutile@redhat.com>
-Date: Mon Nov 5 15:20:36 2012 -0500
-
- PCI: SRIOV control and status via sysfs
-
-git describe --contains 1789382a72a537447d65ea4131d8bcc1ad85ce7b
-v3.8-rc1~128^2~6^2~4
-
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb_main.c
-+++ b/drivers/net/ethernet/intel/igb/igb_main.c
-@@ -7682,6 +7682,7 @@ static int igb_sriov_reinit(struct pci_d
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
- static int igb_pci_disable_sriov(struct pci_dev *dev)
- {
- int err = igb_disable_sriov(dev);
-@@ -7691,6 +7692,7 @@ static int igb_pci_disable_sriov(struct
-
- return err;
- }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
-
- static int igb_pci_enable_sriov(struct pci_dev *dev, int num_vfs)
- {
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct pci_driver s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
-.sriov_configure = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) */
+++ /dev/null
-In kernel 3.3 and 3.10 struct net_device_ops function pointers
-ndo_vlan_rx_add_vid and ndo_vlan_rx_kill_vid changed.
-Address this by putting ifdef around the code.
-
-
-commit 8e586137e6b63af1e881b328466ab5ffbe562510
-Author: Jiri Pirko <jpirko@redhat.com>
-Date: Thu Dec 8 19:52:37 2011 -0500
-
- net: make vlan ndo_vlan_rx_[add/kill]_vid return error value
-
-git describe --contains 8e586137e6b63af1e881b328466ab5ffbe562510
-v3.3-rc1~182^2~291
-
-
-commit 80d5c3689b886308247da295a228a54df49a44f6
-Author: Patrick McHardy <kaber@trash.net>
-Date: Fri Apr 19 02:04:28 2013 +0000
-
- net: vlan: prepare for 802.1ad VLAN filtering offload
-
-git describe --contains 80d5c3689b886308247da295a228a54df49a44f6
-v3.10-rc1~66^2~97^2~4
+++ /dev/null
---- a/drivers/net/usb/cdc_mbim.c
-+++ b/drivers/net/usb/cdc_mbim.c
-@@ -70,7 +70,13 @@ static int cdc_mbim_wdm_manage_power(str
- return cdc_mbim_manage_power(dev, status);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+static int cdc_mbim_rx_add_vid(struct net_device *netdev, u16 vid)
-+#else
-+static void cdc_mbim_rx_add_vid(struct net_device *netdev, u16 vid)
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
- {
- struct usbnet *dev = netdev_priv(netdev);
- struct cdc_mbim_state *info = (void *)&dev->data;
-@@ -78,13 +84,21 @@ static int cdc_mbim_rx_add_vid(struct ne
- /* creation of this VLAN is a request to tag IP session 0 */
- if (vid == MBIM_IPS0_VID)
- info->flags |= FLAG_IPS0_VLAN;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- else
- if (vid >= 512) /* we don't map these to MBIM session */
- return -EINVAL;
- return 0;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- static int cdc_mbim_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+static int cdc_mbim_rx_kill_vid(struct net_device *netdev, u16 vid)
-+#else
-+static void cdc_mbim_rx_kill_vid(struct net_device *netdev, u16 vid)
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
- {
- struct usbnet *dev = netdev_priv(netdev);
- struct cdc_mbim_state *info = (void *)&dev->data;
-@@ -92,7 +106,9 @@ static int cdc_mbim_rx_kill_vid(struct n
- /* this is a request for an untagged IP session 0 */
- if (vid == MBIM_IPS0_VID)
- info->flags &= ~FLAG_IPS0_VLAN;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- return 0;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
- }
-
- static const struct net_device_ops cdc_mbim_netdev_ops = {
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb_main.c
-+++ b/drivers/net/ethernet/intel/igb/igb_main.c
-@@ -158,8 +158,16 @@ static void igb_tx_timeout(struct net_de
- static void igb_reset_task(struct work_struct *);
- static void igb_vlan_mode(struct net_device *netdev,
- netdev_features_t features);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- static int igb_vlan_rx_add_vid(struct net_device *, __be16, u16);
- static int igb_vlan_rx_kill_vid(struct net_device *, __be16, u16);
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+static int igb_vlan_rx_add_vid(struct net_device *, u16);
-+static int igb_vlan_rx_kill_vid(struct net_device *, u16);
-+#else
-+static void igb_vlan_rx_add_vid(struct net_device *, u16);
-+static void igb_vlan_rx_kill_vid(struct net_device *, u16);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
- static void igb_restore_vlan(struct igb_adapter *);
- static void igb_rar_set_qsel(struct igb_adapter *, u8 *, u32 , u8);
- static void igb_ping_all_vfs(struct igb_adapter *);
-@@ -7349,8 +7357,14 @@ static void igb_vlan_mode(struct net_dev
- igb_set_vf_vlan_strip(adapter, adapter->vfs_allocated_count, enable);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- static int igb_vlan_rx_add_vid(struct net_device *netdev,
- __be16 proto, u16 vid)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+static int igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
-+#else
-+static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
-+#endif
- {
- struct igb_adapter *adapter = netdev_priv(netdev);
- struct e1000_hw *hw = &adapter->hw;
-@@ -7362,11 +7376,19 @@ static int igb_vlan_rx_add_vid(struct ne
-
- set_bit(vid, adapter->active_vlans);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- return 0;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- static int igb_vlan_rx_kill_vid(struct net_device *netdev,
- __be16 proto, u16 vid)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+static int igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
-+#else
-+static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
- {
- struct igb_adapter *adapter = netdev_priv(netdev);
- int pf_id = adapter->vfs_allocated_count;
-@@ -7378,7 +7400,9 @@ static int igb_vlan_rx_kill_vid(struct n
-
- clear_bit(vid, adapter->active_vlans);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- return 0;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
- }
-
- static void igb_restore_vlan(struct igb_adapter *adapter)
-@@ -7386,10 +7410,18 @@ static void igb_restore_vlan(struct igb_
- u16 vid = 1;
-
- igb_vlan_mode(adapter->netdev, adapter->netdev->features);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0);
-+#else
-+ igb_vlan_rx_add_vid(adapter->netdev, 0);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
-
- for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
- igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid);
-+#else
-+ igb_vlan_rx_add_vid(adapter->netdev, vid);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) */
- }
-
- int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx)
+++ /dev/null
-In kernel 3.2 struct net_device_ops got a new function pointer
-ndo_set_vf_spoofchk. Address this by putting ifdef around the code.
-
-
-commit 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
-Author: Greg Rose <gregory.v.rose@intel.com>
-Date: Sat Oct 8 03:05:24 2011 +0000
-
- if_link: Add additional parameter to IFLA_VF_INFO for spoof checking
-
-git describe --contains 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
-v3.2-rc1~129^2~87
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct net_device_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-.ndo_set_vf_spoofchk = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
-};
-
-@r2@
-identifier s, func2;
-@@
-
-struct net_device_ops s = {
-.ndo_get_vf_config = func2,
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
-
-@@
-identifier r2.func2, ivi;
-expression assign;
-@@
-
-func2(... ,struct ifla_vf_info *ivi)
-{
- <...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
- ivi->spoofchk = assign;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
- ...>
-}
+++ /dev/null
-In kernel 3.4 a new field no_fcs was introduced to struct sk_buff.
-Address this by putting ifdef around the code.
-
-
-commit 3bdc0eba0b8b47797f4a76e377dd8360f317450f
-Author: Ben Greear <greearb@candelatech.com>
-Date: Sat Feb 11 15:39:30 2012 +0000
-
- net: Add framework to allow sending packets with customized CRC.
-
-git describe --contains 3bdc0eba0b8b47797f4a76e377dd8360f317450f
-v3.4-rc1~177^2~207
+++ /dev/null
-@r1@
-expression E1,E2;
-struct sk_buff *skb;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- E1 ^= E2(..., skb->no_fcs, ...)
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) */
+++ /dev/null
-In kernel 3.6 struct ethtool_ops received 2 new function pointers get_eee
-and set_eee. Address this by putting ifdef around the code.
-
-
-commit 80f12eccce775dc6bb93dba9b52529740f929237
-Author: Yuval Mintz <yuvalmin@broadcom.com>
-Date: Wed Jun 6 17:13:06 2012 +0000
-
- Added kernel support in EEE Ethtool commands
-
-git describe --contains 80f12eccce775dc6bb93dba9b52529740f929237
-v3.6-rc1~125^2~587
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct ethtool_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-.get_eee = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
-};
-
-@r2@
-identifier s, func;
-@@
-
-struct ethtool_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-.set_eee = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
-
-@@
-identifier r2.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+++ /dev/null
-In kernel 3.5 struct ethtool_ops received 2 new function pointers
-get_module_info and get_module_eeprom. Address this by putting ifdef around
-the code.
-
-
-commit 41c3cb6d20f0252308e9796fa4f3dacb4960de91
-Author: Stuart Hodgson <smhodgson@solarflare.com>
-Date: Thu Apr 19 09:44:42 2012 +0100
-
- ethtool: Extend the ethtool API to obtain plugin module eeprom data
-
-git describe --contains 41c3cb6d20f0252308e9796fa4f3dacb4960de91
-v3.5-rc1~109^2~124^2~2
-
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct ethtool_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-.get_module_info = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
-};
-
-@r2@
-identifier s, func;
-@@
-
-struct ethtool_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-.get_module_eeprom = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
-
-@@
-identifier r2.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+++ /dev/null
-In kernel 3.3 struct ethtool_ops received 3 new function pointers
-get_rxfh_indir_size, get_rxfh_indir, set_rxfh_indir.
-Address this by putting ifdef around the code.
-
-
-commit 7850f63f1620512631445b901ae11cd149e7375c
-Author: Ben Hutchings <bhutchings@solarflare.com>
-Date: Thu Dec 15 13:55:01 2011 +0000
-
- ethtool: Centralise validation of ETHTOOL_{G, S}RXFHINDIR parameters
-
-git describe --contains 7850f63f1620512631445b901ae11cd149e7375c
-v3.3-rc1~182^2~192
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
-+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
-@@ -2860,19 +2860,28 @@ static void igb_ethtool_complete(struct
- pm_runtime_put(&adapter->pdev->dev);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- static u32 igb_get_rxfh_indir_size(struct net_device *netdev)
- {
- return IGB_RETA_SIZE;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
- u8 *hfunc)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
-+static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
-+#else
-+static int igb_get_rxfh(struct net_device *netdev, u32 *indir)
-+#endif
- {
- struct igb_adapter *adapter = netdev_priv(netdev);
- int i;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- if (hfunc)
- *hfunc = ETH_RSS_HASH_TOP;
-+#endif
- if (!indir)
- return 0;
- for (i = 0; i < IGB_RETA_SIZE; i++)
-@@ -2880,6 +2889,7 @@ static int igb_get_rxfh(struct net_devic
-
- return 0;
- }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
-
- void igb_write_rss_indir_tbl(struct igb_adapter *adapter)
- {
-@@ -2916,18 +2926,28 @@ void igb_write_rss_indir_tbl(struct igb_
- }
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
- const u8 *key, const u8 hfunc)
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
-+static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
-+ const u8 *key)
-+#else
-+static int igb_set_rxfh(struct net_device *netdev, const u32 *indir)
-+#endif
- {
- struct igb_adapter *adapter = netdev_priv(netdev);
- struct e1000_hw *hw = &adapter->hw;
- int i;
- u32 num_queues;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- /* We do not allow change in unsupported parameters */
- if (key ||
- (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
- return -EOPNOTSUPP;
-+#endif
- if (!indir)
- return 0;
-
-@@ -2956,6 +2976,7 @@ static int igb_set_rxfh(struct net_devic
-
- return 0;
- }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
-
- static unsigned int igb_max_channels(struct igb_adapter *adapter)
- {
-@@ -3075,9 +3096,15 @@ static const struct ethtool_ops igb_etht
- .set_eee = igb_set_eee,
- .get_module_info = igb_get_module_info,
- .get_module_eeprom = igb_get_module_eeprom,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
- .get_rxfh_indir_size = igb_get_rxfh_indir_size,
- .get_rxfh = igb_get_rxfh,
- .set_rxfh = igb_set_rxfh,
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-+ .get_rxfh_indir_size = igb_get_rxfh_indir_size,
-+ .get_rxfh_indir = igb_get_rxfh,
-+ .set_rxfh_indir = igb_set_rxfh,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
- .get_channels = igb_get_channels,
- .set_channels = igb_set_channels,
- .begin = igb_ethtool_begin,
+++ /dev/null
-In kernel 3.2 an argument type of function pointer get_rxnfc in
-struct ethtool_ops changed from void to u32.
-Address this by putting ifdef around the code.
-
-
-commit 815c7db5c809ea3d5735de3131ecdf758b0e14ff
-Author: Ben Hutchings <bhutchings@solarflare.com>
-Date: Tue Sep 6 13:49:12 2011 +0000
-
- ethtool: Clean up definitions of rule location arrays in RX NFC
-
-git describe --contains 815c7db5c809ea3d5735de3131ecdf758b0e14ff
-v3.2-rc1~129^2~272
-
+++ /dev/null
-@r@
-identifier s,func;
-@@
-
-struct ethtool_ops s = {
-.get_rxnfc = func,
-};
-
-@@
-identifier r.func,rule_locs;
-typedef u32;
-@@
-
-// ----------------------------------------------------------------------
-
-func(...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-,u32 *rule_locs
-+#else
-+,void *rule_locs
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
- ) { ... }
+++ /dev/null
-In kernel 3.7 struct ethtool_cmd received eth_tp_mdix and eth_tp_mdix_ctrl.
-Address this by putting ifdef around the code using these struct components.
-
-
-commit 6f6bbc186dc8e4e0c628db7decbd1a5e02cb5fd8
-Author: Jesse Brandeburg <jesse.brandeburg@intel.com>
-Date: Thu Jul 26 02:30:53 2012 +0000
-
- ethtool.h: MDI setting support
-
-git describe --contains 6f6bbc186dc8e4e0c628db7decbd1a5e02cb5fd8
-v3.7-rc1~145^2~300^2~5
-
+++ /dev/null
-@r1@
-expression E1;
-struct ethtool_cmd *ecmd;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- ecmd->eth_tp_mdix_ctrl = E1;
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
-
-@r2@
-struct ethtool_cmd *ecmd;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- if (ecmd->eth_tp_mdix_ctrl) {...}
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
+++ /dev/null
-In kernel 3.7 struct pci_driver changed pci_error_handlers to const.
-Address this by putting ifdef around the code.
-
-
-commit 494530284f16298050ab99f54b7b12dd7d1418a1
-Author: Stephen Hemminger <shemminger@vyatta.com>
-Date: Fri Sep 7 09:33:14 2012 -0700
-
- PCI: Make pci_error_handlers const
-
-git describe --contains 494530284f16298050ab99f54b7b12dd7d1418a1
-v3.7-rc1~177^2~9^2~3
+++ /dev/null
---- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
-+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
-@@ -2555,7 +2555,11 @@ static void atl1e_io_resume(struct pci_d
- netif_device_attach(netdev);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- static const struct pci_error_handlers atl1e_err_handler = {
-+#else
-+static struct pci_error_handlers atl1e_err_handler = {
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
- .error_detected = atl1e_io_error_detected,
- .slot_reset = atl1e_io_slot_reset,
- .resume = atl1e_io_resume,
+++ /dev/null
-@@
-identifier s;
-@@
-
-static
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
-const
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
-struct pci_error_handlers s = { ... };
+++ /dev/null
-In kernel 3.16 struct net_device_ops changed and renamed pointer
-ndo_set_vf_tx_rate to ndo_set_vf_rate.
-
-commit ed616689a3d95eb6c9bdbb1ef74b0f50cbdf276a
-Author: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
-Date: Thu May 22 09:59:05 2014 -0400
-
- net-next:v4: Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool.
-
-commit 5f8444a3fa617076f8da51a3e8ecce01a5d7f738
-Author: Greg Rose <gregory.v.rose@intel.com>
-Date: Sat Oct 8 03:05:24 2011 +0000
-
- if_link: Add additional parameter to IFLA_VF_INFO for spoof checking
-
-git describe --contains ed616689a3d95eb6c9bdbb1ef74b0f50cbdf276a
-v3.16-rc1~27^2~151
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb_main.c
-+++ b/drivers/net/ethernet/intel/igb/igb_main.c
-@@ -8013,6 +8013,7 @@ static int igb_ndo_set_vf_bw(struct net_
- if (hw->mac.type != e1000_82576)
- return -EOPNOTSUPP;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
- if (min_tx_rate)
- return -EINVAL;
-
-@@ -8026,7 +8027,17 @@ static int igb_ndo_set_vf_bw(struct net_
- adapter->vf_rate_link_speed = actual_link_speed;
- adapter->vf_data[vf].tx_rate = (u16)max_tx_rate;
- igb_set_vf_rate_limit(hw, vf, max_tx_rate, actual_link_speed);
-+#else
-+ actual_link_speed = igb_link_mbps(adapter->link_speed);
-+ if ((vf >= adapter->vfs_allocated_count) ||
-+ (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) ||
-+ (tx_rate < 0) || (tx_rate > actual_link_speed))
-+ return -EINVAL;
-
-+ adapter->vf_rate_link_speed = actual_link_speed;
-+ adapter->vf_data[vf].tx_rate = (u16)tx_rate;
-+ igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
- return 0;
- }
-
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct net_device_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
-.ndo_set_vf_rate = func,
-+#else
-+.ndo_set_vf_tx_rate = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
-};
-
-@r2@
-identifier s, func2;
-@@
-
-struct net_device_ops s = {
-.ndo_get_vf_config = func2,
-};
-
-// ----------------------------------------------------------------------
-
-@@
-identifier r1.func, min_tx_rate, max_tx_rate;
-@@
-
-func(...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
- ,int min_tx_rate, int max_tx_rate
-+#else
-+,int tx_rate
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
- ) { ... }
-
-@@
-identifier r2.func2, ivi;
-expression assign, assign2;
-@@
-
-func2(... ,struct ifla_vf_info *ivi)
-{
- <...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
- ivi->max_tx_rate = assign;
- ivi->min_tx_rate = assign2;
-+#else
-+ivi->tx_rate = assign;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
- ...>
-}
+++ /dev/null
---- a/net/ieee802154/dgram.c
-+++ b/net/ieee802154/dgram.c
-@@ -480,8 +480,13 @@ static int dgram_setsockopt(struct sock
- ro->want_ack = !!val;
- break;
- case WPAN_SECURITY:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
- if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
- !ns_capable(net->user_ns, CAP_NET_RAW)) {
-+#else
-+ if (!capable(CAP_NET_ADMIN) &&
-+ !capable(CAP_NET_RAW)) {
-+#endif
- err = -EPERM;
- break;
- }
-@@ -504,8 +509,13 @@ static int dgram_setsockopt(struct sock
- }
- break;
- case WPAN_SECURITY_LEVEL:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
- if (!ns_capable(net->user_ns, CAP_NET_ADMIN) &&
- !ns_capable(net->user_ns, CAP_NET_RAW)) {
-+#else
-+ if (!capable(CAP_NET_ADMIN) &&
-+ !capable(CAP_NET_RAW)) {
-+#endif
- err = -EPERM;
- break;
- }
+++ /dev/null
---- a/drivers/bluetooth/hci_vhci.c
-+++ b/drivers/bluetooth/hci_vhci.c
-@@ -151,6 +151,7 @@ static int vhci_create_device(struct vhc
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- static inline ssize_t vhci_get_user(struct vhci_data *data,
- struct iov_iter *from)
- {
-@@ -158,6 +159,17 @@ static inline ssize_t vhci_get_user(stru
- struct sk_buff *skb;
- __u8 pkt_type, opcode;
- int ret;
-+#else
-+static inline ssize_t vhci_get_user(struct vhci_data *data,
-+ const struct iovec *iov,
-+ unsigned long count)
-+{
-+ size_t len = iov_length(iov, count);
-+ struct sk_buff *skb;
-+ __u8 pkt_type, opcode;
-+ unsigned long i;
-+ int ret;
-+#endif
-
- if (len < 2 || len > HCI_MAX_FRAME_SIZE)
- return -EINVAL;
-@@ -166,10 +178,20 @@ static inline ssize_t vhci_get_user(stru
- if (!skb)
- return -ENOMEM;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- if (copy_from_iter(skb_put(skb, len), len, from) != len) {
- kfree_skb(skb);
- return -EFAULT;
- }
-+#else
-+ for (i = 0; i < count; i++) {
-+ if (copy_from_user(skb_put(skb, iov[i].iov_len),
-+ iov[i].iov_base, iov[i].iov_len)) {
-+ kfree_skb(skb);
-+ return -EFAULT;
-+ }
-+ }
-+#endif
-
- pkt_type = *((__u8 *) skb->data);
- skb_pull(skb, 1);
-@@ -281,12 +303,21 @@ static ssize_t vhci_read(struct file *fi
- return ret;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- static ssize_t vhci_write(struct kiocb *iocb, struct iov_iter *from)
-+#else
-+static ssize_t vhci_write(struct kiocb *iocb, const struct iovec *iov,
-+ unsigned long count, loff_t pos)
-+#endif
- {
- struct file *file = iocb->ki_filp;
- struct vhci_data *data = file->private_data;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- return vhci_get_user(data, from);
-+#else
-+ return vhci_get_user(data, iov, count);
-+#endif
- }
-
- static unsigned int vhci_poll(struct file *file, poll_table *wait)
-@@ -351,7 +382,11 @@ static int vhci_release(struct inode *in
- static const struct file_operations vhci_fops = {
- .owner = THIS_MODULE,
- .read = vhci_read,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- .write_iter = vhci_write,
-+#else
-+ .aio_write = vhci_write,
-+#endif
- .poll = vhci_poll,
- .open = vhci_open,
- .release = vhci_release,
+++ /dev/null
-@r1@
-struct page *page;
-expression E1;
-@@
- return E1
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- || page_is_pfmemalloc(page)
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
- ;
+++ /dev/null
---- a/include/net/bluetooth/l2cap.h
-+++ b/include/net/bluetooth/l2cap.h
-@@ -619,6 +619,12 @@ struct l2cap_ops {
- struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
- unsigned long hdr_len,
- unsigned long len, int nb);
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ int (*memcpy_fromiovec) (struct l2cap_chan *chan,
-+ unsigned char *kdata,
-+ struct iovec *iov,
-+ int len);
-+#endif
- };
-
- struct l2cap_conn {
-@@ -912,6 +918,33 @@ static inline long l2cap_chan_no_get_snd
- return 0;
- }
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan,
-+ unsigned char *kdata,
-+ struct iovec *iov,
-+ int len)
-+{
-+ /* Following is safe since for compiler definitions of kvec and
-+ * iovec are identical, yielding the same in-core layout and alignment
-+ */
-+ struct kvec *vec = (struct kvec *)iov;
-+
-+ while (len > 0) {
-+ if (vec->iov_len) {
-+ int copy = min_t(unsigned int, len, vec->iov_len);
-+ memcpy(kdata, vec->iov_base, copy);
-+ len -= copy;
-+ kdata += copy;
-+ vec->iov_base += copy;
-+ vec->iov_len -= copy;
-+ }
-+ vec++;
-+ }
-+
-+ return 0;
-+}
-+#endif
-+
- extern bool disable_ertm;
-
- int l2cap_init_sockets(void);
---- a/net/bluetooth/6lowpan.c
-+++ b/net/bluetooth/6lowpan.c
-@@ -515,11 +515,18 @@ static int send_pkt(struct l2cap_chan *c
- */
- chan->data = skb;
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ memset(&msg, 0, sizeof(msg));
-+ msg.msg_iov = (struct iovec *) &iv;
-+ msg.msg_iovlen = 1;
-+#endif
- iv.iov_base = skb->data;
- iv.iov_len = skb->len;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- memset(&msg, 0, sizeof(msg));
- iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len);
-+#endif
-
- err = l2cap_chan_send(chan, &msg, skb->len);
- if (err > 0) {
-@@ -1017,6 +1024,9 @@ static const struct l2cap_ops bt_6lowpan
- .suspend = chan_suspend_cb,
- .get_sndtimeo = chan_get_sndtimeo_cb,
- .alloc_skb = chan_alloc_skb_cb,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
-+#endif
-
- .teardown = l2cap_chan_no_teardown,
- .defer = l2cap_chan_no_defer,
---- a/net/bluetooth/a2mp.c
-+++ b/net/bluetooth/a2mp.c
-@@ -63,7 +63,12 @@ static void a2mp_send(struct amp_mgr *mg
-
- memset(&msg, 0, sizeof(msg));
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, total_len);
-+#else
-+ msg.msg_iov = (struct iovec *) &iv;
-+ msg.msg_iovlen = 1;
-+#endif
-
- l2cap_chan_send(chan, &msg, total_len);
-
-@@ -753,6 +758,9 @@ static const struct l2cap_ops a2mp_chan_
- .resume = l2cap_chan_no_resume,
- .set_shutdown = l2cap_chan_no_set_shutdown,
- .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
-+#endif
- };
-
- static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
---- a/net/bluetooth/l2cap_core.c
-+++ b/net/bluetooth/l2cap_core.c
-@@ -2126,7 +2126,12 @@ static inline int l2cap_skbuff_fromiovec
- struct sk_buff **frag;
- int sent = 0;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
-+#else
-+ if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
-+ msg->msg_iov, count))
-+#endif
- return -EFAULT;
-
- sent += count;
-@@ -2146,8 +2151,13 @@ static inline int l2cap_skbuff_fromiovec
-
- *frag = tmp;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- if (copy_from_iter(skb_put(*frag, count), count,
- &msg->msg_iter) != count)
-+#else
-+ if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
-+ msg->msg_iov, count))
-+#endif
- return -EFAULT;
-
- sent += count;
---- a/net/bluetooth/l2cap_sock.c
-+++ b/net/bluetooth/l2cap_sock.c
-@@ -1383,6 +1383,15 @@ static struct sk_buff *l2cap_sock_alloc_
- return skb;
- }
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+static int l2cap_sock_memcpy_fromiovec_cb(struct l2cap_chan *chan,
-+ unsigned char *kdata,
-+ struct iovec *iov, int len)
-+{
-+ return memcpy_fromiovec(kdata, iov, len);
-+}
-+#endif
-+
- static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
- {
- struct sock *sk = chan->data;
-@@ -1467,6 +1476,9 @@ static const struct l2cap_ops l2cap_chan
- .set_shutdown = l2cap_sock_set_shutdown_cb,
- .get_sndtimeo = l2cap_sock_get_sndtimeo_cb,
- .alloc_skb = l2cap_sock_alloc_skb_cb,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ .memcpy_fromiovec = l2cap_sock_memcpy_fromiovec_cb,
-+#endif
- };
-
- static void l2cap_sock_destruct(struct sock *sk)
---- a/net/bluetooth/smp.c
-+++ b/net/bluetooth/smp.c
-@@ -612,7 +612,12 @@ static void smp_send_cmd(struct l2cap_co
-
- memset(&msg, 0, sizeof(msg));
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iv, 2, 1 + len);
-+#else
-+ msg.msg_iov = (struct iovec *) &iv;
-+ msg.msg_iovlen = 2;
-+#endif
-
- l2cap_chan_send(chan, &msg, 1 + len);
-
-@@ -3066,6 +3071,9 @@ static const struct l2cap_ops smp_chan_o
- .suspend = l2cap_chan_no_suspend,
- .set_shutdown = l2cap_chan_no_set_shutdown,
- .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
-+#endif
- };
-
- static inline struct l2cap_chan *smp_new_conn_cb(struct l2cap_chan *pchan)
-@@ -3114,6 +3122,9 @@ static const struct l2cap_ops smp_root_c
- .resume = l2cap_chan_no_resume,
- .set_shutdown = l2cap_chan_no_set_shutdown,
- .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
-+#endif
- };
-
- static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
+++ /dev/null
---- a/drivers/ssb/pcihost_wrapper.c
-+++ b/drivers/ssb/pcihost_wrapper.c
-@@ -33,7 +33,9 @@ static int ssb_pcihost_suspend(struct de
-
- /* if there is a wakeup enabled child device on ssb bus,
- enable pci wakeup posibility. */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
- device_set_wakeup_enable(d, d->power.wakeup_path);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
-
- pci_prepare_to_sleep(dev);
-
+++ /dev/null
-Programmable pins were introduced in the ptp subsystem in kernel 3.15
-and igb makes use of them now. These patches are removing the code
-accessing these new functions.
-
-These patches are needed for every kernel which does not have this
-commit:
-commit 6092315dfdec5185881605d15a0e200d6e90eb66
-Author: Richard Cochran <richardcochran@gmail.com>
-Date: Thu Mar 20 22:21:52 2014 +0100
-
- ptp: introduce programmable pins.
-
- This patch adds a pair of new ioctls to the PTP Hardware Clock device
- interface. Using the ioctls, user space programs can query each pin to
- find out its current function and also reprogram a different function
- if desired.
-
- Signed-off-by: Richard Cochran <richardcochran@gmail.com>
- Signed-off-by: David S. Miller <davem@davemloft.net>
-
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb.h
-+++ b/drivers/net/ethernet/intel/igb/igb.h
-@@ -443,7 +443,9 @@ struct igb_adapter {
- u32 tx_hwtstamp_timeouts;
- u32 rx_hwtstamp_cleared;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- struct ptp_pin_desc sdp_config[IGB_N_SDP];
-+#endif
- struct {
- struct timespec64 start;
- struct timespec64 period;
---- a/drivers/net/ethernet/intel/igb/igb_ptp.c
-+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
-@@ -115,6 +115,7 @@ static cycle_t igb_ptp_read_82580(const
- return val;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- /* SYSTIM read access for I210/I211 */
- static void igb_ptp_read_i210(struct igb_adapter *adapter,
- struct timespec64 *ts)
-@@ -133,6 +134,7 @@ static void igb_ptp_read_i210(struct igb
- ts->tv_sec = sec;
- ts->tv_nsec = nsec;
- }
-+#endif
-
- static void igb_ptp_write_i210(struct igb_adapter *adapter,
- const struct timespec64 *ts)
-@@ -265,6 +267,7 @@ static int igb_ptp_adjtime_82576(struct
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
- {
- struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
-@@ -282,6 +285,7 @@ static int igb_ptp_adjtime_i210(struct p
-
- return 0;
- }
-+#endif
-
- static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
- struct timespec64 *ts)
-@@ -302,6 +306,7 @@ static int igb_ptp_gettime_82576(struct
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp,
- struct timespec64 *ts)
- {
-@@ -317,6 +322,7 @@ static int igb_ptp_gettime_i210(struct p
-
- return 0;
- }
-+#endif
-
- static int igb_ptp_settime_82576(struct ptp_clock_info *ptp,
- const struct timespec64 *ts)
-@@ -337,6 +343,7 @@ static int igb_ptp_settime_82576(struct
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- static int igb_ptp_settime_i210(struct ptp_clock_info *ptp,
- const struct timespec64 *ts)
- {
-@@ -598,6 +605,7 @@ static int igb_ptp_feature_enable_i210(s
-
- return -EOPNOTSUPP;
- }
-+#endif
-
- static int igb_ptp_feature_enable(struct ptp_clock_info *ptp,
- struct ptp_clock_request *rq, int on)
-@@ -605,6 +613,7 @@ static int igb_ptp_feature_enable(struct
- return -EOPNOTSUPP;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- static int igb_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
- enum ptp_pin_function func, unsigned int chan)
- {
-@@ -618,6 +627,7 @@ static int igb_ptp_verify_pin(struct ptp
- }
- return 0;
- }
-+#endif
-
- /**
- * igb_ptp_tx_work
-@@ -1010,7 +1020,9 @@ void igb_ptp_init(struct igb_adapter *ad
- {
- struct e1000_hw *hw = &adapter->hw;
- struct net_device *netdev = adapter->netdev;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- int i;
-+#endif
-
- switch (hw->mac.type) {
- case e1000_82576:
-@@ -1051,6 +1063,7 @@ void igb_ptp_init(struct igb_adapter *ad
- /* Enable the timer functions by clearing bit 31. */
- wr32(E1000_TSAUXC, 0x0);
- break;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- case e1000_i210:
- case e1000_i211:
- for (i = 0; i < IGB_N_SDP; i++) {
-@@ -1077,6 +1090,7 @@ void igb_ptp_init(struct igb_adapter *ad
- /* Enable the timer functions by clearing bit 31. */
- wr32(E1000_TSAUXC, 0x0);
- break;
-+#endif
- default:
- adapter->ptp_clock = NULL;
- return;
-@@ -1088,11 +1102,14 @@ void igb_ptp_init(struct igb_adapter *ad
- INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
-
- /* Initialize the clock and overflow work for devices that need it. */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
- if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) {
- struct timespec64 ts = ktime_to_timespec64(ktime_get_real());
-
- igb_ptp_settime_i210(&adapter->ptp_caps, &ts);
-- } else {
-+ } else
-+#endif
-+ {
- timecounter_init(&adapter->tc, &adapter->cc,
- ktime_to_ns(ktime_get_real()));
-
+++ /dev/null
-diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
-index 04e5785..a251da1 100644
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -3350,12 +3350,12 @@ struct wiphy {
-
- static inline struct net *wiphy_net(struct wiphy *wiphy)
- {
-- return read_pnet(&wiphy->_net);
-+ return possible_read_pnet(&wiphy->_net);
- }
-
- static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
- {
-- write_pnet(&wiphy->_net, net);
-+ possible_write_pnet(&wiphy->_net, net);
- }
-
- /**
+++ /dev/null
---- a/drivers/bluetooth/btusb.c
-+++ b/drivers/bluetooth/btusb.c
-@@ -1845,8 +1845,12 @@ static void btusb_intel_bootup(struct bt
- return;
-
- if (test_and_clear_bit(BTUSB_BOOTING, &data->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&data->flags, BTUSB_BOOTING);
-+#else
-+ wake_up_interruptible(&data->hdev->req_wait_q);
-+#endif
- }
- }
-
-@@ -1863,8 +1867,12 @@ static void btusb_intel_secure_send_resu
-
- if (test_and_clear_bit(BTUSB_DOWNLOADING, &data->flags) &&
- test_bit(BTUSB_FIRMWARE_LOADED, &data->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&data->flags, BTUSB_DOWNLOADING);
-+#else
-+ wake_up_interruptible(&data->hdev->req_wait_q);
-+#endif
- }
- }
-
-@@ -2208,6 +2216,7 @@ static int btusb_setup_intel_new(struct
- * and thus just timeout if that happens and fail the setup
- * of this device.
- */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
- TASK_INTERRUPTIBLE,
- msecs_to_jiffies(5000));
-@@ -2222,6 +2231,31 @@ static int btusb_setup_intel_new(struct
- err = -ETIMEDOUT;
- goto done;
- }
-+#else
-+ if (test_bit(BTUSB_DOWNLOADING, &data->flags)) {
-+ DECLARE_WAITQUEUE(wait, current);
-+ signed long timeout;
-+
-+ add_wait_queue(&hdev->req_wait_q, &wait);
-+ set_current_state(TASK_INTERRUPTIBLE);
-+
-+ timeout = schedule_timeout(msecs_to_jiffies(5000));
-+
-+ remove_wait_queue(&hdev->req_wait_q, &wait);
-+
-+ if (signal_pending(current)) {
-+ BT_ERR("%s: Firmware loading interrupted", hdev->name);
-+ err = -EINTR;
-+ goto done;
-+ }
-+
-+ if (!timeout) {
-+ BT_ERR("%s: Firmware loading timeout", hdev->name);
-+ err = -ETIMEDOUT;
-+ goto done;
-+ }
-+ }
-+#endif
-
- if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) {
- BT_ERR("%s: Firmware loading failed", hdev->name);
-@@ -2261,6 +2295,7 @@ done:
- */
- BT_INFO("%s: Waiting for device to boot", hdev->name);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
- TASK_INTERRUPTIBLE,
- msecs_to_jiffies(1000));
-@@ -2274,6 +2309,33 @@ done:
- BT_ERR("%s: Device boot timeout", hdev->name);
- return -ETIMEDOUT;
- }
-+#else
-+ if (test_bit(BTUSB_BOOTING, &data->flags)) {
-+ DECLARE_WAITQUEUE(wait, current);
-+ signed long timeout;
-+
-+ add_wait_queue(&hdev->req_wait_q, &wait);
-+ set_current_state(TASK_INTERRUPTIBLE);
-+
-+ /* Booting into operational firmware should not take
-+ * longer than 1 second. However if that happens, then
-+ * just fail the setup since something went wrong.
-+ */
-+ timeout = schedule_timeout(msecs_to_jiffies(1000));
-+
-+ remove_wait_queue(&hdev->req_wait_q, &wait);
-+
-+ if (signal_pending(current)) {
-+ BT_ERR("%s: Device boot interrupted", hdev->name);
-+ return -EINTR;
-+ }
-+
-+ if (!timeout) {
-+ BT_ERR("%s: Device boot timeout", hdev->name);
-+ return -ETIMEDOUT;
-+ }
-+ }
-+#endif
-
- rettime = ktime_get();
- delta = ktime_sub(rettime, calltime);
+++ /dev/null
---- a/drivers/bluetooth/hci_intel.c
-+++ b/drivers/bluetooth/hci_intel.c
-@@ -122,8 +122,9 @@ static u8 intel_convert_speed(unsigned i
- static int intel_wait_booting(struct hci_uart *hu)
- {
- struct intel_data *intel = hu->priv;
-- int err;
-+ int err = 0;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- err = wait_on_bit_timeout(&intel->flags, STATE_BOOTING,
- TASK_INTERRUPTIBLE,
- msecs_to_jiffies(1000));
-@@ -137,6 +138,33 @@ static int intel_wait_booting(struct hci
- bt_dev_err(hu->hdev, "Device boot timeout");
- return -ETIMEDOUT;
- }
-+#else
-+ if (test_bit(STATE_BOOTING, &intel->flags)) {
-+ DECLARE_WAITQUEUE(wait, current);
-+ signed long timeout;
-+
-+ add_wait_queue(&hu->hdev->req_wait_q, &wait);
-+ set_current_state(TASK_INTERRUPTIBLE);
-+
-+ /* Booting into operational firmware should not take
-+ * longer than 1 second. However if that happens, then
-+ * just fail the setup since something went wrong.
-+ */
-+ timeout = schedule_timeout(msecs_to_jiffies(1000));
-+
-+ remove_wait_queue(&hu->hdev->req_wait_q, &wait);
-+
-+ if (signal_pending(current)) {
-+ BT_ERR("%s: Device boot interrupted", hu->hdev->name);
-+ return -EINTR;
-+ }
-+
-+ if (!timeout) {
-+ BT_ERR("%s: Device boot timeout", hu->hdev->name);
-+ return -ETIMEDOUT;
-+ }
-+ }
-+#endif
-
- return err;
- }
-@@ -145,8 +173,9 @@ static int intel_wait_booting(struct hci
- static int intel_wait_lpm_transaction(struct hci_uart *hu)
- {
- struct intel_data *intel = hu->priv;
-- int err;
-+ int err = 0;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- err = wait_on_bit_timeout(&intel->flags, STATE_LPM_TRANSACTION,
- TASK_INTERRUPTIBLE,
- msecs_to_jiffies(1000));
-@@ -160,6 +189,29 @@ static int intel_wait_lpm_transaction(st
- bt_dev_err(hu->hdev, "LPM transaction timeout");
- return -ETIMEDOUT;
- }
-+#else
-+ if (test_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
-+ DECLARE_WAITQUEUE(wait, current);
-+ signed long timeout;
-+
-+ add_wait_queue(&hu->hdev->req_wait_q, &wait);
-+ set_current_state(TASK_INTERRUPTIBLE);
-+
-+ timeout = schedule_timeout(msecs_to_jiffies(1000));
-+
-+ remove_wait_queue(&hu->hdev->req_wait_q, &wait);
-+
-+ if (signal_pending(current)) {
-+ BT_ERR("%s: LPM transaction interrupted", hu->hdev->name);
-+ return -EINTR;
-+ }
-+
-+ if (!timeout) {
-+ BT_ERR("%s: LPM transaction timeout", hu->hdev->name);
-+ return -ETIMEDOUT;
-+ }
-+ }
-+#endif
-
- return err;
- }
-@@ -812,6 +864,7 @@ static int intel_setup(struct hci_uart *
- * and thus just timeout if that happens and fail the setup
- * of this device.
- */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- err = wait_on_bit_timeout(&intel->flags, STATE_DOWNLOADING,
- TASK_INTERRUPTIBLE,
- msecs_to_jiffies(5000));
-@@ -826,6 +879,33 @@ static int intel_setup(struct hci_uart *
- err = -ETIMEDOUT;
- goto done;
- }
-+#else
-+ if (test_bit(STATE_DOWNLOADING, &intel->flags)) {
-+ DECLARE_WAITQUEUE(wait, current);
-+ signed long timeout;
-+
-+ add_wait_queue(&hdev->req_wait_q, &wait);
-+ set_current_state(TASK_INTERRUPTIBLE);
-+
-+ /* Booting into operational firmware should not take
-+ * longer than 1 second. However if that happens, then
-+ * just fail the setup since something went wrong.
-+ */
-+ timeout = schedule_timeout(msecs_to_jiffies(5000));
-+
-+ remove_wait_queue(&hdev->req_wait_q, &wait);
-+
-+ if (signal_pending(current)) {
-+ BT_ERR("%s: Firmware loading interrupted", hdev->name);
-+ return -EINTR;
-+ }
-+
-+ if (!timeout) {
-+ BT_ERR("%s: Firmware loading timeout", hdev->name);
-+ return -ETIMEDOUT;
-+ }
-+ }
-+#endif
-
- if (test_bit(STATE_FIRMWARE_FAILED, &intel->flags)) {
- bt_dev_err(hdev, "Firmware loading failed");
-@@ -957,8 +1037,12 @@ static int intel_recv_event(struct hci_d
-
- if (test_and_clear_bit(STATE_DOWNLOADING, &intel->flags) &&
- test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&intel->flags, STATE_DOWNLOADING);
-+#else
-+ wake_up_interruptible(&hu->hdev->req_wait_q);
-+#endif
- }
-
- /* When switching to the operational firmware the device
-@@ -968,8 +1052,12 @@ static int intel_recv_event(struct hci_d
- } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
- skb->data[2] == 0x02) {
- if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&intel->flags, STATE_BOOTING);
-+#else
-+ wake_up_interruptible(&hu->hdev->req_wait_q);
-+#endif
- }
- }
- recv:
-@@ -1008,15 +1096,23 @@ static int intel_recv_lpm(struct hci_dev
- case LPM_OP_SUSPEND_ACK:
- set_bit(STATE_SUSPENDED, &intel->flags);
- if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
-+#else
-+ wake_up_interruptible(&hu->hdev->req_wait_q);
-+#endif
- }
- break;
- case LPM_OP_RESUME_ACK:
- clear_bit(STATE_SUSPENDED, &intel->flags);
- if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- smp_mb__after_atomic();
- wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
-+#else
-+ wake_up_interruptible(&hu->hdev->req_wait_q);
-+#endif
- }
- break;
- default:
+++ /dev/null
-/*
-This provides the backport for the collateral evolution introduced
-via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
-"net: Remove iocb argument from sendmsg and recvmsg".
-
-The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
-relied historically on using an argument passed on the struct proto_ops
-and struct proto sendmsg and recvmsg callbacks to determine if it needed
-to perform a lock within its own code. Commit 1b784140474e4 removed replaced
-the locking functionality to require the argument and instead moved all
-the necessary heuristics into net/tipc. Other subsystems just passed NULL.
-After the net/tipc code was cleaned up from the locking (see commmit
-39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
-argument in socket layer") we no longer needed the extra argument on the
-struct proto_ops and struct proto callbacks.
-
-To backport non-tipc subsystems we then just need to modify the upstream
-code which declares these callbacks and add the extra argument again, but
-the same routine can be used from upstream code. The grammar we use below
-declares routines which can be pegged to struct proto_ops and struct proto
-callbacks that simply call the same upstream code, the extra argument is
-ignored. The argument can be ignored as it was only used within the
-net/tipc subsystem for locking purposes.
-*/
-
-@ proto_ops @
-identifier s, send_func, recv_func;
-@@
-
- struct proto_ops s = {
- .sendmsg = send_func,
- .recvmsg = recv_func,
-};
-
-@ mod_send depends on proto_ops @
-identifier proto_ops.send_func;
-fresh identifier backport_send = "backport_" ## send_func;
-@@
-
-send_func(...)
-{
- ...
-}
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
-+{
-+ return send_func(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
-@ mod_recv depends on proto_ops @
-identifier proto_ops.recv_func;
-fresh identifier backport_recv = "backport_" ## recv_func;
-@@
-
-recv_func(...)
-{
- ...
-}
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_recv(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+{
-+ return recv_func(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
-@ mod_proto_ops_tx depends on proto_ops && mod_send @
-identifier s, proto_ops.send_func, mod_send.backport_send;
-@@
-
- struct proto_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = send_func,
-+#else
-+ .sendmsg = backport_send,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-};
-
-@ mod_proto_ops_rx depends on proto_ops && mod_recv @
-identifier s, proto_ops.recv_func, mod_recv.backport_recv;
-@@
-
- struct proto_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = recv_func,
-+#else
-+ .recvmsg = backport_recv,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-};
-
-@ mod_sock_send_callers depends on proto_ops@
-identifier proto_ops.send_func;
-identifier sock, msg, len, sk;
-@@
-
-send_func(struct socket *sock, struct msghdr *msg, size_t len)
-{
- ...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- return sk->sk_prot->sendmsg(sk, msg, len);
-+#else
-+ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-}
-
-@ proto @
-identifier s, send_func, recv_func;
-@@
-
- struct proto s = {
- .sendmsg = send_func,
- .recvmsg = recv_func,
-};
-
-@ proto_mod_send depends on proto @
-identifier proto.send_func;
-fresh identifier backport_send = "backport_" ## send_func;
-@@
-
-send_func(...)
-{
- ...
-}
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_send(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t len)
-+{
-+ return send_func(sk, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
-@ proto_mod_recv depends on proto @
-identifier proto.recv_func;
-fresh identifier backport_recv = "backport_" ## recv_func;
-@@
-
-recv_func(...)
-{
- ...
-}
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_recv(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t len,
-+ int noblock, int flags, int *addr_len)
-+{
-+ return recv_func(sk, msg, len, noblock, flags, addr_len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
-@ mod_proto_tx depends on proto && proto_mod_send @
-identifier s, proto.send_func, proto_mod_send.backport_send;
-@@
-
- struct proto s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = send_func,
-+#else
-+ .sendmsg = backport_send,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-};
-
-@ mod_proto_rx depends on proto && proto_mod_recv @
-identifier s, proto.recv_func, proto_mod_recv.backport_recv;
-@@
-
- struct proto s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = recv_func,
-+#else
-+ .recvmsg = backport_recv,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-};
+++ /dev/null
---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
-+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
-@@ -2208,7 +2208,9 @@ struct wireless_dev *brcmf_p2p_add_vif(s
- }
-
- strncpy(ifp->ndev->name, name, sizeof(ifp->ndev->name) - 1);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- ifp->ndev->name_assign_type = name_assign_type;
-+#endif /* >= 3.17.0 */
- err = brcmf_net_attach(ifp, true);
- if (err) {
- brcmf_err("Registering netdevice failed\n");
+++ /dev/null
-@@
-struct net_device *dev;
-expression E;
-@@
--dev->tstats = E;
-+netdev_assign_tstats(dev, E);
-@@
-struct net_device *dev;
-@@
--dev->tstats
-+netdev_tstats(dev)
+++ /dev/null
-In kernel 3.19 function pointer ndo_gso_check is changed into
-ndo_features_check in struct net_device_ops.
-Address this by putting ifdef around the code.
-
-commit 5f35227ea34bb616c436d9da47fc325866c428f3
-Author: Jesse Gross <jesse@nicira.com>
-Date: Tue Dec 23 22:37:26 2014 -0800
-
- net: Generalize ndo_gso_check to ndo_features_check
-
-git describe --contains 5f35227ea34bb616c436d9da47fc325866c428f3
-v3.19-rc3~16^2~7
+++ /dev/null
-@r1@
-identifier s, func;
-@@
-
-struct net_device_ops s = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
-.ndo_features_check = func,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
-};
-
-// ----------------------------------------------------------------------
-
-@r2@
-identifier r1.func;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
-func(...) { ... }
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+++ /dev/null
-In kernel 4.1 struct ptp_clock_info changes function pointers gettime,
-settime to gettime64, settime64.
-
-commit 92f1719407b90475b3be0b7b9c983dec2ff8351e
-Author: Richard Cochran <richardcochran@gmail.com>
-Date: Sun Mar 29 23:11:51 2015 +0200
-
- ptp: introduce get/set time methods with explicit 64 bit seconds.
-
-git describe --contains 92f1719407b90475b3be0b7b9c983dec2ff8351e
-next-20150401~92^2~18^2~22
+++ /dev/null
-// ----------------------------------------------------------------------------
-// handle gettime64 to gettime function assignments
-@r1@
-expression E1, E2;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- E1.gettime64 = E2;
-+#else
-+E1.gettime = E2;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-
-// ----------------------------------------------------------------------------
-// handle calls to gettime64 as calls to gettime
-@r2@
-expression E1, E2, E3;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- E1.gettime64(E2, E3);
-+#else
-+E1.gettime(E2, E3);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-
-// ----------------------------------------------------------------------------
-// handle settime64 to settime function assignments
-@r3@
-expression E1, E2;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- E1.settime64 = E2;
-+#else
-+E1.settime = E2;
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-
+++ /dev/null
-In kernel 3.18 __u8 xmit_more is added to struct sk_buff.
-
-commit 0b725a2ca61bedc33a2a63d0451d528b268cf975
-Author: David S. Miller <davem@davemloft.net>
-Date: Mon Aug 25 15:51:53 2014 -0700
-
- net: Remove ndo_xmit_flush netdev operation, use signalling instead.
-
-git describe --contains 0b725a2ca61bedc33a2a63d0451d528b268cf975
-v3.18-rc1~52^2~228
+++ /dev/null
-@r1@
-struct sk_buff *skb;
-expression E1;
-@@
- if (E1
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
- || !skb->xmit_more
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) */
- ) {...}
+++ /dev/null
-The uuid member was added to the struct mei_cl_device_id in this commit:
-commit c93b76b34b4d8dbe8e3443eb27e49ac60034342b
-Author: Tomas Winkler <tomas.winkler@intel.com>
-Date: Thu May 7 15:54:02 2015 +0300
-
- mei: bus: report also uuid in module alias
-
+++ /dev/null
---- a/drivers/nfc/microread/mei.c
-+++ b/drivers/nfc/microread/mei.c
-@@ -67,7 +67,13 @@ static int microread_mei_remove(struct m
- }
-
- static struct mei_cl_device_id microread_mei_tbl[] = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
- { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
-+ { MICROREAD_DRIVER_NAME, MEI_NFC_UUID},
-+#else
-+ { MICROREAD_DRIVER_NAME},
-+#endif
-
- /* required last entry */
- { }
---- a/drivers/nfc/pn544/mei.c
-+++ b/drivers/nfc/pn544/mei.c
-@@ -67,7 +67,13 @@ static int pn544_mei_remove(struct mei_c
- }
-
- static struct mei_cl_device_id pn544_mei_tbl[] = {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
- { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
-+ { PN544_DRIVER_NAME, MEI_NFC_UUID},
-+#else
-+ { PN544_DRIVER_NAME},
-+#endif
-
- /* required last entry */
- { }
+++ /dev/null
-deactivate struct tracing
-
-__field_struct was added in Linux commit 4d4c9cc83. It is hard to backport
-this feature, so just remove the code using it on kernel version < 3.16.
-
-commit 4d4c9cc839a308be3289a361ccba4447ee140552
-Author: Steven Rostedt <rostedt@goodmis.org>
-Date: Tue Jun 17 08:59:16 2014 -0400
-
- tracing: Add __field_struct macro for TRACE_EVENT()
-
+++ /dev/null
-diff --git a/drivers/net/wireless/mediatek/mt7601u/trace.h b/drivers/net/wireless/mediatek/mt7601u/trace.h
-index 2898973..7fa1b96 100644
---- a/drivers/net/wireless/mediatek/mt7601u/trace.h
-+++ b/drivers/net/wireless/mediatek/mt7601u/trace.h
-@@ -252,6 +252,7 @@ TRACE_EVENT(freq_cal_offset,
- DEV_PR_ARG, __entry->phy_mode, __entry->freq_off)
- );
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
- TRACE_EVENT(mt_rx,
- TP_PROTO(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi, u32 f),
- TP_ARGS(dev, rxwi, f),
-@@ -306,6 +307,20 @@ TRACE_EVENT(mt_tx,
- __entry->h.ack_ctl, __entry->h.wcid,
- le16_to_cpu(__entry->h.len_ctl))
- );
-+#else
-+#ifndef __BACKPORT_MT7601U_TRACE_H_EXTRA
-+#define __BACKPORT_MT7601U_TRACE_H_EXTRA
-+static inline void trace_mt_rx(struct mt7601u_dev *dev,
-+ struct mt7601u_rxwi *rxwi,
-+ u32 f)
-+{
-+}
-+static inline void trace_mt_tx(struct mt7601u_dev *dev, struct sk_buff *skb,
-+ struct mt76_sta *sta, struct mt76_txwi *h)
-+{
-+}
-+#endif /* __BACKPORT_MT7601U_TRACE_H_EXTRA */
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) */
-
- TRACE_EVENT(mt_tx_dma_done,
- TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb),
+++ /dev/null
-use old locking for struct tty_struct
-
-With kernel 3.12 a new locking was added to struct tty_struct. This
-patch makes the code use the old locking.
-
-The new locking was added in this commit:
-commit 6a1c0680cf3ba94356ecd58833e1540c93472a57
-Author: Peter Hurley <peter@hurleysoftware.com>
-Date: Sat Jun 15 09:14:23 2013 -0400
-
- tty: Convert termios_mutex to termios_rwsem
+++ /dev/null
---- a/net/nfc/nci/uart.c
-+++ b/net/nfc/nci/uart.c
-@@ -439,9 +439,17 @@ void nci_uart_set_config(struct nci_uart
- if (!nu->tty)
- return;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- down_read(&nu->tty->termios_rwsem);
-+#else
-+ mutex_lock(&nu->tty->termios_mutex);
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
- new_termios = nu->tty->termios;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- up_read(&nu->tty->termios_rwsem);
-+#else
-+ mutex_unlock(&nu->tty->termios_mutex);
-+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
- tty_termios_encode_baud_rate(&new_termios, baudrate, baudrate);
-
- if (flow_ctrl)
+++ /dev/null
---- a/drivers/bluetooth/hci_bcm.c
-+++ b/drivers/bluetooth/hci_bcm.c
-@@ -29,7 +29,9 @@
- #include <linux/acpi.h>
- #include <linux/platform_device.h>
- #include <linux/clk.h>
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- #include <linux/gpio/consumer.h>
-+#endif
- #include <linux/tty.h>
- #include <linux/interrupt.h>
- #include <linux/dmi.h>
-@@ -148,8 +150,10 @@ static int bcm_gpio_set_power(struct bcm
- if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled)
- clk_enable(dev->clk);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- gpiod_set_value(dev->shutdown, powered);
- gpiod_set_value(dev->device_wakeup, powered);
-+#endif
-
- if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled)
- clk_disable(dev->clk);
-@@ -520,7 +524,9 @@ static int bcm_suspend_device(struct dev
-
- /* Suspend the device */
- if (bdev->device_wakeup) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- gpiod_set_value(bdev->device_wakeup, false);
-+#endif
- bt_dev_dbg(bdev, "suspend, delaying 15 ms");
- mdelay(15);
- }
-@@ -535,7 +541,9 @@ static int bcm_resume_device(struct devi
- bt_dev_dbg(bdev, "");
-
- if (bdev->device_wakeup) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- gpiod_set_value(bdev->device_wakeup, true);
-+#endif
- bt_dev_dbg(bdev, "resume, delaying 15 ms");
- mdelay(15);
- }
-@@ -618,6 +626,7 @@ unlock:
- }
- #endif
-
-+#if defined(CONFIG_ACPI) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- static const struct acpi_gpio_params device_wakeup_gpios = { 0, 0, false };
- static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
- static const struct acpi_gpio_params host_wakeup_gpios = { 2, 0, false };
-@@ -629,7 +638,6 @@ static const struct acpi_gpio_mapping ac
- { },
- };
-
--#ifdef CONFIG_ACPI
- static u8 acpi_active_low = ACPI_ACTIVE_LOW;
-
- /* IRQ polarity of some chipsets are not defined correctly in ACPI table. */
-@@ -812,7 +820,7 @@ static const struct hci_uart_proto bcm_p
- .dequeue = bcm_dequeue,
- };
-
--#ifdef CONFIG_ACPI
-+#if defined(CONFIG_ACPI) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- static const struct acpi_device_id bcm_acpi_match[] = {
- { "BCM2E1A", 0 },
- { "BCM2E39", 0 },
-@@ -843,7 +851,9 @@ static struct platform_driver bcm_driver
- .remove = bcm_remove,
- .driver = {
- .name = "hci_bcm",
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- .acpi_match_table = ACPI_PTR(bcm_acpi_match),
-+#endif
- .pm = &bcm_pm_ops,
- },
- };
+++ /dev/null
---- a/drivers/bluetooth/hci_intel.c
-+++ b/drivers/bluetooth/hci_intel.c
-@@ -29,7 +29,9 @@
- #include <linux/wait.h>
- #include <linux/tty.h>
- #include <linux/platform_device.h>
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- #include <linux/gpio/consumer.h>
-+#endif
- #include <linux/acpi.h>
- #include <linux/interrupt.h>
- #include <linux/pm_runtime.h>
-@@ -379,7 +381,9 @@ static int intel_set_power(struct hci_ua
- BT_INFO("hu %p, Switching compatible pm device (%s) to %u",
- hu, dev_name(&idev->pdev->dev), powered);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- gpiod_set_value(idev->reset, powered);
-+#endif
-
- /* Provide to idev a hu reference which is used to run LPM
- * transactions (lpm suspend/resume) from PM callbacks.
-@@ -1306,14 +1310,17 @@ static int intel_probe(struct platform_d
-
- idev->pdev = pdev;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset",
- GPIOD_OUT_LOW);
- if (IS_ERR(idev->reset)) {
- dev_err(&pdev->dev, "Unable to retrieve gpio\n");
- return PTR_ERR(idev->reset);
- }
-+#endif
-
- idev->irq = platform_get_irq(pdev, 0);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- if (idev->irq < 0) {
- struct gpio_desc *host_wake;
-
-@@ -1332,12 +1339,15 @@ static int intel_probe(struct platform_d
- goto no_irq;
- }
- }
-+#endif
-
- /* Only enable wake-up/irq when controller is powered */
- device_set_wakeup_capable(&pdev->dev, true);
- device_wakeup_disable(&pdev->dev);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
- no_irq:
-+#endif
- platform_set_drvdata(pdev, idev);
-
- /* Place this instance on the device list */
-@@ -1345,8 +1355,10 @@ no_irq:
- list_add_tail(&idev->list, &intel_device_list);
- mutex_unlock(&intel_device_list_lock);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- dev_info(&pdev->dev, "registered, gpio(%d)/irq(%d).\n",
- desc_to_gpio(idev->reset), idev->irq);
-+#endif
-
- return 0;
- }
+++ /dev/null
-@@
-expression E;
-@@
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
- E->priv_flags |= IFF_NO_QUEUE;
-+#else
-+E->tx_queue_len = 0;
-+#endif
+++ /dev/null
-@@
-identifier ndisc_send_na;
-expression netdev, saddr, target, router, solicited, override, inc_opt;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
- ipv6_stub->ndisc_send_na(netdev, saddr, target, router, solicited, override, inc_opt);
-+#else
-+ipv6_stub->ndisc_send_na(netdev, NULL, saddr, target, router, solicited, override, inc_opt);
-+#endif
+++ /dev/null
---- a/include/net/cfg802154.h
-+++ b/include/net/cfg802154.h
-@@ -359,6 +359,7 @@ struct wpan_dev {
-
- #define to_phy(_dev) container_of(_dev, struct wpan_phy, dev)
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
- static inline int
- wpan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
- const struct ieee802154_addr *daddr,
-@@ -369,6 +370,7 @@ wpan_dev_hard_header(struct sk_buff *skb
-
- return wpan_dev->header_ops->create(skb, dev, daddr, saddr, len);
- }
-+#endif /* >= 3.19 */
-
- struct wpan_phy *
- wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size);
+++ /dev/null
-@ r1 @
-struct phy_device *phydev;
-@@
--phydev->mdio.addr
-+phydev_get_addr(phydev)
+++ /dev/null
-diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
-index e0bd013..9e78921 100644
---- a/net/ieee802154/socket.c
-+++ b/net/ieee802154/socket.c
-@@ -182,14 +182,20 @@ static int ieee802154_sock_ioctl(struct
- static HLIST_HEAD(raw_head);
- static DEFINE_RWLOCK(raw_lock);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
- static int raw_hash(struct sock *sk)
-+#else
-+static void raw_hash(struct sock *sk)
-+#endif
- {
- write_lock_bh(&raw_lock);
- sk_add_node(sk, &raw_head);
- sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
- write_unlock_bh(&raw_lock);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
- return 0;
-+#endif
- }
-
- static void raw_unhash(struct sock *sk)
-@@ -464,14 +470,20 @@ static inline struct dgram_sock *dgram_s
- return container_of(sk, struct dgram_sock, sk);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
- static int dgram_hash(struct sock *sk)
-+#else
-+static void dgram_hash(struct sock *sk)
-+#endif
- {
- write_lock_bh(&dgram_lock);
- sk_add_node(sk, &dgram_head);
- sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
- write_unlock_bh(&dgram_lock);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
- return 0;
-+#endif
- }
-
- static void dgram_unhash(struct sock *sk)
-@@ -1031,11 +1043,15 @@ static int ieee802154_create(struct net
- sock_set_flag(sk, SOCK_ZAPPED);
-
- if (sk->sk_prot->hash) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
- rc = sk->sk_prot->hash(sk);
- if (rc) {
- sk_common_release(sk);
- goto out;
- }
-+#else
-+ sk->sk_prot->hash(sk);
-+#endif
- }
-
- if (sk->sk_prot->init) {
+++ /dev/null
---- a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
-+++ b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
-@@ -2422,12 +2422,23 @@ int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir)
- */
- if (priv->mac80211_registered) {
- char buf[100];
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- struct dentry *mac80211_dir, *dev_dir;
-
- dev_dir = dbgfs_dir->d_parent;
- mac80211_dir = priv->hw->wiphy->debugfsdir;
-
- snprintf(buf, 100, "../../%pd2", dev_dir);
-+#else
-+ struct dentry *mac80211_dir, *dev_dir, *root_dir;
-+
-+ dev_dir = dbgfs_dir->d_parent;
-+ root_dir = dev_dir->d_parent;
-+ mac80211_dir = priv->hw->wiphy->debugfsdir;
-+
-+ snprintf(buf, 100, "../../%s/%s", root_dir->d_name.name,
-+ dev_dir->d_name.name);
-+#endif
-
- if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf))
- goto err;
---- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
-+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
-@@ -1731,8 +1731,13 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
- mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
-
- if (!mvmvif->dbgfs_dir) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
- dbgfs_dir);
-+#else
-+ IWL_ERR(mvm, "Failed to create debugfs directory under %s\n",
-+ dbgfs_dir->d_name.name);
-+#endif
- return;
- }
-
-@@ -1800,15 +1805,28 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
- * find
- * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
- */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- snprintf(buf, 100, "../../../%pd3/%pd",
- dbgfs_dir,
- mvmvif->dbgfs_dir);
-+#else
-+ snprintf(buf, 100, "../../../%s/%s/%s/%s",
-+ dbgfs_dir->d_parent->d_parent->d_name.name,
-+ dbgfs_dir->d_parent->d_name.name,
-+ dbgfs_dir->d_name.name,
-+ mvmvif->dbgfs_dir->d_name.name);
-+#endif
-
- mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
- mvm->debugfs_dir, buf);
- if (!mvmvif->dbgfs_slink)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- IWL_ERR(mvm, "Can't create debugfs symbolic link under %pd\n",
- dbgfs_dir);
-+#else
-+ IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n",
-+ dbgfs_dir->d_name.name);
-+#endif
- return;
- err:
- IWL_ERR(mvm, "Can't create debugfs entity\n");
---- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
-+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
-@@ -1942,7 +1942,13 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
- * Create a symlink with mac80211. It will be removed when mac80211
- * exists (before the opmode exists which removes the target.)
- */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
- snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent);
-+#else
-+ snprintf(buf, 100, "../../%s/%s",
-+ dbgfs_dir->d_parent->d_parent->d_name.name,
-+ dbgfs_dir->d_parent->d_name.name);
-+#endif
- if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
- goto err;
-
+++ /dev/null
---- a/drivers/bcma/main.c
-+++ b/drivers/bcma/main.c
-@@ -156,6 +156,7 @@ static struct device_node *bcma_of_find_
- return NULL;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
- static int bcma_of_irq_parse(struct device *parent,
- struct bcma_device *core,
- struct of_phandle_args *out_irq, int num)
-@@ -195,6 +196,13 @@ static unsigned int bcma_of_get_irq(stru
-
- return irq_create_of_mapping(&out_irq);
- }
-+#else
-+static unsigned int bcma_of_get_irq(struct device *parent,
-+ struct bcma_device *core, int num)
-+{
-+ return 0;
-+}
-+#endif
-
- static void bcma_of_fill_device(struct platform_device *parent,
- struct bcma_device *core)
+++ /dev/null
-diff --git a/net/mac80211/fils_aead.c b/net/mac80211/fils_aead.c
-index ecfdd97758a3..95fc9669ea4f 100644
---- a/net/mac80211/fils_aead.c
-+++ b/net/mac80211/fils_aead.c
-@@ -1,3 +1,4 @@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
- /*
- * FILS AEAD for (Re)Association Request/Response frames
- * Copyright 2016, Qualcomm Atheros, Inc.
-@@ -340,3 +341,4 @@ int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
- *frame_len -= AES_BLOCK_SIZE;
- return 0;
- }
-+#endif
-diff --git a/net/mac80211/fils_aead.h b/net/mac80211/fils_aead.h
-index fbc65232f0b3..482bc5fcdd18 100644
---- a/net/mac80211/fils_aead.h
-+++ b/net/mac80211/fils_aead.h
-@@ -10,10 +10,27 @@
- #ifndef FILS_AEAD_H
- #define FILS_AEAD_H
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
- int fils_encrypt_assoc_req(struct sk_buff *skb,
- struct ieee80211_mgd_assoc_data *assoc_data);
- int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
- u8 *frame, size_t *frame_len,
- struct ieee80211_mgd_assoc_data *assoc_data);
-+#else
-+static inline
-+int fils_encrypt_assoc_req(struct sk_buff *skb,
-+ struct ieee80211_mgd_assoc_data *assoc_data)
-+{
-+ return -EOPNOTSUPP;
-+}
-+
-+static inline
-+int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
-+ u8 *frame, size_t *frame_len,
-+ struct ieee80211_mgd_assoc_data *assoc_data)
-+{
-+ return -EOPNOTSUPP;
-+}
-+#endif
-
- #endif /* FILS_AEAD_H */
-diff --git a/net/mac80211/main.c b/net/mac80211/main.c
-index a6ecbbf0f47f..afc1517e9729 100644
---- a/net/mac80211/main.c
-+++ b/net/mac80211/main.c
-@@ -553,7 +553,9 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
- NL80211_FEATURE_MAC_ON_CREATE |
- NL80211_FEATURE_USERSPACE_MPM |
- NL80211_FEATURE_FULL_AP_CLIENT_STATE;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_STA);
-+#endif
-
- if (!ops->hw_scan)
- wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
+++ /dev/null
---- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
-+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
-@@ -637,7 +637,11 @@ send:
- }
-
- static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
-+ unsigned long *temperature)
-+#else
- int *temperature)
-+#endif
- {
- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
- int ret;
-@@ -662,7 +666,11 @@ out:
- }
-
- static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
-+ int trip, unsigned long *temp)
-+#else
- int trip, int *temp)
-+#endif
- {
- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
-
-@@ -685,8 +693,13 @@ static int iwl_mvm_tzone_get_trip_type(s
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
-+ int trip, unsigned long temp)
-+#else
- int trip, int temp)
-+#endif
- {
- struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
- struct iwl_mvm_thermal_device *tzone;
-@@ -739,12 +752,15 @@ out:
- mutex_unlock(&mvm->mutex);
- return ret;
- }
-+#endif /* >= 3.6 */
-
- static struct thermal_zone_device_ops tzone_ops = {
- .get_temp = iwl_mvm_tzone_get_temp,
- .get_trip_temp = iwl_mvm_tzone_get_trip_temp,
- .get_trip_type = iwl_mvm_tzone_get_trip_type,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
-+#endif
- };
-
- /* make all trips writable */
+++ /dev/null
---- a/net/wireless/util.c
-+++ b/net/wireless/util.c
-@@ -746,7 +746,11 @@ void ieee80211_amsdu_to_8023s(struct sk_
- u8 *payload;
- int offset = 0, remaining, err;
- struct ethhdr eth;
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
-+ bool reuse_frag = 0;
-+#else
- bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb);
-+#endif
- bool reuse_skb = false;
- bool last = false;
-
+++ /dev/null
---- a/drivers/net/ethernet/intel/igb/igb_main.c
-+++ b/drivers/net/ethernet/intel/igb/igb_main.c
-@@ -2078,7 +2078,11 @@ static int igb_set_features(struct net_d
-
- static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+ const unsigned char *addr,
-+#else
- const unsigned char *addr, u16 vid,
-+#endif
- u16 flags)
- {
- /* guarantee we can provide a unique filter for the unicast address */
+++ /dev/null
-@initialize:python@
-@@
-
-first_ops = 0
-
-@r@
-identifier OPS;
-position p;
-@@
-
-struct net_device_ops OPS@p = { ... };
-
-@script:python depends on r@
-@@
-
-first_ops = 0
-
-@script:python@
-p << r.p;
-@@
-
-ln = int(p[0].line)
-if first_ops == 0 or ln < first_ops:
- first_ops = ln
-
-@script:python@
-p << r.p;
-@@
-
-ln = int(p[0].line)
-if not(first_ops == ln):
- cocci.include_match(False)
-
-@r1 exists@
-expression ndevexp, e1, e2;
-identifier func;
-@@
-func(...) {
- <+...
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
- ndevexp->min_mtu = e1;
- ndevexp->max_mtu = e2;
-+#endif
- ...+>
-}
-
-@r2@
-expression r1.e1,r1.e2;
-identifier r.OPS;
-@@
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
-+ static int __change_mtu(struct net_device *ndev, int new_mtu)
-+ {
-+ if (new_mtu < e1 || new_mtu > e2)
-+ return -EINVAL;
-+ ndev->mtu = new_mtu;
-+ return 0;
-+ }
-+#endif
-+
-struct net_device_ops OPS = {
- ...
-};
-
-@depends on r2@
-identifier OPS;
-@@
-
-struct net_device_ops OPS = {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
-+ .ndo_change_mtu = __change_mtu,
-+#endif
- ...
-};
-
+++ /dev/null
-@@
-expression SKB;
-expression A, V;
-@@
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
-SKB->wifi_acked_valid = V;
-SKB->wifi_acked = A;
-+#endif
--- /dev/null
+--- a/compat/crypto-ccm.c
++++ b/compat/crypto-ccm.c
+@@ -13,13 +13,44 @@
+ #include <crypto/internal/aead.h>
+ #include <crypto/internal/skcipher.h>
+ #include <crypto/scatterwalk.h>
++#include <crypto/algapi.h>
+ #include <linux/err.h>
+ #include <linux/init.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/slab.h>
++#include <linux/version.h>
+
+-#include "internal.h"
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
++/* consider properly backporting this? */
++static int crypto_memneq(const void *a, const void *b, size_t size)
++{
++ unsigned long neq = 0;
++
++#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
++ while (size >= sizeof(unsigned long)) {
++ neq |= *(unsigned long *)a ^ *(unsigned long *)b;
++ /* OPTIMIZER_HIDE_VAR(neq); */
++ barrier();
++ a += sizeof(unsigned long);
++ b += sizeof(unsigned long);
++ size -= sizeof(unsigned long);
++ }
++#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
++ while (size > 0) {
++ neq |= *(unsigned char *)a ^ *(unsigned char *)b;
++ /* OPTIMIZER_HIDE_VAR(neq); */
++ barrier();
++ a += 1;
++ b += 1;
++ size -= 1;
++ }
++ return neq != 0UL ? 1 : 0;
++}
++#endif
++
++/* from internal.h */
++struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
+
+ struct ccm_instance_ctx {
+ struct crypto_skcipher_spawn ctr;
+@@ -897,7 +928,7 @@ static struct crypto_template crypto_rfc
+ .module = THIS_MODULE,
+ };
+
+-static int __init crypto_ccm_module_init(void)
++int __init crypto_ccm_module_init(void)
+ {
+ int err;
+
+@@ -923,18 +954,9 @@ out_undo_base:
+ goto out;
+ }
+
+-static void __exit crypto_ccm_module_exit(void)
++void __exit crypto_ccm_module_exit(void)
+ {
+ crypto_unregister_template(&crypto_rfc4309_tmpl);
+ crypto_unregister_template(&crypto_ccm_tmpl);
+ crypto_unregister_template(&crypto_ccm_base_tmpl);
+ }
+-
+-module_init(crypto_ccm_module_init);
+-module_exit(crypto_ccm_module_exit);
+-
+-MODULE_LICENSE("GPL");
+-MODULE_DESCRIPTION("Counter with CBC MAC");
+-MODULE_ALIAS_CRYPTO("ccm_base");
+-MODULE_ALIAS_CRYPTO("rfc4309");
+-MODULE_ALIAS_CRYPTO("ccm");
--- /dev/null
+--- a/compat/crypto-skcipher.c
++++ b/compat/crypto-skcipher.c
+@@ -18,7 +18,28 @@
+ #include <linux/bug.h>
+ #include <linux/module.h>
+
+-#include "internal.h"
++struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
++ u32 mask);
++
++void *crypto_alloc_tfm(const char *alg_name,
++ const struct crypto_type *frontend, u32 type, u32 mask);
++
++struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
++
++static inline void *crypto_skcipher_ctx(struct crypto_skcipher *tfm)
++{
++ return crypto_tfm_ctx(&tfm->base);
++}
++
++static inline void *skcipher_request_ctx(struct skcipher_request *req)
++{
++ return req->__ctx;
++}
++
++static inline u32 skcipher_request_flags(struct skcipher_request *req)
++{
++ return req->base.flags;
++}
+
+ static unsigned int crypto_skcipher_extsize(struct crypto_alg *alg)
+ {
--- /dev/null
+--- a/compat/drivers-base-devcoredump.c
++++ b/compat/drivers-base-devcoredump.c
+@@ -30,6 +30,7 @@
+ #include <linux/slab.h>
+ #include <linux/fs.h>
+ #include <linux/workqueue.h>
++#include "backports.h"
+
+ static struct class devcd_class;
+
+@@ -39,6 +40,10 @@ static bool devcd_disabled;
+ /* if data isn't read by userspace after 5 minutes then delete it */
+ #define DEVCD_TIMEOUT (HZ * 60 * 5)
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++static struct bin_attribute devcd_attr_data;
++#endif
++
+ struct devcd_entry {
+ struct device devcd_dev;
+ const void *data;
+@@ -68,8 +73,7 @@ static void devcd_dev_release(struct dev
+ * a struct device to know when it goes away?
+ */
+ if (devcd->failing_dev->kobj.sd)
+- sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj,
+- "devcoredump");
++ sysfs_remove_link(&devcd->failing_dev->kobj, "devcoredump");
+
+ put_device(devcd->failing_dev);
+ kfree(devcd);
+@@ -81,6 +85,9 @@ static void devcd_del(struct work_struct
+
+ devcd = container_of(wk, struct devcd_entry, del_wk.work);
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++ device_remove_bin_file(&devcd->devcd_dev, &devcd_attr_data);
++#endif
+ device_del(&devcd->devcd_dev);
+ put_device(&devcd->devcd_dev);
+ }
+@@ -114,6 +121,7 @@ static struct bin_attribute devcd_attr_d
+ .write = devcd_data_write,
+ };
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ static struct bin_attribute *devcd_dev_bin_attrs[] = {
+ &devcd_attr_data, NULL,
+ };
+@@ -125,6 +133,7 @@ static const struct attribute_group devc
+ static const struct attribute_group *devcd_dev_groups[] = {
+ &devcd_dev_group, NULL,
+ };
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) */
+
+ static int devcd_free(struct device *dev, void *data)
+ {
+@@ -169,7 +178,9 @@ static struct class devcd_class = {
+ .name = "devcoredump",
+ .owner = THIS_MODULE,
+ .dev_release = devcd_dev_release,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ .dev_groups = devcd_dev_groups,
++#endif
+ .class_groups = devcd_class_groups,
+ };
+
+@@ -270,6 +281,11 @@ void dev_coredumpm(struct device *dev, s
+ if (device_add(&devcd->devcd_dev))
+ goto put_device;
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++ if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
++ goto put_device;
++#endif
++
+ if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
+ "failing_device"))
+ /* nothing - symlink will be missing */;
+@@ -291,15 +307,13 @@ void dev_coredumpm(struct device *dev, s
+ }
+ EXPORT_SYMBOL_GPL(dev_coredumpm);
+
+-static int __init devcoredump_init(void)
++int __init devcoredump_init(void)
+ {
+ return class_register(&devcd_class);
+ }
+-__initcall(devcoredump_init);
+
+-static void __exit devcoredump_exit(void)
++void __exit devcoredump_exit(void)
+ {
+ class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
+ class_unregister(&devcd_class);
+ }
+-__exitcall(devcoredump_exit);
+--- a/include/linux/backport-devcoredump.h
++++ b/include/linux/backport-devcoredump.h
+@@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(struct scatterlist *tab
+ }
+
+
+-#ifdef CONFIG_DEV_COREDUMP
++#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP
+ void dev_coredumpv(struct device *dev, void *data, size_t datalen,
+ gfp_t gfp);
+
+@@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct device *dev, struct
+ {
+ _devcd_free_sgtable(table);
+ }
+-#endif /* CONFIG_DEV_COREDUMP */
++#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */
+
+ #endif /* __DEVCOREDUMP_H */
+--- a/include/linux/devcoredump.h
++++ b/include/linux/devcoredump.h
+@@ -1,6 +1,7 @@
+ /* Automatically created during backport process */
+ #ifndef CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP
+ #include_next <linux/devcoredump.h>
++#include <linux/bp-devcoredump.h>
+ #else
+ #undef dev_coredumpv
+ #define dev_coredumpv LINUX_BACKPORT(dev_coredumpv)
--- /dev/null
+--- a/compat/net-core-flow_dissector.c
++++ b/compat/net-core-flow_dissector.c
+@@ -177,229 +177,10 @@ ipv6:
+
+ flow->ip_proto = ip_proto;
+ flow->ports = skb_flow_get_ports(skb, nhoff, ip_proto);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
+ flow->thoff = (u16) nhoff;
++#endif
+
+ return true;
+ }
+ EXPORT_SYMBOL(skb_flow_dissect);
+-
+-static u32 hashrnd __read_mostly;
+-static __always_inline void __flow_hash_secret_init(void)
+-{
+- net_get_random_once(&hashrnd, sizeof(hashrnd));
+-}
+-
+-static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
+-{
+- __flow_hash_secret_init();
+- return jhash_3words(a, b, c, hashrnd);
+-}
+-
+-static __always_inline u32 __flow_hash_1word(u32 a)
+-{
+- __flow_hash_secret_init();
+- return jhash_1word(a, hashrnd);
+-}
+-
+-/*
+- * __skb_get_hash: calculate a flow hash based on src/dst addresses
+- * and src/dst port numbers. Sets hash in skb to non-zero hash value
+- * on success, zero indicates no valid hash. Also, sets l4_hash in skb
+- * if hash is a canonical 4-tuple hash over transport ports.
+- */
+-void __skb_get_hash(struct sk_buff *skb)
+-{
+- struct flow_keys keys;
+- u32 hash;
+-
+- if (!skb_flow_dissect(skb, &keys))
+- return;
+-
+- if (keys.ports)
+- skb->l4_hash = 1;
+-
+- /* get a consistent hash (same value on both flow directions) */
+- if (((__force u32)keys.dst < (__force u32)keys.src) ||
+- (((__force u32)keys.dst == (__force u32)keys.src) &&
+- ((__force u16)keys.port16[1] < (__force u16)keys.port16[0]))) {
+- swap(keys.dst, keys.src);
+- swap(keys.port16[0], keys.port16[1]);
+- }
+-
+- hash = __flow_hash_3words((__force u32)keys.dst,
+- (__force u32)keys.src,
+- (__force u32)keys.ports);
+- if (!hash)
+- hash = 1;
+-
+- skb->hash = hash;
+-}
+-EXPORT_SYMBOL(__skb_get_hash);
+-
+-/*
+- * Returns a Tx hash based on the given packet descriptor a Tx queues' number
+- * to be used as a distribution range.
+- */
+-u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
+- unsigned int num_tx_queues)
+-{
+- u32 hash;
+- u16 qoffset = 0;
+- u16 qcount = num_tx_queues;
+-
+- if (skb_rx_queue_recorded(skb)) {
+- hash = skb_get_rx_queue(skb);
+- while (unlikely(hash >= num_tx_queues))
+- hash -= num_tx_queues;
+- return hash;
+- }
+-
+- if (dev->num_tc) {
+- u8 tc = netdev_get_prio_tc_map(dev, skb->priority);
+- qoffset = dev->tc_to_txq[tc].offset;
+- qcount = dev->tc_to_txq[tc].count;
+- }
+-
+- if (skb->sk && skb->sk->sk_hash)
+- hash = skb->sk->sk_hash;
+- else
+- hash = (__force u16) skb->protocol;
+- hash = __flow_hash_1word(hash);
+-
+- return (u16) (((u64) hash * qcount) >> 32) + qoffset;
+-}
+-EXPORT_SYMBOL(__skb_tx_hash);
+-
+-/* __skb_get_poff() returns the offset to the payload as far as it could
+- * be dissected. The main user is currently BPF, so that we can dynamically
+- * truncate packets without needing to push actual payload to the user
+- * space and can analyze headers only, instead.
+- */
+-u32 __skb_get_poff(const struct sk_buff *skb)
+-{
+- struct flow_keys keys;
+- u32 poff = 0;
+-
+- if (!skb_flow_dissect(skb, &keys))
+- return 0;
+-
+- poff += keys.thoff;
+- switch (keys.ip_proto) {
+- case IPPROTO_TCP: {
+- const struct tcphdr *tcph;
+- struct tcphdr _tcph;
+-
+- tcph = skb_header_pointer(skb, poff, sizeof(_tcph), &_tcph);
+- if (!tcph)
+- return poff;
+-
+- poff += max_t(u32, sizeof(struct tcphdr), tcph->doff * 4);
+- break;
+- }
+- case IPPROTO_UDP:
+- case IPPROTO_UDPLITE:
+- poff += sizeof(struct udphdr);
+- break;
+- /* For the rest, we do not really care about header
+- * extensions at this point for now.
+- */
+- case IPPROTO_ICMP:
+- poff += sizeof(struct icmphdr);
+- break;
+- case IPPROTO_ICMPV6:
+- poff += sizeof(struct icmp6hdr);
+- break;
+- case IPPROTO_IGMP:
+- poff += sizeof(struct igmphdr);
+- break;
+- case IPPROTO_DCCP:
+- poff += sizeof(struct dccp_hdr);
+- break;
+- case IPPROTO_SCTP:
+- poff += sizeof(struct sctphdr);
+- break;
+- }
+-
+- return poff;
+-}
+-
+-static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
+-{
+-#ifdef CONFIG_XPS
+- struct xps_dev_maps *dev_maps;
+- struct xps_map *map;
+- int queue_index = -1;
+-
+- rcu_read_lock();
+- dev_maps = rcu_dereference(dev->xps_maps);
+- if (dev_maps) {
+- map = rcu_dereference(
+- dev_maps->cpu_map[raw_smp_processor_id()]);
+- if (map) {
+- if (map->len == 1)
+- queue_index = map->queues[0];
+- else {
+- u32 hash;
+- if (skb->sk && skb->sk->sk_hash)
+- hash = skb->sk->sk_hash;
+- else
+- hash = (__force u16) skb->protocol ^
+- skb->hash;
+- hash = __flow_hash_1word(hash);
+- queue_index = map->queues[
+- ((u64)hash * map->len) >> 32];
+- }
+- if (unlikely(queue_index >= dev->real_num_tx_queues))
+- queue_index = -1;
+- }
+- }
+- rcu_read_unlock();
+-
+- return queue_index;
+-#else
+- return -1;
+-#endif
+-}
+-
+-static u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
+-{
+- struct sock *sk = skb->sk;
+- int queue_index = sk_tx_queue_get(sk);
+-
+- if (queue_index < 0 || skb->ooo_okay ||
+- queue_index >= dev->real_num_tx_queues) {
+- int new_index = get_xps_queue(dev, skb);
+- if (new_index < 0)
+- new_index = skb_tx_hash(dev, skb);
+-
+- if (queue_index != new_index && sk &&
+- rcu_access_pointer(sk->sk_dst_cache))
+- sk_tx_queue_set(sk, new_index);
+-
+- queue_index = new_index;
+- }
+-
+- return queue_index;
+-}
+-
+-struct netdev_queue *netdev_pick_tx(struct net_device *dev,
+- struct sk_buff *skb,
+- void *accel_priv)
+-{
+- int queue_index = 0;
+-
+- if (dev->real_num_tx_queues != 1) {
+- const struct net_device_ops *ops = dev->netdev_ops;
+- if (ops->ndo_select_queue)
+- queue_index = ops->ndo_select_queue(dev, skb, accel_priv,
+- __netdev_pick_tx);
+- else
+- queue_index = __netdev_pick_tx(dev, skb);
+-
+- if (!accel_priv)
+- queue_index = netdev_cap_txqueue(dev, queue_index);
+- }
+-
+- skb_set_queue_mapping(skb, queue_index);
+- return netdev_get_tx_queue(dev, queue_index);
+-}