From 7e61ad89ccae51a80706f765e1d5f2e82a1662c7 Mon Sep 17 00:00:00 2001 From: heitbaum Date: Wed, 9 Feb 2022 12:51:37 +0000 Subject: [PATCH] rtl8812au: Fix code for kernel 5.17 API change Signed-off-by: Rudi Heitbaum --- core/rtw_mp.c | 4 ++++ include/osdep_service.h | 4 ++++ os_dep/linux/ioctl_linux.c | 4 ++++ os_dep/linux/rtw_proc.c | 32 ++++++++++++++++++++++++++++++++ os_dep/osdep_service.c | 8 ++++++++ 5 files changed, 52 insertions(+) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index aca3e8b..bb7f78a 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -1414,7 +1414,11 @@ exit: pmptx->pallocated_buf = NULL; pmptx->stop = 1; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) thread_exit(NULL); +#else + kthread_thread_exit(NULL); +#endif return 0; } diff --git a/include/osdep_service.h b/include/osdep_service.h index d7e3753..5d2fb52 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -418,7 +418,11 @@ static __inline void thread_enter(char *name) printf("%s", "RTKTHREAD_enter"); #endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) void thread_exit(_completion *comp); +#else +void kthread_thread_exit(_completion *comp); +#endif void _rtw_init_completion(_completion *comp); void _rtw_wait_for_comp_timeout(_completion *comp); void _rtw_wait_for_comp(_completion *comp); diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index b5b9119..73745bc 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -11804,7 +11804,11 @@ thread_return lbk_thread(thread_context context) ploopback->bstop = _TRUE; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) thread_exit(NULL); +#else + kthread_thread_exit(NULL); +#endif return 0; } diff --git a/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c index f1016e1..840a675 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -213,7 +213,11 @@ const int drv_proc_hdls_num = sizeof(drv_proc_hdls) / sizeof(struct rtw_proc_hdl static int rtw_drv_proc_open(struct inode *inode, struct file *file) { /* struct net_device *dev = proc_get_parent_data(inode); */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(inode); +#else + ssize_t index = (ssize_t)inode->i_private; +#endif const struct rtw_proc_hdl *hdl = drv_proc_hdls + index; void *private = NULL; @@ -235,7 +239,11 @@ static int rtw_drv_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#else + ssize_t index = (ssize_t)file_inode(file)->i_private; +#endif const struct rtw_proc_hdl *hdl = drv_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; @@ -4155,7 +4163,11 @@ const int adapter_proc_hdls_num = sizeof(adapter_proc_hdls) / sizeof(struct rtw_ static int rtw_adapter_proc_open(struct inode *inode, struct file *file) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(inode); +#else + ssize_t index = (ssize_t)inode->i_private; +#endif const struct rtw_proc_hdl *hdl = adapter_proc_hdls + index; void *private = proc_get_parent_data(inode); @@ -4177,7 +4189,11 @@ static int rtw_adapter_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#else + ssize_t index = (ssize_t)file_inode(file)->i_private; +#endif const struct rtw_proc_hdl *hdl = adapter_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; @@ -4342,7 +4358,11 @@ const int odm_proc_hdls_num = sizeof(odm_proc_hdls) / sizeof(struct rtw_proc_hdl static int rtw_odm_proc_open(struct inode *inode, struct file *file) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(inode); +#else + ssize_t index = (ssize_t)inode->i_private; +#endif const struct rtw_proc_hdl *hdl = odm_proc_hdls + index; void *private = proc_get_parent_data(inode); @@ -4364,7 +4384,11 @@ static int rtw_odm_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#else + ssize_t index = (ssize_t)file_inode(file)->i_private; +#endif const struct rtw_proc_hdl *hdl = odm_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; @@ -4501,7 +4525,11 @@ const int mcc_proc_hdls_num = sizeof(mcc_proc_hdls) / sizeof(struct rtw_proc_hdl static int rtw_mcc_proc_open(struct inode *inode, struct file *file) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(inode); +#else + ssize_t index = (ssize_t)inode->i_private; +#endif const struct rtw_proc_hdl *hdl = mcc_proc_hdls + index; void *private = proc_get_parent_data(inode); @@ -4523,7 +4551,11 @@ static int rtw_mcc_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_mcc_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#else + ssize_t index = (ssize_t)file_inode(file)->i_private; +#endif const struct rtw_proc_hdl *hdl = mcc_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 0769b49..5e0bd8a 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1289,10 +1289,18 @@ u32 _rtw_down_sema(_sema *sema) #endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) inline void thread_exit(_completion *comp) +#else +inline void kthread_thread_exit(_completion *comp) +#endif { #ifdef PLATFORM_LINUX +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) complete_and_exit(comp, 0); +#else + kthread_complete_and_exit(comp, 0); +#endif #endif #ifdef PLATFORM_FREEBSD