From 9832dd2e11620d415cbb0c1de7d20683d2608d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Sun, 23 Jan 2022 20:17:17 +0100
Subject: [PATCH 035/463] 8723cs: Forward port to 5.17

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../hal/rtl8703b/sdio/rtl8703bs_recv.c        |  6 ++---
 .../staging/rtl8723cs/os_dep/linux/os_intfs.c |  6 +++--
 .../staging/rtl8723cs/os_dep/linux/rtw_proc.c | 25 ++++++-------------
 .../staging/rtl8723cs/os_dep/osdep_service.c  |  2 +-
 4 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723cs/hal/rtl8703b/sdio/rtl8703bs_recv.c b/drivers/staging/rtl8723cs/hal/rtl8703b/sdio/rtl8703bs_recv.c
index 28f7156798445..dda8a8a194884 100644
--- a/drivers/staging/rtl8723cs/hal/rtl8703b/sdio/rtl8703bs_recv.c
+++ b/drivers/staging/rtl8723cs/hal/rtl8703b/sdio/rtl8703bs_recv.c
@@ -161,7 +161,7 @@ s32 rtl8703bs_recv_hdl(_adapter *padapter)
 	return _SUCCESS;
 }
 
-static void rtl8703bs_recv_tasklet(void *priv)
+static void rtl8703bs_recv_tasklet(unsigned long priv)
 {
 	_adapter *adapter = (_adapter *)priv;
 	s32 ret;
@@ -177,7 +177,7 @@ static void rtl8703bs_recv_tasklet(void *priv)
 	}
 }
 #else
-static void rtl8703bs_recv_tasklet(void *priv)
+static void rtl8703bs_recv_tasklet(unsigned long priv)
 {
 	PADAPTER				padapter;
 	PHAL_DATA_TYPE			pHalData;
@@ -403,7 +403,7 @@ s32 rtl8703bs_init_recv_priv(PADAPTER padapter)
 	/* 3 2. init tasklet */
 #ifdef PLATFORM_LINUX
 	tasklet_init(&precvpriv->recv_tasklet,
-		     (void(*)(unsigned long))rtl8703bs_recv_tasklet,
+		     rtl8703bs_recv_tasklet,
 		     (unsigned long)padapter);
 #endif
 
diff --git a/drivers/staging/rtl8723cs/os_dep/linux/os_intfs.c b/drivers/staging/rtl8723cs/os_dep/linux/os_intfs.c
index 86572d7c17da8..7fbce22c08423 100644
--- a/drivers/staging/rtl8723cs/os_dep/linux/os_intfs.c
+++ b/drivers/staging/rtl8723cs/os_dep/linux/os_intfs.c
@@ -1615,7 +1615,8 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *addr)
 	}
 
 	_rtw_memcpy(adapter_mac_addr(padapter), sa->sa_data, ETH_ALEN); /* set mac addr to adapter */
-	_rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */
+	//_rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */
+	dev_addr_set(pnetdev, sa->sa_data);
 
 #if 0
 	if (rtw_is_hw_init_completed(padapter)) {
@@ -2151,7 +2152,8 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name)
 	/* alloc netdev name */
 	rtw_init_netdev_name(ndev, name);
 
-	_rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN);
+	//_rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN);
+	dev_addr_set(ndev, adapter_mac_addr(adapter));
 
 	/* Tell the network stack we exist */
 
diff --git a/drivers/staging/rtl8723cs/os_dep/linux/rtw_proc.c b/drivers/staging/rtl8723cs/os_dep/linux/rtw_proc.c
index bfe65dbbc4f91..482916f2eabb4 100644
--- a/drivers/staging/rtl8723cs/os_dep/linux/rtw_proc.c
+++ b/drivers/staging/rtl8723cs/os_dep/linux/rtw_proc.c
@@ -30,15 +30,6 @@ inline struct proc_dir_entry *get_rtw_drv_proc(void)
 
 #define RTW_PROC_NAME DRV_NAME
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-#define file_inode(file) ((file)->f_dentry->d_inode)
-#endif
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0))
-#define PDE_DATA(inode) PDE((inode))->data
-#define proc_get_parent_data(inode) PDE((inode))->parent->data
-#endif
-
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
 #define get_proc_net proc_net
 #else
@@ -247,7 +238,7 @@ 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); */
-	ssize_t index = (ssize_t)PDE_DATA(inode);
+	ssize_t index = (ssize_t)pde_data(inode);
 	const struct rtw_proc_hdl *hdl = drv_proc_hdls + index;
 	void *private = NULL;
 
@@ -273,7 +264,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(file_inode(file));
+	ssize_t index = (ssize_t)pde_data(file_inode(file));
 	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;
 
@@ -5631,7 +5622,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(inode);
+	ssize_t index = (ssize_t)pde_data(inode);
 	const struct rtw_proc_hdl *hdl = adapter_proc_hdls + index;
 	void *private = proc_get_parent_data(inode);
 
@@ -5657,7 +5648,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(file_inode(file));
+	ssize_t index = (ssize_t)pde_data(file_inode(file));
 	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;
 
@@ -5820,7 +5811,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(inode);
+	ssize_t index = (ssize_t)pde_data(inode);
 	const struct rtw_proc_hdl *hdl = odm_proc_hdls + index;
 	void *private = proc_get_parent_data(inode);
 
@@ -5846,7 +5837,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(file_inode(file));
+	ssize_t index = (ssize_t)pde_data(file_inode(file));
 	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;
 
@@ -5985,7 +5976,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(inode);
+	ssize_t index = (ssize_t)pde_data(inode);
 	const struct rtw_proc_hdl *hdl = mcc_proc_hdls + index;
 	void *private = proc_get_parent_data(inode);
 
@@ -6011,7 +6002,7 @@ 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)
 {
-	ssize_t index = (ssize_t)PDE_DATA(file_inode(file));
+	ssize_t index = (ssize_t)pde_data(file_inode(file));
 	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/drivers/staging/rtl8723cs/os_dep/osdep_service.c b/drivers/staging/rtl8723cs/os_dep/osdep_service.c
index 82c887874d41f..dd3fb044993c3 100644
--- a/drivers/staging/rtl8723cs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723cs/os_dep/osdep_service.c
@@ -1309,7 +1309,7 @@ u32 _rtw_down_sema(_sema *sema)
 inline void thread_exit(_completion *comp)
 {
 #ifdef PLATFORM_LINUX
-	complete_and_exit(comp, 0);
+	kthread_complete_and_exit(comp, 0);
 #endif
 
 #ifdef PLATFORM_FREEBSD
-- 
2.46.0

