From 40d703465a83c2eeeafe2e84dad25fb3696236d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Garc=C3=A9s?= Date: Thu, 19 May 2022 18:46:11 +0000 Subject: [PATCH] Cleanup memcpy warnings since 5.17 Introduce eth_hw_addr_set from 5.15 Port torvalds/linux@48eab83 Port torvalds/linux@6ed178c --- include/osdep_service_linux.h | 12 ++++++++++++ os_dep/linux/ioctl_linux.c | 2 +- os_dep/linux/os_intfs.c | 4 ++-- os_dep/osdep_service.c | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index 64e32df..15255cb 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -220,6 +220,18 @@ typedef void *timer_hdl_context; #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) #endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +/* Porting from linux kernel commits +48eab831ae8b9f7002a533fa4235eed63ea1f1a3 +3f6cffb8604b537e3d7ea040d7f4368689638eaf +adeef3e32146a8d2a73c399dc6f5d76a449131b1 +*/ +static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) +{ + memcpy(dev->dev_addr, addr, ETH_ALEN); +} +#endif + typedef unsigned long systime; typedef struct tasklet_struct _tasklet; diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index fd97462..66f30b3 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -9815,7 +9815,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, /* set mac addr*/ psdio = &adapter_to_dvobj(padapter)->intf_data; rtw_macaddr_cfg(&psdio->func->dev, adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); - _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ + eth_hw_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter)); /* set mac addr to net_device */ #ifdef CONFIG_P2P rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index ebd245f..801e126 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1469,7 +1469,7 @@ 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 */ + eth_hw_addr_set(pnetdev, sa->sa_data); /* set mac addr to net_device */ #if 0 if (rtw_is_hw_init_completed(padapter)) { @@ -1909,7 +1909,7 @@ 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); + eth_hw_addr_set(ndev, adapter_mac_addr(adapter)); /* Tell the network stack we exist */ diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 72071cc..5135715 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2563,7 +2563,7 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname) rtw_init_netdev_name(pnetdev, ifname); - _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); + eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter)); if (rtnl_lock_needed) ret = register_netdev(pnetdev);