hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/linuxver.h
....@@ -1,16 +1,17 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Linux-specific abstractions to gain some independence from linux kernel versions.
43 * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
54 *
6
- * Copyright (C) 1999-2019, Broadcom Corporation
7
- *
5
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
6
+ *
7
+ * Copyright (C) 1999-2017, Broadcom Corporation
8
+ *
89 * Unless you and Broadcom execute a separate written software license
910 * agreement governing use of this software, this software is licensed to you
1011 * under the terms of the GNU General Public License version 2 (the "GPL"),
1112 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1213 * following added to such license:
13
- *
14
+ *
1415 * As a special exception, the copyright holders of this software give you
1516 * permission to link this software with independent modules, and to copy and
1617 * distribute the resulting executable under terms of your choice, provided that
....@@ -18,7 +19,7 @@
1819 * the license of that module. An independent module is a module which is not
1920 * derived from this software. The special exception does not apply to any
2021 * modifications of the software.
21
- *
22
+ *
2223 * Notwithstanding the above, under no circumstances may you combine this
2324 * software in any way with any other Broadcom software provided under a license
2425 * other than the GPL, without Broadcom's express prior written consent.
....@@ -26,7 +27,7 @@
2627 *
2728 * <<Broadcom-WL-IPTag/Open:>>
2829 *
29
- * $Id: linuxver.h 514727 2014-11-12 03:02:48Z $
30
+ * $Id: linuxver.h 646730 2016-06-30 13:01:49Z $
3031 */
3132
3233 #ifndef _linuxver_h_
....@@ -36,7 +37,7 @@
3637 #pragma GCC diagnostic push
3738 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3839 #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
39
-#endif
40
+#endif // endif
4041
4142 #include <typedefs.h>
4243 #include <linux/version.h>
....@@ -47,12 +48,12 @@
4748 #include <generated/autoconf.h>
4849 #else
4950 #include <linux/autoconf.h>
50
-#endif
51
+#endif // endif
5152 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */
5253
5354 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0))
5455 #include <linux/kconfig.h>
55
-#endif
56
+#endif // endif
5657 #include <linux/module.h>
5758
5859 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0))
....@@ -61,21 +62,21 @@
6162 #undef __NO_VERSION__
6263 #else
6364 #define __NO_VERSION__
64
-#endif
65
+#endif // endif
6566 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0) */
6667
6768 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
6869 #define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
6970 #define module_param_string(_name_, _string_, _size_, _perm_) \
7071 MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
71
-#endif
72
+#endif // endif
7273
7374 /* linux/malloc.h is deprecated, use linux/slab.h instead. */
7475 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 9))
7576 #include <linux/malloc.h>
7677 #else
7778 #include <linux/slab.h>
78
-#endif
79
+#endif // endif
7980
8081 #include <linux/types.h>
8182 #include <linux/init.h>
....@@ -101,16 +102,16 @@
101102 #include <linux/tqueue.h>
102103 #ifndef work_struct
103104 #define work_struct tq_struct
104
-#endif
105
+#endif // endif
105106 #ifndef INIT_WORK
106107 #define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
107
-#endif
108
+#endif // endif
108109 #ifndef schedule_work
109110 #define schedule_work(_work) schedule_task((_work))
110
-#endif
111
+#endif // endif
111112 #ifndef flush_scheduled_work
112113 #define flush_scheduled_work() flush_scheduled_tasks()
113
-#endif
114
+#endif // endif
114115 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41) */
115116
116117 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
....@@ -140,7 +141,7 @@
140141 (RHEL_MAJOR == 5))
141142 /* Exclude RHEL 5 */
142143 typedef void (*work_func_t)(void *work);
143
-#endif
144
+#endif // endif
144145 #endif /* >= 2.6.20 */
145146
146147 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
....@@ -150,7 +151,7 @@
150151 #define IRQ_NONE
151152 #define IRQ_HANDLED
152153 #define IRQ_RETVAL(x)
153
-#endif
154
+#endif // endif
154155 #else
155156 typedef irqreturn_t(*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
156157 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) */
....@@ -162,7 +163,7 @@
162163 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
163164 #ifdef CONFIG_NET_RADIO
164165 #define CONFIG_WIRELESS_EXT
165
-#endif
166
+#endif // endif
166167 #endif /* < 2.6.17 */
167168
168169 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67)
....@@ -174,28 +175,32 @@
174175 #include <linux/sched.h>
175176 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */
176177
178
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
179
+#include <linux/signal.h>
180
+#include <linux/sched/signal.h>
181
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */
182
+
177183 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
178184 #include <linux/sched/rt.h>
179185 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */
180186
181187 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
182188 #include <net/lib80211.h>
183
-#endif
189
+#endif // endif
184190 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
185191 #include <linux/ieee80211.h>
186192 #else
187193 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
188194 #include <net/ieee80211.h>
189
-#endif
195
+#endif // endif
190196 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) */
191
-
192197
193198 #ifndef __exit
194199 #define __exit
195
-#endif
200
+#endif // endif
196201 #ifndef __devexit
197202 #define __devexit
198
-#endif
203
+#endif // endif
199204 #ifndef __devinit
200205 # if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0))
201206 # define __devinit __init
....@@ -206,10 +211,10 @@
206211 #endif /* !__devinit */
207212 #ifndef __devinitdata
208213 #define __devinitdata
209
-#endif
214
+#endif // endif
210215 #ifndef __devexit_p
211216 #define __devexit_p(x) x
212
-#endif
217
+#endif // endif
213218
214219 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0))
215220
....@@ -252,7 +257,7 @@
252257
253258 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18))
254259 #define pci_module_init pci_register_driver
255
-#endif
260
+#endif // endif
256261
257262 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18))
258263 #ifdef MODULE
....@@ -261,39 +266,39 @@
261266 #else
262267 #define module_init(x) __initcall(x);
263268 #define module_exit(x) __exitcall(x);
264
-#endif
269
+#endif // endif
265270 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) */
266271
267272 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
268273 #define WL_USE_NETDEV_OPS
269274 #else
270275 #undef WL_USE_NETDEV_OPS
271
-#endif
276
+#endif // endif
272277
273278 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) && defined(CONFIG_RFKILL)
274279 #define WL_CONFIG_RFKILL
275280 #else
276281 #undef WL_CONFIG_RFKILL
277
-#endif
282
+#endif // endif
278283
279284 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48))
280285 #define list_for_each(pos, head) \
281286 for (pos = (head)->next; pos != (head); pos = pos->next)
282
-#endif
287
+#endif // endif
283288
284289 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 13))
285290 #define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
286291 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 44))
287292 #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
288
-#endif
293
+#endif // endif
289294
290295 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 23))
291296 #define pci_enable_device(dev) do { } while (0)
292
-#endif
297
+#endif // endif
293298
294299 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14))
295300 #define net_device device
296
-#endif
301
+#endif // endif
297302
298303 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 42))
299304
....@@ -306,7 +311,7 @@
306311 #ifndef PCI_DMA_TODEVICE
307312 #define PCI_DMA_TODEVICE 1
308313 #define PCI_DMA_FROMDEVICE 2
309
-#endif
314
+#endif // endif
310315
311316 typedef u32 dma_addr_t;
312317
....@@ -347,6 +352,41 @@
347352 #define pci_unmap_single(cookie, address, size, dir)
348353
349354 #endif /* DMA mapping */
355
+
356
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
357
+typedef struct timer_list timer_list_compat_t;
358
+
359
+#define init_timer_compat(timer_compat, cb, priv) \
360
+ init_timer(timer_compat); \
361
+ (timer_compat)->data = (ulong)priv; \
362
+ (timer_compat)->function = cb
363
+#define timer_set_private(timer_compat, priv) (timer_compat)->data = (ulong)priv
364
+#define timer_expires(timer_compat) (timer_compat)->expires
365
+
366
+#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) */
367
+
368
+typedef struct timer_list_compat {
369
+ struct timer_list timer;
370
+ void *arg;
371
+ void (*callback)(ulong arg);
372
+} timer_list_compat_t;
373
+
374
+extern void timer_cb_compat(struct timer_list *tl);
375
+
376
+#define init_timer_compat(timer_compat, cb, priv) \
377
+ (timer_compat)->arg = priv; \
378
+ (timer_compat)->callback = cb; \
379
+ timer_setup(&(timer_compat)->timer, timer_cb_compat, 0);
380
+#define timer_set_private(timer_compat, priv) (timer_compat)->arg = priv
381
+#define timer_expires(timer_compat) (timer_compat)->timer.expires
382
+
383
+#define del_timer(t) del_timer(&((t)->timer))
384
+#define del_timer_sync(t) del_timer_sync(&((t)->timer))
385
+#define timer_pending(t) timer_pending(&((t)->timer))
386
+#define add_timer(t) add_timer(&((t)->timer))
387
+#define mod_timer(t, j) mod_timer(&((t)->timer), j)
388
+
389
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) */
350390
351391 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 43))
352392
....@@ -445,7 +485,7 @@
445485 #else
446486 #define PCI_SAVE_STATE(a, b) pci_save_state(a, b)
447487 #define PCI_RESTORE_STATE(a, b) pci_restore_state(a, b)
448
-#endif
488
+#endif // endif
449489
450490 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 6))
451491 static inline int
....@@ -488,7 +528,7 @@
488528 /* Old cp0 access macros deprecated in 2.4.19 */
489529 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19))
490530 #define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
491
-#endif
531
+#endif // endif
492532
493533 /* Module refcount handled internally in 2.6.x */
494534 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
....@@ -499,46 +539,46 @@
499539 #else
500540 #define OLD_MOD_INC_USE_COUNT do {} while (0)
501541 #define OLD_MOD_DEC_USE_COUNT do {} while (0)
502
-#endif
542
+#endif // endif
503543 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
504544 #ifndef SET_MODULE_OWNER
505545 #define SET_MODULE_OWNER(dev) do {} while (0)
506
-#endif
546
+#endif // endif
507547 #ifndef MOD_INC_USE_COUNT
508548 #define MOD_INC_USE_COUNT do {} while (0)
509
-#endif
549
+#endif // endif
510550 #ifndef MOD_DEC_USE_COUNT
511551 #define MOD_DEC_USE_COUNT do {} while (0)
512
-#endif
552
+#endif // endif
513553 #define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
514554 #define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
515555 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
516556
517557 #ifndef SET_NETDEV_DEV
518558 #define SET_NETDEV_DEV(net, pdev) do {} while (0)
519
-#endif
559
+#endif // endif
520560
521561 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0))
522562 #ifndef HAVE_FREE_NETDEV
523563 #define free_netdev(dev) kfree(dev)
524
-#endif
564
+#endif // endif
525565 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) */
526566
527567 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
528568 /* struct packet_type redefined in 2.6.x */
529569 #define af_packet_priv data
530
-#endif
570
+#endif // endif
531571
532572 /* suspend args */
533573 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
534574 #define DRV_SUSPEND_STATE_TYPE pm_message_t
535575 #else
536576 #define DRV_SUSPEND_STATE_TYPE uint32
537
-#endif
577
+#endif // endif
538578
539579 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
540580 #define CHECKSUM_HW CHECKSUM_PARTIAL
541
-#endif
581
+#endif // endif
542582
543583 typedef struct {
544584 void *parent; /* some external entity that the thread supposed to work for */
....@@ -549,10 +589,11 @@
549589 struct semaphore sema;
550590 int terminated;
551591 struct completion completed;
592
+ int flush_ind;
593
+ struct completion flushed;
552594 spinlock_t spinlock;
553595 int up_cnt;
554596 } tsk_ctl_t;
555
-
556597
557598 /* requires tsk_ctl_t tsk argument, the caller's priv data is passed in owner ptr */
558599 /* note this macro assumes there may be only one context waiting on thread's completion */
....@@ -560,7 +601,7 @@
560601 #define DBG_THR(x) printk x
561602 #else
562603 #define DBG_THR(x)
563
-#endif
604
+#endif // endif
564605
565606 static inline bool binary_sema_down(tsk_ctl_t *tsk)
566607 {
....@@ -600,40 +641,111 @@
600641 return sem_up;
601642 }
602643
603
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
644
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0))
645
+#define SMP_RD_BARRIER_DEPENDS(x)
646
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
604647 #define SMP_RD_BARRIER_DEPENDS(x) smp_read_barrier_depends(x)
605648 #else
606649 #define SMP_RD_BARRIER_DEPENDS(x) smp_rmb(x)
607
-#endif
650
+#endif // endif
608651
609652 #define PROC_START(thread_func, owner, tsk_ctl, flags, name) \
610653 { \
611654 sema_init(&((tsk_ctl)->sema), 0); \
612655 init_completion(&((tsk_ctl)->completed)); \
656
+ init_completion(&((tsk_ctl)->flushed)); \
613657 (tsk_ctl)->parent = owner; \
614658 (tsk_ctl)->proc_name = name; \
615659 (tsk_ctl)->terminated = FALSE; \
660
+ (tsk_ctl)->flush_ind = FALSE; \
661
+ (tsk_ctl)->up_cnt = 0; \
616662 (tsk_ctl)->p_task = kthread_run(thread_func, tsk_ctl, (char*)name); \
617
- (tsk_ctl)->thr_pid = (tsk_ctl)->p_task->pid; \
618
- spin_lock_init(&((tsk_ctl)->spinlock)); \
619
- DBG_THR(("%s(): thread:%s:%lx started\n", __FUNCTION__, \
620
- (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
663
+ if (IS_ERR((tsk_ctl)->p_task)) { \
664
+ (tsk_ctl)->thr_pid = -1; \
665
+ DBG_THR(("%s(): thread:%s create failed\n", __FUNCTION__, \
666
+ (tsk_ctl)->proc_name)); \
667
+ } else { \
668
+ (tsk_ctl)->thr_pid = (tsk_ctl)->p_task->pid; \
669
+ spin_lock_init(&((tsk_ctl)->spinlock)); \
670
+ DBG_THR(("%s(): thread:%s:%lx started\n", __FUNCTION__, \
671
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
672
+ }; \
621673 }
674
+
675
+#define PROC_WAIT_TIMEOUT_MSEC 5000 /* 5 seconds */
622676
623677 #define PROC_STOP(tsk_ctl) \
624678 { \
679
+ uint timeout = (uint)msecs_to_jiffies(PROC_WAIT_TIMEOUT_MSEC); \
625680 (tsk_ctl)->terminated = TRUE; \
626681 smp_wmb(); \
627682 up(&((tsk_ctl)->sema)); \
628
- wait_for_completion(&((tsk_ctl)->completed)); \
629
- DBG_THR(("%s(): thread:%s:%lx terminated OK\n", __FUNCTION__, \
683
+ DBG_THR(("%s(): thread:%s:%lx wait for terminate\n", __FUNCTION__, \
630684 (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
685
+ timeout = (uint)wait_for_completion_timeout(&((tsk_ctl)->completed), timeout); \
686
+ if (timeout == 0) \
687
+ DBG_THR(("%s(): thread:%s:%lx terminate timeout\n", __FUNCTION__, \
688
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
689
+ else \
690
+ DBG_THR(("%s(): thread:%s:%lx terminated OK\n", __FUNCTION__, \
691
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
692
+ (tsk_ctl)->parent = NULL; \
693
+ (tsk_ctl)->proc_name = NULL; \
631694 (tsk_ctl)->thr_pid = -1; \
695
+ (tsk_ctl)->up_cnt = 0; \
696
+}
697
+
698
+#define PROC_STOP_USING_BINARY_SEMA(tsk_ctl) \
699
+{ \
700
+ uint timeout = (uint)msecs_to_jiffies(PROC_WAIT_TIMEOUT_MSEC); \
701
+ (tsk_ctl)->terminated = TRUE; \
702
+ smp_wmb(); \
703
+ binary_sema_up(tsk_ctl); \
704
+ DBG_THR(("%s(): thread:%s:%lx wait for terminate\n", __FUNCTION__, \
705
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
706
+ timeout = (uint)wait_for_completion_timeout(&((tsk_ctl)->completed), timeout); \
707
+ if (timeout == 0) \
708
+ DBG_THR(("%s(): thread:%s:%lx terminate timeout\n", __FUNCTION__, \
709
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
710
+ else \
711
+ DBG_THR(("%s(): thread:%s:%lx terminated OK\n", __FUNCTION__, \
712
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
713
+ (tsk_ctl)->parent = NULL; \
714
+ (tsk_ctl)->proc_name = NULL; \
715
+ (tsk_ctl)->thr_pid = -1; \
716
+}
717
+
718
+/*
719
+* Flush is non-rentrant, so callers must make sure
720
+* there is no race condition.
721
+* For safer exit, added wait_for_completion_timeout
722
+* with 1 sec timeout.
723
+*/
724
+#define PROC_FLUSH_USING_BINARY_SEMA(tsk_ctl) \
725
+{ \
726
+ uint timeout = (uint)msecs_to_jiffies(PROC_WAIT_TIMEOUT_MSEC); \
727
+ (tsk_ctl)->flush_ind = TRUE; \
728
+ smp_wmb(); \
729
+ binary_sema_up(tsk_ctl); \
730
+ DBG_THR(("%s(): thread:%s:%lx wait for flush\n", __FUNCTION__, \
731
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
732
+ timeout = (uint)wait_for_completion_timeout(&((tsk_ctl)->flushed), timeout); \
733
+ if (timeout == 0) \
734
+ DBG_THR(("%s(): thread:%s:%lx flush timeout\n", __FUNCTION__, \
735
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
736
+ else \
737
+ DBG_THR(("%s(): thread:%s:%lx flushed OK\n", __FUNCTION__, \
738
+ (tsk_ctl)->proc_name, (tsk_ctl)->thr_pid)); \
632739 }
633740
634741 /* ----------------------- */
635742
636743 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
744
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
745
+/* send_sig declaration moved */
746
+#include <linux/sched/signal.h>
747
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) */
748
+
637749 #define KILL_PROC(nr, sig) \
638750 { \
639751 struct task_struct *tsk; \
....@@ -656,7 +768,7 @@
656768 { \
657769 kill_proc(pid, sig, 1); \
658770 }
659
-#endif
771
+#endif // endif
660772 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) */
661773
662774 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
....@@ -708,7 +820,7 @@
708820 #define DEV_PRIV(dev) (dev->priv)
709821 #else
710822 #define DEV_PRIV(dev) netdev_priv(dev)
711
-#endif
823
+#endif // endif
712824
713825 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
714826 #define WL_ISR(i, d, p) wl_isr((i), (d))
....@@ -724,14 +836,16 @@
724836 #define CAN_SLEEP() ((!in_atomic() && !irqs_disabled()))
725837 #else
726838 #define CAN_SLEEP() (FALSE)
727
-#endif
839
+#endif // endif
728840
729841 #define KMALLOC_FLAG (CAN_SLEEP() ? GFP_KERNEL: GFP_ATOMIC)
730842
731843 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
732844 #define RANDOM32 prandom_u32
845
+#define RANDOM_BYTES prandom_bytes
733846 #else
734847 #define RANDOM32 random32
848
+#define RANDOM_BYTES get_random_bytes
735849 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) */
736850
737851 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
....@@ -744,7 +858,7 @@
744858 * Overide latest kfifo functions with
745859 * older version to work on older kernels
746860 */
747
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33))
861
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)) && !defined(WL_COMPAT_WIRELESS)
748862 #define kfifo_in_spinlocked(a, b, c, d) kfifo_put(a, (u8 *)b, c)
749863 #define kfifo_out_spinlocked(a, b, c, d) kfifo_get(a, (u8 *)b, c)
750864 #define kfifo_esize(a) 1
....@@ -757,6 +871,31 @@
757871
758872 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
759873 #pragma GCC diagnostic pop
760
-#endif
874
+#endif // endif
875
+
876
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
877
+static inline struct inode *file_inode(const struct file *f)
878
+{
879
+ return f->f_dentry->d_inode;
880
+}
881
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)) */
882
+
883
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
884
+#define vfs_write(fp, buf, len, pos) kernel_write(fp, buf, len, pos)
885
+#define vfs_read(fp, buf, len, pos) kernel_read(fp, buf, len, pos)
886
+int kernel_read_compat(struct file *file, loff_t offset, char *addr, unsigned long count);
887
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) */
888
+#define kernel_read_compat(file, offset, addr, count) kernel_read(file, offset, addr, count)
889
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) */
890
+
891
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
892
+#define timespec64 timespec
893
+#define ktime_get_real_ts64(timespec) ktime_get_real_ts(timespec)
894
+#define ktime_to_timespec64(timespec) ktime_to_timespec(timespec)
895
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) */
896
+
897
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
898
+#define rtc_time_to_tm(time, tm) rtc_time64_to_tm(time, tm)
899
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) */
761900
762901 #endif /* _linuxver_h_ */