rtl8812au-ct: fix even more compilation error with kernel 6.1

Fix more compilation error with kernel 6.1 and make it possible to
compile.

Multiple fix are done due to kernel bump:
- PDE_DATA (now deprecated) to pde_data
- dev_addr now const and require some cast
- prandom_u32 (now deprecated) to get_random_u32

Also other minor fix for always true condition and tasklet type cast not
compatible.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
Christian Marangi 2023-07-30 11:30:19 +02:00
parent 96010bb17c
commit a07566ead8
No known key found for this signature in database
GPG Key ID: AC001D09ADBFEAD7
5 changed files with 272 additions and 0 deletions

View File

@ -0,0 +1,25 @@
From e8f10b21abd8ae440632f561f8b65f37b4b55cc8 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 30 Jul 2023 11:16:32 +0200
Subject: [PATCH 1/5] os_dep/osdep_service: use new get_random_u32
Drop prandom_u32 as got deprecated for get_random_u32.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
os_dep/osdep_service.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/os_dep/osdep_service.c
+++ b/os_dep/osdep_service.c
@@ -2335,7 +2335,9 @@ u64 rtw_division64(u64 x, u64 y)
inline u32 rtw_random32(void)
{
#ifdef PLATFORM_LINUX
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0))
+ return get_random_u32();
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
return prandom_u32();
#elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18))
u32 random_int;

View File

@ -0,0 +1,72 @@
From dc4024894c9deefc56f8dd6b2d2822b277f268a5 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 30 Jul 2023 11:18:48 +0200
Subject: [PATCH 2/5] treewide: fix always TRUE condition warning
Fix always TRUE condition warning an drop redundant check.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
core/rtw_sta_mgt.c | 3 +--
hal/OUTSRC/phydm_debug.c | 16 ++++++----------
os_dep/linux/ioctl_cfg80211.c | 3 +--
3 files changed, 8 insertions(+), 14 deletions(-)
--- a/core/rtw_sta_mgt.c
+++ b/core/rtw_sta_mgt.c
@@ -207,8 +207,7 @@ void rtw_mfree_stainfo(struct sta_info *
{
_func_enter_;
- if(&psta->lock != NULL)
- _rtw_spinlock_free(&psta->lock);
+ _rtw_spinlock_free(&psta->lock);
_rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv);
_rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv);
--- a/hal/OUTSRC/phydm_debug.c
+++ b/hal/OUTSRC/phydm_debug.c
@@ -870,12 +870,10 @@ phydm_cmd_parser(
case PHYDM_RA:
for(i=0; i<5; i++) {
- if(input[i+1]) {
- PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]);
+ PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]);
- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i]));
- input_idx++;
- }
+ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i]));
+ input_idx++;
}
if(input_idx>=1) {
@@ -891,12 +889,10 @@ phydm_cmd_parser(
case PHYDM_PATHDIV:
for(i=0; i<5; i++) {
- if(input[i+1]) {
- PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]);
+ PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]);
- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i]));
- input_idx++;
- }
+ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i]));
+ input_idx++;
}
if(input_idx>=1) {
--- a/os_dep/linux/ioctl_cfg80211.c
+++ b/os_dep/linux/ioctl_cfg80211.c
@@ -2170,8 +2170,7 @@ static int cfg80211_rtw_scan(struct wiph
#ifdef CONFIG_P2P
if( pwdinfo->driver_interface == DRIVER_CFG80211 ) {
- if(ssids->ssid != NULL
- && _rtw_memcmp(ssids->ssid, "DIRECT-", 7)
+ if(_rtw_memcmp(ssids->ssid, "DIRECT-", 7)
&& rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL)
) {
if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {

View File

@ -0,0 +1,93 @@
From 5f3bb5602615894cda88ca1b44fdfafdfb01c8c8 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 30 Jul 2023 11:20:39 +0200
Subject: [PATCH 3/5] treewide: use correct type for tasklet_init
Update and use correct type for tasklet_init to fix compilation error
for not valid cast.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
hal/hal_hci/hal_usb.c | 2 +-
hal/rtl8812a/usb/rtl8812au_xmit.c | 2 +-
hal/rtl8812a/usb/usb_ops_linux.c | 2 +-
include/rtl8812a_xmit.h | 2 +-
include/usb_ops_linux.h | 2 +-
os_dep/linux/usb_ops_linux.c | 4 ++--
6 files changed, 7 insertions(+), 7 deletions(-)
--- a/hal/hal_hci/hal_usb.c
+++ b/hal/hal_hci/hal_usb.c
@@ -35,7 +35,7 @@ int usb_init_recv_priv(_adapter *padapte
#ifdef PLATFORM_LINUX
tasklet_init(&precvpriv->recv_tasklet,
- (void(*)(unsigned long))usb_recv_tasklet,
+ usb_recv_tasklet,
(unsigned long)padapter);
#endif /* PLATFORM_LINUX */
--- a/hal/rtl8812a/usb/rtl8812au_xmit.c
+++ b/hal/rtl8812a/usb/rtl8812au_xmit.c
@@ -30,7 +30,7 @@ s32 rtl8812au_init_xmit_priv(_adapter *p
#ifdef PLATFORM_LINUX
tasklet_init(&pxmitpriv->xmit_tasklet,
- (void(*)(unsigned long))rtl8812au_xmit_tasklet,
+ rtl8812au_xmit_tasklet,
(unsigned long)padapter);
#endif
#ifdef CONFIG_TX_EARLY_MODE
--- a/hal/rtl8812a/usb/usb_ops_linux.c
+++ b/hal/rtl8812a/usb/usb_ops_linux.c
@@ -475,7 +475,7 @@ _exit_recvbuf2recvframe:
}
-void rtl8812au_xmit_tasklet(void *priv)
+void rtl8812au_xmit_tasklet(unsigned long priv)
{
int ret = _FALSE;
_adapter *padapter = (_adapter*)priv;
--- a/include/rtl8812a_xmit.h
+++ b/include/rtl8812a_xmit.h
@@ -331,7 +331,7 @@ s32 rtl8812au_hal_xmit(PADAPTER padapter
s32 rtl8812au_mgnt_xmit(PADAPTER padapter, struct xmit_frame *pmgntframe);
s32 rtl8812au_hal_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmitframe);
s32 rtl8812au_xmit_buf_handler(PADAPTER padapter);
-void rtl8812au_xmit_tasklet(void *priv);
+void rtl8812au_xmit_tasklet(unsigned long priv);
s32 rtl8812au_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
#endif
--- a/include/usb_ops_linux.h
+++ b/include/usb_ops_linux.h
@@ -78,7 +78,7 @@ int usb_write16(struct intf_hdl *pintfhd
int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val);
int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
-void usb_recv_tasklet(void *priv);
+void usb_recv_tasklet(unsigned long priv);
#endif
--- a/os_dep/linux/usb_ops_linux.c
+++ b/os_dep/linux/usb_ops_linux.c
@@ -717,7 +717,7 @@ void usb_init_recvbuf(_adapter *padapter
int recvbuf2recvframe(PADAPTER padapter, void *ptr);
#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
-void usb_recv_tasklet(void *priv)
+void usb_recv_tasklet(unsigned long priv)
{
struct recv_buf *precvbuf = NULL;
_adapter *padapter = (_adapter*)priv;
@@ -870,7 +870,7 @@ u32 usb_read_port(struct intf_hdl *pintf
}
#else // CONFIG_USE_USB_BUFFER_ALLOC_RX
-void usb_recv_tasklet(void *priv)
+void usb_recv_tasklet(unsigned long priv)
{
_pkt *pskb;
_adapter *padapter = (_adapter*)priv;

View File

@ -0,0 +1,56 @@
From 51ab9d6a959de87206731f941b1df39e5c5d63ea Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 30 Jul 2023 11:21:49 +0200
Subject: [PATCH 4/5] treewide: drop const from dev_addr
dev_addr is not const and conflict with memcpy function. Fix compilation
warning by casting dev_addr to void*.
This operation is safe as this is done before netdev register.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
os_dep/linux/os_intfs.c | 6 +++---
os_dep/osdep_service.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
--- a/os_dep/linux/os_intfs.c
+++ b/os_dep/linux/os_intfs.c
@@ -1885,7 +1885,7 @@ int _netdev_if2_open(struct net_device *
_rtw_memcpy(padapter->eeprompriv.mac_addr, mac, ETH_ALEN);
rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, padapter->eeprompriv.mac_addr);
- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
}
#endif //CONFIG_PLATFORM_INTEL_BYT
@@ -2254,7 +2254,7 @@ static int _rtw_drv_register_netdev(_ada
/* alloc netdev name */
rtw_init_netdev_name(pnetdev, name);
- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
/* Tell the network stack we exist */
if (register_netdev(pnetdev) != 0) {
@@ -2334,7 +2334,7 @@ int _netdev_open(struct net_device *pnet
#ifdef CONFIG_PLATFORM_INTEL_BYT
rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, padapter->eeprompriv.mac_addr);
- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
#endif //CONFIG_PLATFORM_INTEL_BYT
padapter->bDriverStopped = _FALSE;
--- a/os_dep/osdep_service.c
+++ b/os_dep/osdep_service.c
@@ -2209,7 +2209,7 @@ int rtw_change_ifname(_adapter *padapter
rtw_init_netdev_name(pnetdev, ifname);
- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
if(!rtnl_is_locked())

View File

@ -0,0 +1,26 @@
From f455198acaa71c2963746a6b17c878c7d1d0e331 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 30 Jul 2023 11:22:58 +0200
Subject: [PATCH 5/5] os_dep/linux/proc: move to pde_data function
PDE_DATA macro was dropped in 5.17 with the new pde_data that does the
exact thing. Fix compilation error and use new function.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
os_dep/linux/rtw_proc.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/os_dep/linux/rtw_proc.c
+++ b/os_dep/linux/rtw_proc.c
@@ -37,6 +37,10 @@ inline struct proc_dir_entry *get_rtw_dr
#define file_inode(file) ((file)->f_dentry->d_inode)
#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0))
+#define PDE_DATA(inode) pde_data(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