From 80a0cb2c1aa10e52bc653e7455a6f1b64fdccd09 Mon Sep 17 00:00:00 2001 From: Carlos Garces Date: Thu, 4 Jan 2018 00:49:20 +0100 Subject: [PATCH] Update for kernel 4.15 This commit adds support for kernel 4.15, which changed the timer interface. Fetch from https://github.com/jwrdegoede/rtl8189ES_linux/commit/8c3acf92759861e82b552b1f0ef1a26b26391071 --- .travis.yml | 9 ++++++--- hal/phydm/phydm_types.h | 8 ++++++++ include/osdep_service.h | 6 ++++-- include/osdep_service_linux.h | 31 +++++++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f661fe7..0089e94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,8 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-5 - env: COMPILER=gcc-5 KVER=4.14 + - libelf-dev + env: COMPILER=gcc-5 KVER=4.15-rc6 - compiler: gcc addons: apt: @@ -34,7 +35,8 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-6 - env: COMPILER=gcc-6 KVER=4.14 + - libelf-dev + env: COMPILER=gcc-6 KVER=4.15-rc6 - compiler: gcc addons: apt: @@ -42,7 +44,8 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-7 - env: COMPILER=gcc-7 KVER=4.14 + - libelf-dev + env: COMPILER=gcc-7 KVER=4.15-rc6 - compiler: gcc addons: apt: diff --git a/hal/phydm/phydm_types.h b/hal/phydm/phydm_types.h index a3e347c..1c94627 100644 --- a/hal/phydm/phydm_types.h +++ b/hal/phydm/phydm_types.h @@ -152,7 +152,11 @@ typedef enum _RT_SPINLOCK_TYPE{ typedef struct rtl8192cd_priv *prtl8192cd_priv; typedef struct stat_info STA_INFO_T,*PSTA_INFO_T; +#if defined (LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + typedef struct legacy_timer_emu RT_TIMER, *PRT_TIMER; +#else typedef struct timer_list RT_TIMER, *PRT_TIMER; +#endif typedef void * RT_TIMER_CALL_BACK; #ifdef CONFIG_PCI_HCI @@ -222,7 +226,11 @@ typedef enum _RT_SPINLOCK_TYPE{ #define ODM_ENDIAN_TYPE ODM_ENDIAN_BIG #endif +#if defined (LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + typedef struct legacy_timer_emu RT_TIMER, *PRT_TIMER; +#else typedef struct timer_list RT_TIMER, *PRT_TIMER; +#endif typedef void * RT_TIMER_CALL_BACK; #define STA_INFO_T struct sta_info #define PSTA_INFO_T struct sta_info * diff --git a/include/osdep_service.h b/include/osdep_service.h index d78defd..b49f877 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -318,15 +318,17 @@ extern void rtw_udelay_os(int us); extern void rtw_yield_os(void); - extern void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc); - __inline static unsigned char _cancel_timer_ex(_timer *ptimer) { #ifdef PLATFORM_LINUX +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + return del_timer_sync(&ptimer->t); +#else return del_timer_sync(ptimer); #endif +#endif #ifdef PLATFORM_FREEBSD _cancel_timer(ptimer,0); return 0; diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index a4926e6..959b13c 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -133,7 +133,15 @@ #else typedef struct semaphore _mutex; #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + typedef struct legacy_timer_emu { + struct timer_list t; + void (*function)(unsigned long); + unsigned long data; + } _timer; +#else typedef struct timer_list _timer; +#endif struct __queue { struct list_head queue; @@ -266,26 +274,45 @@ __inline static void rtw_list_delete(_list *plist) #define RTW_TIMER_HDL_ARGS void *FunctionContext +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) +static void legacy_timer_emu_func(struct timer_list *t) +{ + struct legacy_timer_emu *lt = from_timer(lt, t, t); + lt->function(lt->data); +} +#endif + __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,void* cntx) { //setup_timer(ptimer, pfunc,(u32)cntx); ptimer->function = pfunc; ptimer->data = (unsigned long)cntx; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + timer_setup(&ptimer->t, legacy_timer_emu_func, 0); +#else init_timer(ptimer); +#endif } __inline static void _set_timer(_timer *ptimer,u32 delay_time) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + mod_timer(&ptimer->t, (jiffies+(delay_time*HZ/1000))); +#else mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); +#endif } __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled) { - del_timer_sync(ptimer); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) + del_timer_sync(&ptimer->t); +#else + del_timer_sync(ptimer); +#endif *bcancelled = 1; } - static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))