summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2019-02-21 14:48:31 +0100
committerDominik Sliwa <dominik.sliwa@toradex.com>2019-02-22 15:26:14 +0100
commit515a1fa55cda2b1d952872e1786857481bd54fcc (patch)
tree4c66dd52c58f3d1da423a1ed7f92c4f720e24685
parentc956caceefd8e859c8b783dd13dad197dc1f7907 (diff)
backports: support 3.1 and 3.10 tegra kernels
Changes specific to vendor kernels Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
-rw-r--r--backport/backport-include/linux/export.h4
-rw-r--r--backport/backport-include/linux/hrtimer.h10
-rw-r--r--backport/backport-include/linux/kernel.h2
-rw-r--r--backport/backport-include/linux/netdevice.h2
-rw-r--r--backport/backport-include/linux/of_device.h2
-rw-r--r--backport/backport-include/linux/pci.h5
-rw-r--r--backport/backport-include/linux/random.h4
-rw-r--r--backport/backport-include/linux/suspend.h14
-rw-r--r--backport/backport-include/linux/thermal.h34
-rw-r--r--backport/backport-include/linux/timekeeping.h5
-rw-r--r--backport/backport-include/trace/ftrace.h3
-rw-r--r--backport/compat/backport-3.17.c18
-rw-r--r--backport/compat/backport-4.12.c2
-rw-r--r--backport/compat/compat-3.5.c4
-rw-r--r--backport/compat/compat-3.6.c2
-rw-r--r--backport/compat/compat-3.7.c3
-rw-r--r--backport/compat/compat-3.8.c3
-rw-r--r--dependencies22
-rw-r--r--patches/0082-pci_error_handlers.cocci2
-rw-r--r--patches/0094-backport-old-tegra-compile.patch413
-rw-r--r--patches/0095-backport-old-tegra-compile.patch279
-rw-r--r--patches/verify.patch5
22 files changed, 809 insertions, 29 deletions
diff --git a/backport/backport-include/linux/export.h b/backport/backport-include/linux/export.h
index 6f6cb6a9..a3c7799a 100644
--- a/backport/backport-include/linux/export.h
+++ b/backport/backport-include/linux/export.h
@@ -3,7 +3,7 @@
#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,2,0)
+#if LINUX_VERSION_IS_GEQ(3,1,0)
#include_next <linux/export.h>
#else
#ifndef pr_fmt
@@ -14,6 +14,6 @@
#undef pr_fmt
#undef backport_undef_pr_fmt
#endif
-#endif /* LINUX_VERSION_IS_GEQ(3,2,0) */
+#endif /* LINUX_VERSION_IS_GEQ(3,1,0) */
#endif /* _COMPAT_LINUX_EXPORT_H */
diff --git a/backport/backport-include/linux/hrtimer.h b/backport/backport-include/linux/hrtimer.h
new file mode 100644
index 00000000..2c186dd1
--- /dev/null
+++ b/backport/backport-include/linux/hrtimer.h
@@ -0,0 +1,10 @@
+#ifndef __BACKPORT_LINUX_HRTIMER_H
+#define __BACKPORT_LINUX_HRTIMER_H
+#include_next <linux/hrtimer.h>
+
+#if LINUX_VERSION_IS_LESS(3,17,0)
+u64 bp_ktime_divns(const ktime_t kt, s64 div);
+#define ktime_divns bp_ktime_divns
+#endif /* < 3.17 */
+
+#endif /* __BACKPORT_LINUX_HRTIMER_H */
diff --git a/backport/backport-include/linux/kernel.h b/backport/backport-include/linux/kernel.h
index f5081663..332f1537 100644
--- a/backport/backport-include/linux/kernel.h
+++ b/backport/backport-include/linux/kernel.h
@@ -1,7 +1,9 @@
#ifndef __BACKPORT_KERNEL_H
#define __BACKPORT_KERNEL_H
#include_next <linux/kernel.h>
+#if LINUX_VERSION_IS_GEQ(4,5,0)
#include <linux/bug.h>
+#endif
#include <linux/version.h>
/*
* some older kernels don't have this and thus don't
diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
index c3e91a0c..4b1fddff 100644
--- a/backport/backport-include/linux/netdevice.h
+++ b/backport/backport-include/linux/netdevice.h
@@ -344,7 +344,7 @@ static inline void netif_trans_update(struct net_device *dev)
(_dev)->needs_free_netdev = true;
#endif
-#if LINUX_VERSION_IS_LESS(4,15,0)
+#if LINUX_VERSION_IN_RANGE(3,10,0, 4,14,0)
static inline int _bp_netdev_upper_dev_link(struct net_device *dev,
struct net_device *upper_dev)
{
diff --git a/backport/backport-include/linux/of_device.h b/backport/backport-include/linux/of_device.h
index 2178a338..827c7fb1 100644
--- a/backport/backport-include/linux/of_device.h
+++ b/backport/backport-include/linux/of_device.h
@@ -24,8 +24,10 @@ static inline int backport_of_dma_configure(struct device *dev,
#endif /* < 4.18 */
#if LINUX_VERSION_IS_LESS(4,12,0)
+#if LINUX_VERSION_IS_GEQ(4,4,0)
ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len);
#define of_device_modalias bp_of_device_modalias
+#endif /* > 4.4.0 */
#endif /* < 4.12 */
#endif /* __BP_OF_DEVICE_H */
diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h
index 3a141bf3..42b3dc53 100644
--- a/backport/backport-include/linux/pci.h
+++ b/backport/backport-include/linux/pci.h
@@ -17,6 +17,9 @@
pci_unregister_driver)
#endif
+#if LINUX_VERSION_IS_LESS(3,4,0)
+void pci_stop_and_remove_bus_device(struct pci_dev *dev);
+#endif
#if LINUX_VERSION_IS_LESS(3,7,0)
#define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
@@ -60,6 +63,8 @@ static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
{
return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
}
+
+int pci_pcie_type(struct pci_dev *dev);
#endif
#ifndef PCI_DEVICE_SUB
diff --git a/backport/backport-include/linux/random.h b/backport/backport-include/linux/random.h
index 7d817d8b..fa016cce 100644
--- a/backport/backport-include/linux/random.h
+++ b/backport/backport-include/linux/random.h
@@ -12,7 +12,9 @@ static inline void add_device_randomness(const void *buf, unsigned int size)
}
#endif
-#if LINUX_VERSION_IS_LESS(3,8,0)
+/* #if LINUX_VERSION_IS_LESS(3,8,0) */
+/* already backported in our kernels */
+#if 0
/* backports 496f2f9 */
#define prandom_seed(_seed) srandom32(_seed)
#define prandom_u32() random32()
diff --git a/backport/backport-include/linux/suspend.h b/backport/backport-include/linux/suspend.h
new file mode 100644
index 00000000..60307182
--- /dev/null
+++ b/backport/backport-include/linux/suspend.h
@@ -0,0 +1,14 @@
+#ifndef __BP_LINUX_SUSPEND_H
+#define __BP_LINUX_SUSPEND_H
+#include_next <linux/suspend.h>
+
+#if LINUX_VERSION_IS_LESS(3,18,0)
+static inline void pm_system_wakeup(void)
+{
+#if LINUX_VERSION_IS_GEQ(3,10,0)
+ freeze_wake();
+#endif
+}
+#endif
+
+#endif /* __BP_LINUX_SUSPEND_H */
diff --git a/backport/backport-include/linux/thermal.h b/backport/backport-include/linux/thermal.h
index 8874e196..ad61a90a 100644
--- a/backport/backport-include/linux/thermal.h
+++ b/backport/backport-include/linux/thermal.h
@@ -6,6 +6,40 @@
#ifdef CONFIG_THERMAL
#if LINUX_VERSION_IS_LESS(3,8,0)
#include <linux/errno.h>
+#include <linux/err.h>
+
+enum thermal_trend {
+ THERMAL_TREND_STABLE, /* temperature is stable */
+ THERMAL_TREND_RAISING, /* temperature is raising */
+ THERMAL_TREND_DROPPING, /* temperature is dropping */
+ THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
+ THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
+};
+
+struct backport_thermal_zone_device_ops {
+ int (*bind) (struct thermal_zone_device *,
+ struct thermal_cooling_device *);
+ int (*unbind) (struct thermal_zone_device *,
+ struct thermal_cooling_device *);
+ int (*get_temp) (struct thermal_zone_device *, int *);
+ int (*get_mode) (struct thermal_zone_device *,
+ enum thermal_device_mode *);
+ int (*set_mode) (struct thermal_zone_device *,
+ enum thermal_device_mode);
+ int (*get_trip_type) (struct thermal_zone_device *, int,
+ enum thermal_trip_type *);
+ int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
+ int (*set_trip_temp) (struct thermal_zone_device *, int, int);
+ int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
+ int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
+ int (*get_crit_temp) (struct thermal_zone_device *, int *);
+ int (*set_emul_temp) (struct thermal_zone_device *, int);
+ int (*get_trend) (struct thermal_zone_device *, int,
+ enum thermal_trend *);
+ int (*notify) (struct thermal_zone_device *, int,
+ enum thermal_trip_type);
+};
+#define thermal_zone_device_ops LINUX_BACKPORT(thermal_zone_device_ops)
struct thermal_bind_params {
struct thermal_cooling_device *cdev;
diff --git a/backport/backport-include/linux/timekeeping.h b/backport/backport-include/linux/timekeeping.h
index 71871531..a0d65fba 100644
--- a/backport/backport-include/linux/timekeeping.h
+++ b/backport/backport-include/linux/timekeeping.h
@@ -8,6 +8,11 @@
#endif
#if LINUX_VERSION_IS_LESS(3,17,0)
+#if BITS_PER_LONG < 64
+extern u64 ktime_divns(const ktime_t kt, s64 div);
+#else /* BITS_PER_LONG < 64 */
+# define ktime_divns(kt, div) (u64)((kt).tv64 / (div))
+#endif
#define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
extern ktime_t ktime_get(void);
#define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
diff --git a/backport/backport-include/trace/ftrace.h b/backport/backport-include/trace/ftrace.h
index 2daedd55..756ded36 100644
--- a/backport/backport-include/trace/ftrace.h
+++ b/backport/backport-include/trace/ftrace.h
@@ -9,5 +9,6 @@
#undef __get_dynamic_array_len
#define __get_dynamic_array_len(field) \
((__entry->__data_loc_##field >> 16) & 0xffff)
-
+#if LINUX_VERSION_IS_GEQ(3,2,0)
#include_next <trace/ftrace.h>
+#endif
diff --git a/backport/compat/backport-3.17.c b/backport/compat/backport-3.17.c
index bf6027cb..5961e3bc 100644
--- a/backport/compat/backport-3.17.c
+++ b/backport/compat/backport-3.17.c
@@ -146,6 +146,24 @@ char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
}
EXPORT_SYMBOL_GPL(devm_kasprintf);
+u64 bp_ktime_divns(const ktime_t kt, s64 div)
+{
+ u64 dclc;
+ int sft = 0;
+
+ dclc = ktime_to_ns(kt);
+ /* Make sure the divisor is less than 2^32: */
+ while (div >> 32) {
+ sft++;
+ div >>= 1;
+ }
+ dclc >>= sft;
+ do_div(dclc, (unsigned long) div);
+
+ return dclc;
+}
+EXPORT_SYMBOL_GPL(bp_ktime_divns);
+
#define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
int param_set_##name(const char *val, const struct kernel_param *kp) \
{ \
diff --git a/backport/compat/backport-4.12.c b/backport/compat/backport-4.12.c
index 413ae7f1..4f9de261 100644
--- a/backport/compat/backport-4.12.c
+++ b/backport/compat/backport-4.12.c
@@ -3,6 +3,7 @@
#endif
#ifdef CONFIG_OF
+#if LINUX_VERSION_IS_GEQ(4,4,0)
/**
* of_device_modalias - Fill buffer with newline terminated modalias string
*/
@@ -20,3 +21,4 @@ ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len)
}
EXPORT_SYMBOL_GPL(bp_of_device_modalias);
#endif
+#endif
diff --git a/backport/compat/compat-3.5.c b/backport/compat/compat-3.5.c
index de312283..721ec0e3 100644
--- a/backport/compat/compat-3.5.c
+++ b/backport/compat/compat-3.5.c
@@ -67,7 +67,9 @@ EXPORT_SYMBOL_GPL(overflowuid);
EXPORT_SYMBOL_GPL(overflowgid);
#endif
-#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
+/* #if IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
+/* backported to all of our kernels */
+#if 0
int ptp_clock_index(struct ptp_clock *ptp)
{
return ptp->index;
diff --git a/backport/compat/compat-3.6.c b/backport/compat/compat-3.6.c
index ef364852..9e593f5c 100644
--- a/backport/compat/compat-3.6.c
+++ b/backport/compat/compat-3.6.c
@@ -14,6 +14,7 @@
/* whoopsie ! */
#ifndef CONFIG_COMMON_CLK
+#ifndef CONFIG_ARCH_TEGRA
int clk_enable(struct clk *clk)
{
return 0;
@@ -25,3 +26,4 @@ void clk_disable(struct clk *clk)
}
EXPORT_SYMBOL_GPL(clk_disable);
#endif
+#endif
diff --git a/backport/compat/compat-3.7.c b/backport/compat/compat-3.7.c
index a70709c9..528d7ec9 100644
--- a/backport/compat/compat-3.7.c
+++ b/backport/compat/compat-3.7.c
@@ -49,10 +49,11 @@ static inline u16 pcie_flags_reg(struct pci_dev *dev)
}
#define pci_pcie_type LINUX_BACKPORT(pci_pcie_type)
-static inline int pci_pcie_type(struct pci_dev *dev)
+int pci_pcie_type(struct pci_dev *dev)
{
return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
}
+EXPORT_SYMBOL_GPL(pci_pcie_type);
#define pcie_cap_version LINUX_BACKPORT(pcie_cap_version)
static inline int pcie_cap_version(struct pci_dev *dev)
diff --git a/backport/compat/compat-3.8.c b/backport/compat/compat-3.8.c
index ff9cd493..21686cc3 100644
--- a/backport/compat/compat-3.8.c
+++ b/backport/compat/compat-3.8.c
@@ -356,6 +356,8 @@ bool hid_ignore(struct hid_device *hdev)
}
EXPORT_SYMBOL_GPL(hid_ignore);
+/* backported to our kernel */
+#if 0
/**
* prandom_bytes - get the requested number of pseudo-random bytes
* @buf: where to copy the pseudo-random bytes to
@@ -386,6 +388,7 @@ void prandom_bytes(void *buf, int bytes)
}
}
EXPORT_SYMBOL_GPL(prandom_bytes);
+#endif
#ifdef CONFIG_OF
/**
diff --git a/dependencies b/dependencies
index 7df54bdf..aea32119 100644
--- a/dependencies
+++ b/dependencies
@@ -23,16 +23,9 @@ ATMEL 4.18
AIRO 3.9
AIRO_CS 3.9
-# pci_error_handlers->reset_notify is missing
-MWIFIEX_PCIE 3.16
-
# needs pcie_get_mps()
QTNFMAC_PCIE 3.13
-# needs pm_system_wakeup() which can't reall be
-# backported properly
-MWIFIEX 3.18
-
BCMA_DRIVER_MIPS 3.3
SSB_DRIVER_MIPS 3.3
# needs GPIO stuff we didn't backport
@@ -64,9 +57,6 @@ ATH9K_HWRNG 3.17
# mpls_features was added with kernel 3.11
IGB 3.11
-# This driver needs mmc_hw_reset() which was added in kernel version 3.2
-MWIFIEX_SDIO 3.2
-
# DRIVER_ATTR_RW is not compiling in kernel 3.10
IPW2100 3.11
IPW2200 3.11
@@ -81,13 +71,5 @@ RSI_SDIO 3.13
# For Coexsitence the BT driver has to export rsi_bt_ops
RSI_COEX 4.17
-# depends on devm_led_classdev_register() and struct page_frag_cache
-# (can't use MT76_CORE for this as it's selected)
-MT76x0U 4.2
-MT76x0E 4.2
-MT76x2E 4.2
-MT76x2U 4.2
-
-# select_queue_fallback_t is missing
-RTL8723BS 3.14
-R8188EU 3.14
+SERIAL_DEV_BUS 4.2
+WLAN_VENDOR_MEDIATEK 3.3
diff --git a/patches/0082-pci_error_handlers.cocci b/patches/0082-pci_error_handlers.cocci
index 9b5573d4..2a1fc388 100644
--- a/patches/0082-pci_error_handlers.cocci
+++ b/patches/0082-pci_error_handlers.cocci
@@ -9,7 +9,7 @@ struct pci_error_handlers OPS@p = {
+#if LINUX_VERSION_IS_GEQ(4,13,0)
.reset_prepare = pcie_reset_prepare_fn,
.reset_done = pcie_reset_done_fn,
-+#else
++#elif LINUX_VERSION_IS_GEQ(3,16,0)
+ .reset_notify = pcie_reset_notify_fn,
+#endif
};
diff --git a/patches/0094-backport-old-tegra-compile.patch b/patches/0094-backport-old-tegra-compile.patch
new file mode 100644
index 00000000..abd418a5
--- /dev/null
+++ b/patches/0094-backport-old-tegra-compile.patch
@@ -0,0 +1,413 @@
+From 6e3d45d51a72d29e46fc6ffc0fa9722ccd6d7c16 Mon Sep 17 00:00:00 2001
+From: Dominik Sliwa <dominik.sliwa@toradex.com>
+Date: Fri, 22 Feb 2019 09:22:28 +0100
+Subject: [PATCH] backport old tegra compile
+
+---
+ drivers/net/wireless/ath/ath10k/mac.c | 7 +++++++
+ drivers/net/wireless/intel/iwlwifi/fw/acpi.h | 4 ++++
+ drivers/net/wireless/marvell/mwifiex/pcie.c | 4 ++++
+ drivers/net/wireless/mediatek/mt76/dma.c | 4 ++++
+ drivers/net/wireless/mediatek/mt76/mac80211.c | 4 ++++
+ drivers/net/wireless/mediatek/mt76/mt76.h | 4 ++++
+ drivers/net/wireless/mediatek/mt76/mt76x0/dma.c | 10 ++++++++--
+ drivers/net/wireless/mediatek/mt76/mt76x0/mac.c | 5 ++++-
+ drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 7 +++++--
+ drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 4 ++++
+ drivers/net/wireless/mediatek/mt76/mt76x0/trace.h | 3 ++-
+ drivers/net/wireless/mediatek/mt76/mt76x0/tx.c | 5 ++++-
+ drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 11 ++++++++---
+ drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c | 1 +
+ drivers/net/wireless/mediatek/mt76/usb.c | 5 +++++
+ drivers/net/wireless/mediatek/mt7601u/trace.c | 2 ++
+ 16 files changed, 71 insertions(+), 11 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
+index 3ceca7a..82e3da1 100644
+--- a/drivers/net/wireless/ath/ath10k/mac.c
++++ b/drivers/net/wireless/ath/ath10k/mac.c
+@@ -8182,6 +8182,7 @@ struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id)
+ #define WRD_METHOD "WRDD"
+ #define WRDD_WIFI (0x07)
+
++#if LINUX_VERSION_IS_GEQ(3,11,0)
+ static u32 ath10k_mac_wrdd_get_mcc(struct ath10k *ar, union acpi_object *wrdd)
+ {
+ union acpi_object *mcc_pkg;
+@@ -8265,6 +8266,12 @@ static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
+ *rd |= COUNTRY_ERD_FLAG;
+ return 0;
+ }
++#else
++static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
++{
++ return -EOPNOTSUPP;
++}
++#endif
+
+ static int ath10k_mac_init_rd(struct ath10k *ar)
+ {
+diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+index 0b3b122..44d36ac 100644
+--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
++++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+@@ -114,6 +114,10 @@ u64 iwl_acpi_get_pwr_limit(struct device *dev);
+
+ #else /* CONFIG_ACPI */
+
++#if LINUX_VERSION_IS_LESS(3,11,0)
++typedef char *acpi_string; /* Null terminated ASCII string */
++#endif
++
+ static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method)
+ {
+ return ERR_PTR(-ENOENT);
+diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
+index 74e0e83..3134561 100644
+--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
+@@ -2823,10 +2823,14 @@ static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter)
+ {
+ struct pcie_service_card *card = adapter->card;
+
++#if LINUX_VERSION_IS_LESS(3,14,0)
++ pci_reset_function(card->dev);
++#else
+ /* We can't afford to wait here; remove() might be waiting on us. If we
+ * can't grab the device lock, maybe we'll get another chance later.
+ */
+ pci_try_reset_function(card->dev);
++#endif
+ }
+
+ static void mwifiex_pcie_work(struct work_struct *work)
+diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
+index c51da22..7bc3f5b 100644
+--- a/drivers/net/wireless/mediatek/mt76/dma.c
++++ b/drivers/net/wireless/mediatek/mt76/dma.c
+@@ -325,7 +325,11 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q, bool napi)
+ void *(*alloc)(unsigned int fragsz);
+
+ if (napi)
++#if LINUX_VERSION_IS_LESS(3,18,0)
++ alloc = netdev_alloc_frag;
++#else
+ alloc = napi_alloc_frag;
++#endif
+ else
+ alloc = netdev_alloc_frag;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
+index 4517caf..86c9e06 100644
+--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
++++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
+@@ -92,6 +92,9 @@ static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
+
+ static int mt76_led_init(struct mt76_dev *dev)
+ {
++#if LINUX_VERSION_IS_LESS(4,1,0)
++ return 0;
++#else
+ struct device_node *np = dev->dev->of_node;
+ struct ieee80211_hw *hw = dev->hw;
+ int led_pin;
+@@ -117,6 +120,7 @@ static int mt76_led_init(struct mt76_dev *dev)
+ }
+
+ return devm_led_classdev_register(dev->dev, &dev->led_cdev);
++#endif
+ }
+
+ static void mt76_init_stream_cap(struct mt76_dev *dev,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
+index 2eab358..e579d82 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76.h
+@@ -574,9 +574,13 @@ static inline bool mt76u_check_sg(struct mt76_dev *dev)
+ struct usb_interface *intf = to_usb_interface(dev->dev);
+ struct usb_device *udev = interface_to_usbdev(intf);
+
++#if LINUX_VERSION_IS_LESS(3,14,0)
++ return udev->bus->sg_tablesize > 0 && udev->speed == USB_SPEED_WIRELESS;
++#else
+ return (udev->bus->sg_tablesize > 0 &&
+ (udev->bus->no_sg_constraint ||
+ udev->speed == USB_SPEED_WIRELESS));
++#endif
+ }
+
+ int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c
+index e2efb43..4877f4d 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c
+@@ -104,8 +104,9 @@ static void mt76x0_rx_process_seg(struct mt76x0_dev *dev, u8 *data,
+
+ if (unlikely(FIELD_GET(MT_RXD_INFO_TYPE, fce_info)))
+ dev_err_once(dev->mt76.dev, "Error: RX path seen a non-pkt urb\n");
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_rx(&dev->mt76, rxwi, fce_info);
++#endif
+
+ skb = mt76x0_rx_skb_from_seg(dev, rxwi, data, seg_len, truesize, p);
+ if (!skb)
+@@ -154,8 +155,10 @@ mt76x0_rx_process_entry(struct mt76x0_dev *dev, struct mt76x0_dma_buf_rx *e)
+ cnt++;
+ }
+
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ if (cnt > 1)
+ trace_mt76x0_rx_dma_aggr(&dev->mt76, cnt, !!new_p);
++#endif
+
+ if (new_p) {
+ /* we have one extra ref from the allocator */
+@@ -235,7 +238,9 @@ static void mt76x0_complete_tx(struct urb *urb)
+ goto out;
+
+ skb = q->e[q->start].skb;
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_tx_dma_done(&dev->mt76, skb);
++#endif
+
+ __skb_queue_tail(&dev->tx_skb_done, skb);
+ tasklet_schedule(&dev->tx_tasklet);
+@@ -383,8 +388,9 @@ static int mt76x0_submit_rx_buf(struct mt76x0_dev *dev,
+
+ usb_fill_bulk_urb(e->urb, usb_dev, pipe, buf, MT_RX_URB_SIZE,
+ mt76x0_complete_rx, dev);
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_submit_urb(&dev->mt76, e->urb);
++#endif
+ ret = usb_submit_urb(e->urb, gfp);
+ if (ret)
+ dev_err(dev->mt76.dev, "Error: submit RX URB failed:%d\n", ret);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c
+index 91a84be..4d21651 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c
+@@ -603,8 +603,9 @@ int mt76x0_mac_wcid_set_key(struct mt76x0_dev *dev, u8 idx,
+ cipher = mt76_mac_get_key_info(key, key_data);
+ if (cipher == MT_CIPHER_NONE && key)
+ return -EINVAL;
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_set_key(&dev->mt76, idx);
++#endif
+
+ mt76_wr_copy(dev, MT_WCID_KEY(idx), key_data, sizeof(key_data));
+
+@@ -644,7 +645,9 @@ int mt76x0_mac_shared_key_setup(struct mt76x0_dev *dev, u8 vif_idx, u8 key_idx,
+ if (cipher == MT_CIPHER_NONE && key)
+ return -EINVAL;
+
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_set_shared_key(&dev->mt76, vif_idx, key_idx);
++#endif
+
+ mt76_wr_copy(dev, MT_SKEY(vif_idx, key_idx),
+ key_data, sizeof(key_data));
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c
+index 8affacb..1f563c8 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c
+@@ -55,8 +55,9 @@ static inline void trace_mt76x0_mcu_msg_send_cs(struct mt76_dev *dev,
+
+ for (i = 0; i < skb->len / 4; i++)
+ csum ^= get_unaligned_le32(skb->data + i * 4);
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_mcu_msg_send(dev, skb, csum, need_resp);
++#endif
+ }
+
+ static struct sk_buff *
+@@ -167,9 +168,11 @@ __mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb,
+
+ if (dev->mcu.resp_cmpl.done)
+ dev_err(dev->mt76.dev, "Error: MCU response pre-completed!\n");
+-
+ trace_mt76x0_mcu_msg_send_cs(&dev->mt76, skb, wait_resp);
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_submit_urb_sync(&dev->mt76, cmd_pipe, skb->len);
++#endif
++
+
+ ret = usb_bulk_msg(usb_dev, cmd_pipe, skb->data, skb->len, &sent, 500);
+ if (ret) {
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+index 14e8c57..a9727e2 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+@@ -52,7 +52,9 @@ mt76x0_rf_csr_wr(struct mt76x0_dev *dev, u32 offset, u8 value)
+ FIELD_PREP(MT_RF_CSR_CFG_REG_ID, reg) |
+ MT_RF_CSR_CFG_WR |
+ MT_RF_CSR_CFG_KICK);
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_rf_write(&dev->mt76, bank, offset, value);
++#endif
+ out:
+ mutex_unlock(&dev->reg_atomic_mutex);
+
+@@ -96,7 +98,9 @@ mt76x0_rf_csr_rr(struct mt76x0_dev *dev, u32 offset)
+ if (FIELD_GET(MT_RF_CSR_CFG_REG_ID, val) == reg &&
+ FIELD_GET(MT_RF_CSR_CFG_REG_BANK, val) == bank) {
+ ret = FIELD_GET(MT_RF_CSR_CFG_DATA, val);
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_rf_read(&dev->mt76, bank, offset, ret);
++#endif
+ }
+ out:
+ mutex_unlock(&dev->reg_atomic_mutex);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h b/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h
+index 8a752a0..3730a33 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h
+@@ -14,10 +14,10 @@
+
+ #if !defined(__MT76X0U_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+ #define __MT76X0U_TRACE_H
+-
+ #include <linux/tracepoint.h>
+ #include "mt76x0.h"
+ #include "mac.h"
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+
+ #undef TRACE_SYSTEM
+ #define TRACE_SYSTEM mt76x0
+@@ -311,3 +311,4 @@ TRACE_EVENT(mt76x0_set_shared_key,
+ #define TRACE_INCLUDE_FILE trace
+
+ #include <trace/define_trace.h>
++#endif
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
+index 751b49c..21c42cb 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
+@@ -176,8 +176,9 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
+
+ if (mt76x0_dma_enqueue_tx(dev, skb, wcid, hw_q))
+ return;
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_tx(&dev->mt76, skb, msta, txwi);
++#endif
+ }
+
+ void mt76x0_tx_stat(struct work_struct *work)
+@@ -198,7 +199,9 @@ void mt76x0_tx_stat(struct work_struct *work)
+
+ cleaned++;
+ }
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_tx_status_cleaned(&dev->mt76, cleaned);
++#endif
+
+ spin_lock_irqsave(&dev->tx_lock, flags);
+ if (cleaned)
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+index a9a7b6f..014890b 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+@@ -83,8 +83,9 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx,
+ complete_fn, context);
+ buf->urb->transfer_dma = buf->dma;
+ buf->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_submit_urb(&dev->mt76, buf->urb);
++#endif
+ ret = usb_submit_urb(buf->urb, gfp);
+ if (ret)
+ dev_err(dev->mt76.dev, "Error: submit URB dir:%d ep:%d failed:%d\n",
+@@ -113,9 +114,10 @@ int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req,
+ ret = usb_control_msg(usb_dev, pipe, req, req_type,
+ val, offset, buf, buflen,
+ MT_VEND_REQ_TOUT_MS);
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_vend_req(&dev->mt76, pipe, req, req_type, val, offset,
+ buf, buflen, ret);
+-
++#endif
+ if (ret == -ENODEV)
+ set_bit(MT76_REMOVED, &dev->mt76.state);
+ if (ret >= 0 || ret == -ENODEV)
+@@ -155,8 +157,9 @@ static u32 mt76x0_rr(struct mt76_dev *dev, u32 offset)
+ ret, offset);
+
+ mutex_unlock(&mdev->usb_ctrl_mtx);
+-
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_reg_read(dev, offset, val);
++#endif
+ return val;
+ }
+
+@@ -191,7 +194,9 @@ static void mt76x0_wr(struct mt76_dev *dev, u32 offset, u32 val)
+ put_unaligned_le32(val, mdev->data);
+ ret = mt76x0_vendor_request(mdev, MT_VEND_MULTI_WRITE, USB_DIR_OUT,
+ 0, offset, mdev->data, MT_VEND_BUF);
++#if LINUX_VERSION_IS_GEQ(3,12,0)
+ trace_mt76x0_reg_write(dev, offset, val);
++#endif
+
+ mutex_unlock(&mdev->usb_ctrl_mtx);
+ }
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c
+index 1753bcb..89a0037 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c
+@@ -17,6 +17,7 @@
+ #include <asm/unaligned.h>
+ #include "mt76x2.h"
+ #include "mt76x2_eeprom.h"
++#include <linux/module.h>
+
+ #define EE_FIELD(_name, _value) [MT_EE_##_name] = (_value) | 1
+
+diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
+index 363bea8..4bde2a3 100644
+--- a/drivers/net/wireless/mediatek/mt76/usb.c
++++ b/drivers/net/wireless/mediatek/mt76/usb.c
+@@ -14,6 +14,7 @@
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++#include <linux/module.h>
+ #include "mt76.h"
+ #include "usb_trace.h"
+ #include "dma.h"
+@@ -646,7 +647,11 @@ mt76u_tx_build_sg(struct sk_buff *skb, struct urb *urb)
+ sg_init_marker(urb->sg, nsgs);
+ urb->num_sgs = nsgs;
+
++#if LINUX_VERSION_IS_GEQ(4,1,0)
+ return skb_to_sgvec_nomark(skb, urb->sg, 0, skb->len);
++#else
++ return skb_to_sgvec(skb, urb->sg, 0, skb->len);
++#endif
+ }
+
+ static int
+diff --git a/drivers/net/wireless/mediatek/mt7601u/trace.c b/drivers/net/wireless/mediatek/mt7601u/trace.c
+index d48a407..4137d5b 100644
+--- a/drivers/net/wireless/mediatek/mt7601u/trace.c
++++ b/drivers/net/wireless/mediatek/mt7601u/trace.c
+@@ -12,6 +12,7 @@
+ * GNU General Public License for more details.
+ */
+
++#if LINUX_VERSION_IS_GEQ(3,10,0)
+ #include <linux/module.h>
+ #if LINUX_VERSION_IS_LESS(3,4,0)
+ #include <linux/interrupt.h>
+@@ -22,3 +23,4 @@
+ #include "trace.h"
+
+ #endif
++#endif
+--
+2.13.6
+
diff --git a/patches/0095-backport-old-tegra-compile.patch b/patches/0095-backport-old-tegra-compile.patch
new file mode 100644
index 00000000..31519871
--- /dev/null
+++ b/patches/0095-backport-old-tegra-compile.patch
@@ -0,0 +1,279 @@
+From c1d1a970c7ad8a79b54f18297445b32230c0b9ce Mon Sep 17 00:00:00 2001
+From: Dominik Sliwa <dominik.sliwa@toradex.com>
+Date: Fri, 22 Feb 2019 12:49:27 +0100
+Subject: [PATCH] old tegra compile
+
+---
+ backport-include/linux/atomic.h | 25 +++++++++++++++++++++++++
+ backport-include/linux/hrtimer.h | 20 ++++++++++++++++++++
+ backport-include/linux/skbuff.h | 1 +
+ backport-include/linux/string.h | 4 ++++
+ backport-include/linux/timekeeping.h | 2 ++
+ compat/backport-3.17.c | 2 ++
+ compat/backport-4.18.c | 2 ++
+ compat/backport-genetlink.c | 2 ++
+ compat/compat-3.3.c | 25 +++++++++++++++++++++++++
+ drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 4 ++++
+ net/wireless/trace.h | 17 +++++++++++++++++
+ 11 files changed, 104 insertions(+)
+
+diff --git a/backport-include/linux/atomic.h b/backport-include/linux/atomic.h
+index b4dd2e1..7baa2f5 100644
+--- a/backport-include/linux/atomic.h
++++ b/backport-include/linux/atomic.h
+@@ -51,4 +51,29 @@
+
+ #endif /* atomic_try_cmpxchg_acquire */
+
++#if LINUX_VERSION_IS_LESS(3,7,0)
++/*
++ * atomic_dec_if_positive - decrement by 1 if old value positive
++ * @v: pointer of type atomic_t
++ *
++ * The function returns the old value of *v minus 1, even if
++ * the atomic variable, v, was not decremented.
++ */
++static inline int atomic_dec_if_positive(atomic_t *v)
++{
++ int c, old, dec;
++ c = atomic_read(v);
++ for (;;) {
++ dec = c - 1;
++ if (unlikely(dec < 0))
++ break;
++ old = atomic_cmpxchg((v), c, dec);
++ if (likely(old == c))
++ break;
++ c = old;
++ }
++ return dec;
++}
++#endif
++
+ #endif /* __BP_ATOMIC_H */
+diff --git a/backport-include/linux/hrtimer.h b/backport-include/linux/hrtimer.h
+index 2c186dd..cb18567 100644
+--- a/backport-include/linux/hrtimer.h
++++ b/backport-include/linux/hrtimer.h
+@@ -3,8 +3,28 @@
+ #include_next <linux/hrtimer.h>
+
+ #if LINUX_VERSION_IS_LESS(3,17,0)
++#if LINUX_VERSION_IS_LESS(3,3,0)
++inline u64 bp_ktime_divns(const ktime_t kt, s64 div)
++{
++ u64 dclc;
++ int sft = 0;
++
++ dclc = ktime_to_ns(kt);
++ /* Make sure the divisor is less than 2^32: */
++ while (div >> 32) {
++ sft++;
++ div >>= 1;
++ }
++ dclc >>= sft;
++ do_div(dclc, (unsigned long) div);
++
++ return dclc;
++}
++#define ktime_get_boottime_seconds() bp_ktime_divns(ktime_get_boottime(), NSEC_PER_SEC)
++#else
+ u64 bp_ktime_divns(const ktime_t kt, s64 div);
+ #define ktime_divns bp_ktime_divns
++#endif
+ #endif /* < 3.17 */
+
+ #endif /* __BACKPORT_LINUX_HRTIMER_H */
+diff --git a/backport-include/linux/skbuff.h b/backport-include/linux/skbuff.h
+index 7b1fe6e..277d892 100644
+--- a/backport-include/linux/skbuff.h
++++ b/backport-include/linux/skbuff.h
+@@ -12,6 +12,7 @@
+ #endif
+
+ #if LINUX_VERSION_IS_LESS(3,3,0)
++void kfree_skb_list(struct sk_buff *segs);
+ #define __pskb_copy LINUX_BACKPORT(__pskb_copy)
+ extern struct sk_buff *__pskb_copy(struct sk_buff *skb,
+ int headroom, gfp_t gfp_mask);
+diff --git a/backport-include/linux/string.h b/backport-include/linux/string.h
+index 2bfdf74..dda80d8 100644
+--- a/backport-include/linux/string.h
++++ b/backport-include/linux/string.h
+@@ -37,4 +37,8 @@ char *strreplace(char *s, char old, char new);
+ int match_string(const char * const *array, size_t n, const char *string);
+ #endif /* LINUX_VERSION_IS_LESS(4,5,0) */
+
++#if LINUX_VERSION_IS_LESS(3,3,0)
++void *memchr_inv(const void *s, int c, size_t n);
++#endif
++
+ #endif /* __BACKPORT_LINUX_STRING_H */
+diff --git a/backport-include/linux/timekeeping.h b/backport-include/linux/timekeeping.h
+index a0d65fb..571c602 100644
+--- a/backport-include/linux/timekeeping.h
++++ b/backport-include/linux/timekeeping.h
+@@ -30,7 +30,9 @@ static inline u64 ktime_get_boot_ns(void)
+ #endif /* < 3.17 */
+
+ #if LINUX_VERSION_IS_LESS(4,18,0)
++#if LINUX_VERSION_IS_GEQ(3,4,0)
+ extern time64_t ktime_get_boottime_seconds(void);
++#endif
+ #endif /* < 4.18 */
+
+ #if LINUX_VERSION_IS_LESS(3,19,0)
+diff --git a/compat/backport-3.17.c b/compat/backport-3.17.c
+index 5961e3b..19c2eca 100644
+--- a/compat/backport-3.17.c
++++ b/compat/backport-3.17.c
+@@ -146,6 +146,7 @@ char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
+ }
+ EXPORT_SYMBOL_GPL(devm_kasprintf);
+
++#if LINUX_VERSION_IS_GEQ(3,3,0)
+ u64 bp_ktime_divns(const ktime_t kt, s64 div)
+ {
+ u64 dclc;
+@@ -163,6 +164,7 @@ u64 bp_ktime_divns(const ktime_t kt, s64 div)
+ return dclc;
+ }
+ EXPORT_SYMBOL_GPL(bp_ktime_divns);
++#endif
+
+ #define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
+ int param_set_##name(const char *val, const struct kernel_param *kp) \
+diff --git a/compat/backport-4.18.c b/compat/backport-4.18.c
+index c47fabe..a08fd7c 100644
+--- a/compat/backport-4.18.c
++++ b/compat/backport-4.18.c
+@@ -4,8 +4,10 @@
+
+ #include <linux/hrtimer.h>
+
++#if LINUX_VERSION_IS_GEQ(3,4,0)
+ time64_t ktime_get_boottime_seconds(void)
+ {
+ return ktime_divns(ktime_get_boottime(), NSEC_PER_SEC);
+ }
+ EXPORT_SYMBOL_GPL(ktime_get_boottime_seconds);
++#endif
+diff --git a/compat/backport-genetlink.c b/compat/backport-genetlink.c
+index d841566..906fc04 100644
+--- a/compat/backport-genetlink.c
++++ b/compat/backport-genetlink.c
+@@ -85,8 +85,10 @@ static void extack_netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh,
+
+ skb = nlmsg_new(payload + tlvlen, GFP_KERNEL);
+ if (!skb) {
++#if LINUX_VERSION_IS_GEQ(3,10,0)
+ NETLINK_CB(in_skb).sk->sk_err = ENOBUFS;
+ NETLINK_CB(in_skb).sk->sk_error_report(NETLINK_CB(in_skb).sk);
++#endif
+ return;
+ }
+
+diff --git a/compat/compat-3.3.c b/compat/compat-3.3.c
+index 1185a5d..54e1c78 100644
+--- a/compat/compat-3.3.c
++++ b/compat/compat-3.3.c
+@@ -11,6 +11,7 @@
+ #include <linux/kernel.h>
+ #include <linux/version.h>
+ #include <linux/skbuff.h>
++#include <linux/string.h>
+ #include <linux/module.h>
+ #include <linux/workqueue.h>
+ #include <net/dst.h>
+@@ -224,3 +225,27 @@ void backport_destroy_workqueue(struct workqueue_struct *wq)
+ spin_unlock(&wq_name_lock);
+ }
+ EXPORT_SYMBOL_GPL(backport_destroy_workqueue);
++
++void *memchr_inv(const void *s, int c, size_t n)
++{
++ const unsigned char *p = s;
++ while (n-- != 0)
++ if ((unsigned char)c != *p++)
++ return (void *)(p - 1);
++
++ return NULL;
++}
++EXPORT_SYMBOL_GPL(memchr_inv);
++
++void kfree_skb_list(struct sk_buff *segs)
++{
++ while (segs) {
++ struct sk_buff *next = segs->next;
++
++ kfree_skb(segs);
++ segs = next;
++ }
++}
++EXPORT_SYMBOL(kfree_skb_list);
++
++
+diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+index eaf0a19..27b8388 100644
+--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
++++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+@@ -96,6 +96,7 @@ static void iwl_trans_pcie_dump_regs(struct iwl_trans *trans)
+ {
+ #define PCI_DUMP_SIZE 64
+ #define PREFIX_LEN 32
++#if LINUX_VERSION_IS_GEQ(3,3,0)
+ struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+ struct pci_dev *pdev = trans_pcie->pci_dev;
+ u32 i, pos, alloc_size, *ptr, *buf;
+@@ -178,6 +179,9 @@ err_read:
+ out:
+ trans_pcie->pcie_dbg_dumped_once = 1;
+ kfree(buf);
++#else
++ return ;
++#endif
+ }
+
+ static void iwl_trans_pcie_sw_reset(struct iwl_trans *trans)
+diff --git a/net/wireless/trace.h b/net/wireless/trace.h
+index b0446c2..7c6901d 100644
+--- a/net/wireless/trace.h
++++ b/net/wireless/trace.h
+@@ -214,6 +214,23 @@
+ * rdev->ops traces *
+ *************************************************************/
+
++
++#if LINUX_VERSION_IS_LESS(3,10,0)
++#ifndef BACKPORTS_TRACE
++#define BACKPORTS_TRACE
++#undef TP_PROTO
++#define TP_PROTO(args...) args
++#undef DECLARE_TRACE
++#define DECLARE_TRACE(args...)
++#undef DEFINE_EVENT
++#define DEFINE_EVENT(skip,name,proto,args...) inline void trace_##name(proto){}
++#undef TRACE_EVENT
++#define TRACE_EVENT(name,proto,args...) inline void trace_##name(proto){}
++#undef DECLARE_EVENT_CLASS
++#define DECLARE_EVENT_CLASS(args...)
++#endif
++#endif
++
+ TRACE_EVENT(rdev_suspend,
+ TP_PROTO(struct wiphy *wiphy, struct cfg80211_wowlan *wow),
+ TP_ARGS(wiphy, wow),
+diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
+index fefd5e3..1b14bf8 100644
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -12287,7 +12287,7 @@ static int nl80211_crit_protocol_start(struct sk_buff *skb,
+
+ ret = rdev_crit_proto_start(rdev, wdev, proto, duration);
+ if (!ret)
+- rdev->crit_proto_nlportid = info->snd_portid;
++ rdev->crit_proto_nlportid = genl_info_snd_portid(info);
+
+ return ret;
+ }
+--
diff --git a/patches/verify.patch b/patches/verify.patch
index ccc08a78..0a09fdbb 100644
--- a/patches/verify.patch
+++ b/patches/verify.patch
@@ -11,10 +11,13 @@
if (ret == -ENOMEM)
--- a/compat/verification/x509_public_key.c
+++ b/compat/verification/x509_public_key.c
-@@ -13,11 +13,8 @@
+@@ -13,11 +13,11 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
++#if LINUX_VERSION_IS_LESS(3,17,0)
++#include <linux/err.h>
++#endif
-#include <keys/asymmetric-subtype.h>
-#include <keys/asymmetric-parser.h>
#include <keys/system_keyring.h>