Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

atmel: use eth_hw_addr_set()

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Use a buffer on the stack. Note that atmel_get_mib() is a wrapper
around atmel_copy_to_host(). For the to device direction we just
need to make sure functions respect argument being cost.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211018235021.1279697-7-kuba@kernel.org

authored by

Jakub Kicinski and committed by
Kalle Valo
251277af c7b6128a

+10 -5
+10 -5
drivers/net/wireless/atmel/atmel.c
··· 600 600 static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, 601 601 u16 data); 602 602 static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, 603 - u8 *data, int data_len); 603 + const u8 *data, int data_len); 604 604 static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, 605 605 u8 *data, int data_len); 606 606 static void atmel_scan(struct atmel_private *priv, int specific_ssid); ··· 3669 3669 { 3670 3670 int rc = 0; 3671 3671 struct atmel_private *priv = netdev_priv(dev); 3672 + u8 addr[ETH_ALEN] = {}; 3672 3673 3673 3674 /* reset pccard */ 3674 3675 if (priv->bus_type == BUS_TYPE_PCCARD) ··· 3694 3693 if (i == 0) { 3695 3694 printk(KERN_ALERT "%s: MAC failed to boot MAC address reader.\n", dev->name); 3696 3695 } else { 3697 - atmel_copy_to_host(dev, dev->dev_addr, atmel_read16(dev, MR2), 6); 3696 + 3697 + atmel_copy_to_host(dev, addr, atmel_read16(dev, MR2), 6); 3698 + eth_hw_addr_set(dev, addr); 3698 3699 /* got address, now squash it again until the network 3699 3700 interface is opened */ 3700 3701 if (priv->bus_type == BUS_TYPE_PCCARD) ··· 3708 3705 /* Mac address easy in this case. */ 3709 3706 priv->card_type = CARD_TYPE_PARALLEL_FLASH; 3710 3707 atmel_write16(dev, BSR, 1); 3711 - atmel_copy_to_host(dev, dev->dev_addr, 0xc000, 6); 3708 + atmel_copy_to_host(dev, addr, 0xc000, 6); 3709 + eth_hw_addr_set(dev, addr); 3712 3710 atmel_write16(dev, BSR, 0x200); 3713 3711 rc = 1; 3714 3712 } else { ··· 3717 3713 for the Mac Address */ 3718 3714 priv->card_type = CARD_TYPE_SPI_FLASH; 3719 3715 if (atmel_wakeup_firmware(priv) == 0) { 3720 - atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); 3716 + atmel_get_mib(priv, Mac_Address_Mib_Type, 0, addr, 6); 3717 + eth_hw_addr_set(dev, addr); 3721 3718 3722 3719 /* got address, now squash it again until the network 3723 3720 interface is opened */ ··· 4108 4103 } 4109 4104 4110 4105 static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, 4111 - u8 *data, int data_len) 4106 + const u8 *data, int data_len) 4112 4107 { 4113 4108 struct get_set_mib m; 4114 4109 m.type = type;