ethernet: tundra: don't write directly to netdev->dev_addr

netdev->dev_addr is const now.

Maintain the questionable offsetting in ndo_set_mac_address.

Compile tested holly_defconfig and mpc7448_hpc2_defconfig.

Fixes: adeef3e321 ("net: constify netdev->dev_addr")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2022-01-25 16:37:57 -08:00 committed by David S. Miller
parent 007c95120d
commit 14ba66a60f

View file

@ -1091,20 +1091,22 @@ static int tsi108_get_mac(struct net_device *dev)
struct tsi108_prv_data *data = netdev_priv(dev);
u32 word1 = TSI_READ(TSI108_MAC_ADDR1);
u32 word2 = TSI_READ(TSI108_MAC_ADDR2);
u8 addr[ETH_ALEN];
/* Note that the octets are reversed from what the manual says,
* producing an even weirder ordering...
*/
if (word2 == 0 && word1 == 0) {
dev->dev_addr[0] = 0x00;
dev->dev_addr[1] = 0x06;
dev->dev_addr[2] = 0xd2;
dev->dev_addr[3] = 0x00;
dev->dev_addr[4] = 0x00;
addr[0] = 0x00;
addr[1] = 0x06;
addr[2] = 0xd2;
addr[3] = 0x00;
addr[4] = 0x00;
if (0x8 == data->phy)
dev->dev_addr[5] = 0x01;
addr[5] = 0x01;
else
dev->dev_addr[5] = 0x02;
addr[5] = 0x02;
eth_hw_addr_set(dev, addr);
word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
@ -1114,12 +1116,13 @@ static int tsi108_get_mac(struct net_device *dev)
TSI_WRITE(TSI108_MAC_ADDR1, word1);
TSI_WRITE(TSI108_MAC_ADDR2, word2);
} else {
dev->dev_addr[0] = (word2 >> 16) & 0xff;
dev->dev_addr[1] = (word2 >> 24) & 0xff;
dev->dev_addr[2] = (word1 >> 0) & 0xff;
dev->dev_addr[3] = (word1 >> 8) & 0xff;
dev->dev_addr[4] = (word1 >> 16) & 0xff;
dev->dev_addr[5] = (word1 >> 24) & 0xff;
addr[0] = (word2 >> 16) & 0xff;
addr[1] = (word2 >> 24) & 0xff;
addr[2] = (word1 >> 0) & 0xff;
addr[3] = (word1 >> 8) & 0xff;
addr[4] = (word1 >> 16) & 0xff;
addr[5] = (word1 >> 24) & 0xff;
eth_hw_addr_set(dev, addr);
}
if (!is_valid_ether_addr(dev->dev_addr)) {
@ -1136,14 +1139,12 @@ static int tsi108_set_mac(struct net_device *dev, void *addr)
{
struct tsi108_prv_data *data = netdev_priv(dev);
u32 word1, word2;
int i;
if (!is_valid_ether_addr(addr))
return -EADDRNOTAVAIL;
for (i = 0; i < 6; i++)
/* +2 is for the offset of the HW addr type */
dev->dev_addr[i] = ((unsigned char *)addr)[i + 2];
/* +2 is for the offset of the HW addr type */
eth_hw_addr_set(dev, ((unsigned char *)addr) + 2);
word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);