lantiq: ltq-ifxos: Do not force O3 build any more
[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,11 @@ 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, pThrCntrl->thrParams.pName);
51 + if (IS_ERR(pThrCntrl->tid)) {
52 + IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR,
53 + ("IFXOS ERROR - Problem creating thread: %li" IFXOS_CRLF, PTR_ERR(pThrCntrl->tid)));
54 + }
55
56 pThrCntrl->bValid = IFX_TRUE;
57
58 --- a/src/include/linux/ifxos_linux_thread.h
59 +++ b/src/include/linux/ifxos_linux_thread.h
60 @@ -152,7 +152,7 @@ typedef struct
61 IFXOS_ThreadFunction_t pThrFct;
62
63 /** Kernel thread process ID */
64 - IFX_int32_t tid;
65 + struct task_struct *tid;
66
67 /** requested kernel thread priority */
68 IFX_int32_t nPriority;
69 --- a/src/linux/ifxos_linux_socket_drv.c
70 +++ b/src/linux/ifxos_linux_socket_drv.c
71 @@ -19,6 +19,7 @@
72 /* ============================================================================
73 IFX Linux adaptation - Global Includes - Kernel
74 ========================================================================= */
75 +#include <linux/version.h>
76 #include <linux/kernel.h>
77 #ifdef MODULE
78 #include <linux/module.h>
79 @@ -166,23 +167,33 @@ IFX_int_t IFXOS_SocketSendTo(
80 IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR);
81 IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR);
82
83 + iov.iov_base = pBuffer;
84 + iov.iov_len = (unsigned int) bufSize_byte;
85 +
86 msg.msg_name = (void *) pSocAddr;
87 msg.msg_namelen = sizeof(IFXOS_sockAddr_t);
88 - msg.msg_iov = &iov;
89 - msg.msg_iovlen = 1;
90 msg.msg_control = IFX_NULL;
91 msg.msg_controllen = 0;
92 msg.msg_flags = MSG_DONTWAIT;
93
94 - msg.msg_iov->iov_base = pBuffer;
95 - msg.msg_iov->iov_len = (unsigned int) bufSize_byte;
96 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
97 + msg.msg_iov = &iov;
98 + msg.msg_iovlen = 1;
99 +#else
100 + iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, bufSize_byte);
101 +#endif
102
103 /* Modify address limitation which is used if user space is calling
104 kernel space, otherwise sock_sendmsg() will fail.*/
105 old_fs = get_fs();
106 set_fs(KERNEL_DS);
107
108 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
109 ret = sock_sendmsg((struct socket *) socFd, &msg, bufSize_byte);
110 +#else
111 + ret = sock_sendmsg((struct socket *) socFd, &msg);
112 +#endif
113 +
114 set_fs(old_fs);
115
116 return ret;
117 --- a/src/linux/ifxos_linux_memory_map_drv.c
118 +++ b/src/linux/ifxos_linux_memory_map_drv.c
119 @@ -25,6 +25,7 @@
120 IFX Linux adaptation - Global Includes - Kernel
121 ========================================================================= */
122
123 +#include <linux/version.h>
124 #include <linux/kernel.h>
125 #ifdef MODULE
126 #include <linux/module.h>
127 @@ -87,6 +88,7 @@ IFX_int32_t IFXOS_Phy2VirtMap(
128 IFXOS_RETURN_IF_POINTER_NOT_NULL(*ppVirtAddr, IFX_ERROR);
129 IFXOS_RETURN_IF_ARG_LE_ZERO(addrRangeSize_byte, IFX_ERROR);
130
131 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
132 if ( check_mem_region(physicalAddr, addrRangeSize_byte) )
133 {
134 IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR,
135 @@ -98,6 +100,16 @@ IFX_int32_t IFXOS_Phy2VirtMap(
136
137 /* can't fail */
138 request_mem_region(physicalAddr, addrRangeSize_byte, pName);
139 +#else
140 + if ( !request_mem_region(physicalAddr, addrRangeSize_byte, pName) )
141 + {
142 + IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR,
143 + ("IFXOS: ERROR Phy2Virt map, region request - addr 0x%08lX (size 0x%lX) not free" IFXOS_CRLF,
144 + physicalAddr, addrRangeSize_byte));
145 +
146 + return IFX_ERROR;
147 + }
148 +#endif
149
150 /* remap memory (not cache able): physical --> virtual */
151 pVirtAddr = (IFX_uint8_t *)ioremap_nocache( physicalAddr,