From 3fdde50dcc583de247bdc6c93b5c459c0fa2c57a Mon Sep 17 00:00:00 2001 From: Sherry Sun Date: Tue, 15 Feb 2022 14:46:39 +0800 Subject: [PATCH] mxm_wifiex: fix the net_device::dev_addr build warnings on L5.16 Use eth_hw_addr_set function instead of writing the address directly to net_device::dev_addr. Make sure we don't cast off const qualifier from dev->dev_addr. Otherwise will have the build warnings when build the driver based on L5.16 kernel. Fixes: adeef3e32146 ("net: constify netdev->dev_addr") Signed-off-by: Sherry Sun Approved-by: Tian Yang --- mxm_wifiex/wlan_src/mlinux/moal_ioctl.c | 8 ++++++++ mxm_wifiex/wlan_src/mlinux/moal_main.c | 16 ++++++++++++++++ mxm_wifiex/wlan_src/mlinux/moal_shim.c | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c b/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c index 0f228e8..07d64d8 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c @@ -854,8 +854,12 @@ mlan_status woal_request_set_mac_address(moal_private *priv, t_u8 wait_option) "set mac address failed! status=%d, error_code=0x%x\n", status, req->status_code); } else { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set(priv->netdev, priv->current_addr); +#else moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); +#endif HEXDUMP("priv->MacAddr:", priv->current_addr, ETH_ALEN); } done: @@ -1928,8 +1932,12 @@ mlan_status woal_request_get_fw_info(moal_private *priv, t_u8 wait_option, moal_memcpy_ext(priv->phandle, priv->current_addr, &info->param.fw_info.mac_addr, sizeof(mlan_802_11_mac_addr), ETH_ALEN); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set(priv->netdev, priv->current_addr); +#else moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); +#endif if (fw_info) moal_memcpy_ext(priv->phandle, fw_info, &info->param.fw_info, diff --git a/mxm_wifiex/wlan_src/mlinux/moal_main.c b/mxm_wifiex/wlan_src/mlinux/moal_main.c index 7f7749c..7a64a77 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_main.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_main.c @@ -2316,6 +2316,13 @@ static t_u32 woal_process_init_cfg(moal_handle *handle, t_u8 *data, t_size size) "Set MAC address failed\n"); goto done; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set( + handle->priv[i] + ->netdev, + handle->priv[i] + ->current_addr); +#else moal_memcpy_ext( handle, handle->priv[i] @@ -2324,6 +2331,7 @@ static t_u32 woal_process_init_cfg(moal_handle *handle, t_u8 *data, t_size size) handle->priv[i] ->current_addr, ETH_ALEN, ETH_ALEN); +#endif index++; /* Mark found one interface matching */ @@ -5183,8 +5191,12 @@ int woal_set_mac_address(struct net_device *dev, void *addr) goto done; } HEXDUMP("priv->MacAddr:", priv->current_addr, ETH_ALEN); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set(dev, priv->current_addr); +#else moal_memcpy_ext(priv->phandle, dev->dev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); +#endif done: LEAVE(); return ret; @@ -6603,8 +6615,12 @@ void woal_init_priv(moal_private *priv, t_u8 wait_option) } woal_request_set_mac_address(priv, MOAL_IOCTL_WAIT); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set(priv->netdev, priv->current_addr); +#else moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); +#endif #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) priv->host_mlme = 0; priv->auth_flag = 0; diff --git a/mxm_wifiex/wlan_src/mlinux/moal_shim.c b/mxm_wifiex/wlan_src/mlinux/moal_shim.c index 6dcd00a..a142ecb 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_shim.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_shim.c @@ -2861,8 +2861,12 @@ mlan_status moal_recv_event(t_void *pmoal, pmlan_event pmevent) woal_start_queue(priv->netdev); moal_memcpy_ext(priv->phandle, priv->current_addr, pmevent->event_buf + 6, ETH_ALEN, ETH_ALEN); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) + eth_hw_addr_set(priv->netdev, priv->current_addr); +#else moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); +#endif woal_broadcast_event(priv, pmevent->event_buf, pmevent->event_len); #ifdef STA_SUPPORT