summaryrefslogtreecommitdiff
path: root/patches/0095-backport-old-tegra-compile.patch
blob: 31519871a151e8bfcda90d70ea889c0d76d30582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
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;
 }
--