dcd260ef3fa9b2b0683180e9e26a1644a30bd6b3
[openwrt/openwrt.git] / package / kernel / lantiq / ltq-ifxos / patches / 100-compat.patch
1 --- a/src/linux/ifxos_linux_thread_drv.c
2 +++ b/src/linux/ifxos_linux_thread_drv.c
3 @@ -38,6 +38,7 @@
4 #include <linux/smp_lock.h>
5 #endif
6 #include <linux/signal.h>
7 +#include <linux/kthread.h>
8
9
10 #include "ifx_types.h"
11 @@ -70,10 +71,6 @@
12 #if ( defined(IFXOS_HAVE_THREAD) && (IFXOS_HAVE_THREAD == 1) )
13
14
15 -IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
16 - IFXOS_ThreadCtrl_t *pThrCntrl);
17 -
18 -
19 /* ============================================================================
20 IFX Linux adaptation - Kernel Thread handling
21 ========================================================================= */
22 @@ -98,9 +95,9 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr
23 - IFX_SUCCESS on success
24 - IFX_ERROR on error
25 */
26 -IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
27 - IFXOS_ThreadCtrl_t *pThrCntrl)
28 +int IFXOS_KernelThreadStartup(void *data)
29 {
30 + IFXOS_ThreadCtrl_t *pThrCntrl = (IFXOS_ThreadCtrl_t*) data;
31 IFX_int32_t retVal = IFX_ERROR;
32 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
33 struct task_struct *kthread = current;
34 @@ -141,7 +138,7 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr
35 /* let others run */
36 unlock_kernel();
37 #else
38 - daemonize(pThrCntrl->thrParams.pName);
39 + //daemonize(pThrCntrl->thrParams.pName);
40
41 /* Enable signals in Kernel >= 2.6 */
42 allow_signal(SIGKILL);
43 @@ -221,9 +218,7 @@ IFX_int32_t IFXOS_ThreadInit(
44 init_completion(&pThrCntrl->thrCompletion);
45
46 /* start kernel thread via the wrapper function */
47 - pThrCntrl->tid = kernel_thread( (IFXOS_KERNEL_THREAD_StartRoutine)IFXOS_KernelThreadStartup,
48 - (void *)pThrCntrl,
49 - IFXOS_DRV_THREAD_OPTIONS);
50 + pThrCntrl->tid = kthread_run(IFXOS_KernelThreadStartup, (void *)pThrCntrl, "ifxos");
51
52 pThrCntrl->bValid = IFX_TRUE;
53
54 --- a/src/include/ifxos_thread.h
55 +++ b/src/include/ifxos_thread.h
56 @@ -111,7 +111,7 @@ typedef struct IFXOS_ThreadParams_s
57 /**
58 Function type of the user thread/task function.
59 */
60 -typedef IFX_int32_t (*IFXOS_ThreadFunction_t)(IFXOS_ThreadParams_t *);
61 +typedef int (*IFXOS_ThreadFunction_t)(void*);
62
63 /** @} */
64
65 --- a/src/include/linux/ifxos_linux_thread.h
66 +++ b/src/include/linux/ifxos_linux_thread.h
67 @@ -152,7 +152,7 @@ typedef struct
68 IFXOS_ThreadFunction_t pThrFct;
69
70 /** Kernel thread process ID */
71 - IFX_int32_t tid;
72 + struct task_struct *tid;
73
74 /** requested kernel thread priority */
75 IFX_int32_t nPriority;
76 --- a/src/linux/ifxos_linux_socket_drv.c
77 +++ b/src/linux/ifxos_linux_socket_drv.c
78 @@ -19,6 +19,7 @@
79 /* ============================================================================
80 IFX Linux adaptation - Global Includes - Kernel
81 ========================================================================= */
82 +#include <linux/version.h>
83 #include <linux/kernel.h>
84 #ifdef MODULE
85 #include <linux/module.h>
86 @@ -166,23 +167,33 @@ IFX_int_t IFXOS_SocketSendTo(
87 IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR);
88 IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR);
89
90 + iov.iov_base = pBuffer;
91 + iov.iov_len = (unsigned int) bufSize_byte;
92 +
93 msg.msg_name = (void *) pSocAddr;
94 msg.msg_namelen = sizeof(IFXOS_sockAddr_t);
95 - msg.msg_iov = &iov;
96 - msg.msg_iovlen = 1;
97 msg.msg_control = IFX_NULL;
98 msg.msg_controllen = 0;
99 msg.msg_flags = MSG_DONTWAIT;
100
101 - msg.msg_iov->iov_base = pBuffer;
102 - msg.msg_iov->iov_len = (unsigned int) bufSize_byte;
103 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
104 + msg.msg_iov = &iov;
105 + msg.msg_iovlen = 1;
106 +#else
107 + iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, bufSize_byte);
108 +#endif
109
110 /* Modify address limitation which is used if user space is calling
111 kernel space, otherwise sock_sendmsg() will fail.*/
112 old_fs = get_fs();
113 set_fs(KERNEL_DS);
114
115 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
116 ret = sock_sendmsg((struct socket *) socFd, &msg, bufSize_byte);
117 +#else
118 + ret = sock_sendmsg((struct socket *) socFd, &msg);
119 +#endif
120 +
121 set_fs(old_fs);
122
123 return ret;
124 --- a/src/linux/ifxos_linux_memory_map_drv.c
125 +++ b/src/linux/ifxos_linux_memory_map_drv.c
126 @@ -25,6 +25,7 @@
127 IFX Linux adaptation - Global Includes - Kernel
128 ========================================================================= */
129
130 +#include <linux/version.h>
131 #include <linux/kernel.h>
132 #ifdef MODULE
133 #include <linux/module.h>
134 @@ -87,6 +88,7 @@ IFX_int32_t IFXOS_Phy2VirtMap(
135 IFXOS_RETURN_IF_POINTER_NOT_NULL(*ppVirtAddr, IFX_ERROR);
136 IFXOS_RETURN_IF_ARG_LE_ZERO(addrRangeSize_byte, IFX_ERROR);
137
138 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
139 if ( check_mem_region(physicalAddr, addrRangeSize_byte) )
140 {
141 IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR,
142 @@ -98,6 +100,16 @@ IFX_int32_t IFXOS_Phy2VirtMap(
143
144 /* can't fail */
145 request_mem_region(physicalAddr, addrRangeSize_byte, pName);
146 +#else
147 + if ( !request_mem_region(physicalAddr, addrRangeSize_byte, pName) )
148 + {
149 + IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR,
150 + ("IFXOS: ERROR Phy2Virt map, region request - addr 0x%08lX (size 0x%lX) not free" IFXOS_CRLF,
151 + physicalAddr, addrRangeSize_byte));
152 +
153 + return IFX_ERROR;
154 + }
155 +#endif
156
157 /* remap memory (not cache able): physical --> virtual */
158 pVirtAddr = (IFX_uint8_t *)ioremap_nocache( physicalAddr,