From d881f65da1e6f3bc4237b39cf2373bef51c3828c Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Wed, 24 May 2023 12:58:37 +0200 Subject: [PATCH] realtek: eth: Do not write directly to dev->addr One is never to write to dev->addr directly. In 6.1 it will be a const and with the newly enabled WERROR, we get a failing grade. Lets fix this ahead of time. Signed-off-by: Olliver Schinagl --- .../drivers/net/ethernet/rtl838x_eth.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c index e9ebc7c73c..9dcb7a3b78 100644 --- a/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c +++ b/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c @@ -1557,7 +1557,7 @@ static int rtl838x_set_mac_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + dev_addr_set(dev, addr->sa_data); rtl838x_set_mac_hw(dev, mac); pr_info("Using MAC %08x%08x\n", sw_r32(priv->r->mac), sw_r32(priv->r->mac + 4)); @@ -2352,6 +2352,7 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev) struct resource *res, *mem; phy_interface_t phy_mode; struct phylink *phylink; + u8 mac_addr[ETH_ALEN]; int err = 0, rxrings, rxringlen; struct ring_b *ring; @@ -2478,17 +2479,18 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev) * 1) from device tree data * 2) from internal registers set by bootloader */ - of_get_mac_address(pdev->dev.of_node, dev->dev_addr); - if (is_valid_ether_addr(dev->dev_addr)) { - rtl838x_set_mac_hw(dev, (u8 *)dev->dev_addr); + of_get_mac_address(pdev->dev.of_node, mac_addr); + if (is_valid_ether_addr(mac_addr)) { + rtl838x_set_mac_hw(dev, mac_addr); } else { - dev->dev_addr[0] = (sw_r32(priv->r->mac) >> 8) & 0xff; - dev->dev_addr[1] = sw_r32(priv->r->mac) & 0xff; - dev->dev_addr[2] = (sw_r32(priv->r->mac + 4) >> 24) & 0xff; - dev->dev_addr[3] = (sw_r32(priv->r->mac + 4) >> 16) & 0xff; - dev->dev_addr[4] = (sw_r32(priv->r->mac + 4) >> 8) & 0xff; - dev->dev_addr[5] = sw_r32(priv->r->mac + 4) & 0xff; - } + mac_addr[0] = (sw_r32(priv->r->mac) >> 8) & 0xff; + mac_addr[1] = sw_r32(priv->r->mac) & 0xff; + mac_addr[2] = (sw_r32(priv->r->mac + 4) >> 24) & 0xff; + mac_addr[3] = (sw_r32(priv->r->mac + 4) >> 16) & 0xff; + mac_addr[4] = (sw_r32(priv->r->mac + 4) >> 8) & 0xff; + mac_addr[5] = sw_r32(priv->r->mac + 4) & 0xff; + } + dev_addr_set(dev, mac_addr); /* if the address is invalid, use a random value */ if (!is_valid_ether_addr(dev->dev_addr)) { struct sockaddr sa = { AF_UNSPEC }; -- 2.30.2