From db394109d0ade353a3070897762df73d085cc454 Mon Sep 17 00:00:00 2001 From: James Benway Date: Wed, 24 Jul 2024 09:13:18 -0400 Subject: [PATCH] netdev: fix device address setting for kernel > 5.15 --- netdev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/netdev.c b/netdev.c index 181c85f..a6776da 100644 --- a/netdev.c +++ b/netdev.c @@ -818,8 +818,17 @@ static int ccat_eth_init_netdev(struct ccat_eth_priv *priv) int status; /* init netdev with MAC and stack callbacks */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) + u8 mac_addr[ETH_ALEN]; + + if (priv->netdev->addr_len != ETH_ALEN) + return -EFAULT; + memcpy_fromio(mac_addr, priv->reg.mii + 8, ETH_ALEN); + eth_hw_addr_set(priv->netdev, mac_addr); +#else memcpy_fromio(priv->netdev->dev_addr, priv->reg.mii + 8, priv->netdev->addr_len); +#endif priv->netdev->netdev_ops = &ccat_eth_netdev_ops; netif_carrier_off(priv->netdev);