From d5ca8f06ac7dea8b30f6f802c810d85f64a61c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20G=C3=B6rner?= <5477952+MaxG87@users.noreply.github.com> Date: Sun, 30 Jan 2022 17:50:19 +0100 Subject: [PATCH] Fix build since dev_addr constification Since commit adeef3e32146 ("net: constify netdev->dev_addr") the driver no longer builds with various complaints about discarded const classifiers. This is fixed by switching to the helper directly. --- os_dep/linux/ioctl_linux.c | 4 ++++ os_dep/linux/os_intfs.c | 8 ++++++++ os_dep/osdep_service.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 91c07ae..e85a1a8 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -9813,7 +9813,11 @@ static int rtw_mp_efuse_set(struct net_device *dev, rtw_hal_read_chip_info(padapter); /* set mac addr*/ rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter)); +#else _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ +#endif #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 8ca79d7..ff628fe 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1477,7 +1477,11 @@ 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 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(pnetdev, sa->sa_data); +#else _rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */ +#endif #if 0 if (rtw_is_hw_init_completed(padapter)) { @@ -1915,7 +1919,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) /* alloc netdev name */ rtw_init_netdev_name(ndev, name); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(ndev, adapter_mac_addr(adapter)); +#else _rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); +#endif #if defined(CONFIG_NET_NS) dev_net_set(ndev, wiphy_net(adapter_to_wiphy(adapter))); #endif //CONFIG_NET_NS diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index acda285..7c3acab 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2561,7 +2561,12 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname) rtw_init_netdev_name(pnetdev, ifname); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter)); +#else _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#endif if (rtnl_lock_needed) ret = register_netdev(pnetdev);