Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix compilation for Realtek RTL8822BU USB Adapter linux driver for kernel >= 4.15
diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c
index 1a9264d..d97371c 100644
--- a/hal/phydm/phydm_interface.c
+++ b/hal/phydm/phydm_interface.c
@@ -653,7 +653,11 @@ ODM_sleep_us(u32 us)
void
odm_set_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer,
+#else
+ struct timer_list *p_timer,
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
u32 ms_delay
)
{
@@ -673,7 +677,11 @@ odm_set_timer(
void
odm_initialize_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer,
+#else
+ struct timer_list *p_timer,
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
void *call_back_func,
void *p_context,
const char *sz_id
@@ -702,7 +710,11 @@ odm_initialize_timer(
void
odm_cancel_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer
+#else
+ struct timer_list *p_timer
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
)
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
@@ -721,7 +733,11 @@ odm_cancel_timer(
void
odm_release_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer
+#else
+ struct timer_list *p_timer
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
)
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
diff --git a/hal/phydm/phydm_interface.h b/hal/phydm/phydm_interface.h
index 3c24a6e..aa64ddf 100644
--- a/hal/phydm/phydm_interface.h
+++ b/hal/phydm/phydm_interface.h
@@ -358,14 +358,22 @@ ODM_sleep_us(u32 us);
void
odm_set_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer,
+#else
+ struct timer_list *p_timer,
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
u32 ms_delay
);
void
odm_initialize_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer,
+#else
+ struct timer_list *p_timer,
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
void *call_back_func,
void *p_context,
const char *sz_id
@@ -374,13 +382,21 @@ odm_initialize_timer(
void
odm_cancel_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer
+#else
+ struct timer_list *p_timer
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
);
void
odm_release_timer(
struct PHY_DM_STRUCT *p_dm_odm,
- struct timer_list *p_timer
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ struct legacy_timer_emu *p_timer
+#else
+ struct timer_list *p_timer
+#endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
);
/*
diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h
index c400fdc..73fb554 100644
--- a/include/osdep_service_linux.h
+++ b/include/osdep_service_linux.h
@@ -148,7 +148,15 @@ typedef spinlock_t _lock;
#else
typedef struct semaphore _mutex;
#endif
-typedef struct timer_list _timer;
+#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 //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
typedef struct completion _completion;
struct __queue {
@@ -278,22 +286,42 @@ __inline static void rtw_list_delete(_list *plist)
list_del_init(plist);
}
+#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 //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+
__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 //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
}
__inline static void _set_timer(_timer *ptimer, u32 delay_time)
{
- mod_timer(ptimer , (jiffies + (delay_time * HZ / 1000)));
+#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 //(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
}
__inline static void _cancel_timer(_timer *ptimer, u8 *bcancelled)
{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+ *bcancelled = del_timer_sync(&ptimer->t) == 1 ? 1 : 0;
+#else
*bcancelled = del_timer_sync(ptimer) == 1 ? 1 : 0;
+#endif
}
static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c
index 8bc7bbc..2101bd1 100644
--- a/os_dep/osdep_service.c
+++ b/os_dep/osdep_service.c
@@ -2019,7 +2019,8 @@ static int readFile(struct file *fp, char *buf, int len)
while (sum < len) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
- rlen = __vfs_read(fp, buf + sum, len - sum, &fp->f_pos);
+ /*rlen = __vfs_read(fp, buf + sum, len - sum, &fp->f_pos);*/
+ rlen = kernel_read(fp, buf + sum, len - sum, &fp->f_pos);
#else
rlen = fp->f_op->read(fp, buf + sum, len - sum, &fp->f_pos);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.