100-compat.patch 5.2 KB

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