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