Commit 251277af authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Kalle Valo

atmel: use eth_hw_addr_set()

Commit 406f42fa ("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: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211018235021.1279697-7-kuba@kernel.org
parent c7b6128a
...@@ -600,7 +600,7 @@ static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, ...@@ -600,7 +600,7 @@ static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index,
static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index,
u16 data); u16 data);
static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index,
u8 *data, int data_len); const u8 *data, int data_len);
static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index,
u8 *data, int data_len); u8 *data, int data_len);
static void atmel_scan(struct atmel_private *priv, int specific_ssid); static void atmel_scan(struct atmel_private *priv, int specific_ssid);
...@@ -3669,6 +3669,7 @@ static int probe_atmel_card(struct net_device *dev) ...@@ -3669,6 +3669,7 @@ static int probe_atmel_card(struct net_device *dev)
{ {
int rc = 0; int rc = 0;
struct atmel_private *priv = netdev_priv(dev); struct atmel_private *priv = netdev_priv(dev);
u8 addr[ETH_ALEN] = {};
/* reset pccard */ /* reset pccard */
if (priv->bus_type == BUS_TYPE_PCCARD) if (priv->bus_type == BUS_TYPE_PCCARD)
...@@ -3693,7 +3694,9 @@ static int probe_atmel_card(struct net_device *dev) ...@@ -3693,7 +3694,9 @@ static int probe_atmel_card(struct net_device *dev)
if (i == 0) { if (i == 0) {
printk(KERN_ALERT "%s: MAC failed to boot MAC address reader.\n", dev->name); printk(KERN_ALERT "%s: MAC failed to boot MAC address reader.\n", dev->name);
} else { } else {
atmel_copy_to_host(dev, dev->dev_addr, atmel_read16(dev, MR2), 6);
atmel_copy_to_host(dev, addr, atmel_read16(dev, MR2), 6);
eth_hw_addr_set(dev, addr);
/* got address, now squash it again until the network /* got address, now squash it again until the network
interface is opened */ interface is opened */
if (priv->bus_type == BUS_TYPE_PCCARD) if (priv->bus_type == BUS_TYPE_PCCARD)
...@@ -3705,7 +3708,8 @@ static int probe_atmel_card(struct net_device *dev) ...@@ -3705,7 +3708,8 @@ static int probe_atmel_card(struct net_device *dev)
/* Mac address easy in this case. */ /* Mac address easy in this case. */
priv->card_type = CARD_TYPE_PARALLEL_FLASH; priv->card_type = CARD_TYPE_PARALLEL_FLASH;
atmel_write16(dev, BSR, 1); atmel_write16(dev, BSR, 1);
atmel_copy_to_host(dev, dev->dev_addr, 0xc000, 6); atmel_copy_to_host(dev, addr, 0xc000, 6);
eth_hw_addr_set(dev, addr);
atmel_write16(dev, BSR, 0x200); atmel_write16(dev, BSR, 0x200);
rc = 1; rc = 1;
} else { } else {
...@@ -3713,7 +3717,8 @@ static int probe_atmel_card(struct net_device *dev) ...@@ -3713,7 +3717,8 @@ static int probe_atmel_card(struct net_device *dev)
for the Mac Address */ for the Mac Address */
priv->card_type = CARD_TYPE_SPI_FLASH; priv->card_type = CARD_TYPE_SPI_FLASH;
if (atmel_wakeup_firmware(priv) == 0) { if (atmel_wakeup_firmware(priv) == 0) {
atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); atmel_get_mib(priv, Mac_Address_Mib_Type, 0, addr, 6);
eth_hw_addr_set(dev, addr);
/* got address, now squash it again until the network /* got address, now squash it again until the network
interface is opened */ interface is opened */
...@@ -4103,7 +4108,7 @@ static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, ...@@ -4103,7 +4108,7 @@ static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index,
} }
static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index,
u8 *data, int data_len) const u8 *data, int data_len)
{ {
struct get_set_mib m; struct get_set_mib m;
m.type = type; m.type = type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment