Commit 2b373670 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

ethernet: forcedeth: remove direct netdev->dev_addr writes

forcedeth writes to dev_addr byte by byte, make it use
a local buffer instead. Commit the changes with
eth_hw_addr_set() at the end.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarZhu Yanjun <zyjzyj2000@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f12e658c
...@@ -5711,6 +5711,7 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) ...@@ -5711,6 +5711,7 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
u32 phystate_orig = 0, phystate; u32 phystate_orig = 0, phystate;
int phyinitialized = 0; int phyinitialized = 0;
static int printed_version; static int printed_version;
u8 mac[ETH_ALEN];
if (!printed_version++) if (!printed_version++)
pr_info("Reverse Engineered nForce ethernet driver. Version %s.\n", pr_info("Reverse Engineered nForce ethernet driver. Version %s.\n",
...@@ -5884,50 +5885,52 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) ...@@ -5884,50 +5885,52 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
txreg = readl(base + NvRegTransmitPoll); txreg = readl(base + NvRegTransmitPoll);
if (id->driver_data & DEV_HAS_CORRECT_MACADDR) { if (id->driver_data & DEV_HAS_CORRECT_MACADDR) {
/* mac address is already in correct order */ /* mac address is already in correct order */
dev->dev_addr[0] = (np->orig_mac[0] >> 0) & 0xff; mac[0] = (np->orig_mac[0] >> 0) & 0xff;
dev->dev_addr[1] = (np->orig_mac[0] >> 8) & 0xff; mac[1] = (np->orig_mac[0] >> 8) & 0xff;
dev->dev_addr[2] = (np->orig_mac[0] >> 16) & 0xff; mac[2] = (np->orig_mac[0] >> 16) & 0xff;
dev->dev_addr[3] = (np->orig_mac[0] >> 24) & 0xff; mac[3] = (np->orig_mac[0] >> 24) & 0xff;
dev->dev_addr[4] = (np->orig_mac[1] >> 0) & 0xff; mac[4] = (np->orig_mac[1] >> 0) & 0xff;
dev->dev_addr[5] = (np->orig_mac[1] >> 8) & 0xff; mac[5] = (np->orig_mac[1] >> 8) & 0xff;
} else if (txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV) { } else if (txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV) {
/* mac address is already in correct order */ /* mac address is already in correct order */
dev->dev_addr[0] = (np->orig_mac[0] >> 0) & 0xff; mac[0] = (np->orig_mac[0] >> 0) & 0xff;
dev->dev_addr[1] = (np->orig_mac[0] >> 8) & 0xff; mac[1] = (np->orig_mac[0] >> 8) & 0xff;
dev->dev_addr[2] = (np->orig_mac[0] >> 16) & 0xff; mac[2] = (np->orig_mac[0] >> 16) & 0xff;
dev->dev_addr[3] = (np->orig_mac[0] >> 24) & 0xff; mac[3] = (np->orig_mac[0] >> 24) & 0xff;
dev->dev_addr[4] = (np->orig_mac[1] >> 0) & 0xff; mac[4] = (np->orig_mac[1] >> 0) & 0xff;
dev->dev_addr[5] = (np->orig_mac[1] >> 8) & 0xff; mac[5] = (np->orig_mac[1] >> 8) & 0xff;
/* /*
* Set orig mac address back to the reversed version. * Set orig mac address back to the reversed version.
* This flag will be cleared during low power transition. * This flag will be cleared during low power transition.
* Therefore, we should always put back the reversed address. * Therefore, we should always put back the reversed address.
*/ */
np->orig_mac[0] = (dev->dev_addr[5] << 0) + (dev->dev_addr[4] << 8) + np->orig_mac[0] = (mac[5] << 0) + (mac[4] << 8) +
(dev->dev_addr[3] << 16) + (dev->dev_addr[2] << 24); (mac[3] << 16) + (mac[2] << 24);
np->orig_mac[1] = (dev->dev_addr[1] << 0) + (dev->dev_addr[0] << 8); np->orig_mac[1] = (mac[1] << 0) + (mac[0] << 8);
} else { } else {
/* need to reverse mac address to correct order */ /* need to reverse mac address to correct order */
dev->dev_addr[0] = (np->orig_mac[1] >> 8) & 0xff; mac[0] = (np->orig_mac[1] >> 8) & 0xff;
dev->dev_addr[1] = (np->orig_mac[1] >> 0) & 0xff; mac[1] = (np->orig_mac[1] >> 0) & 0xff;
dev->dev_addr[2] = (np->orig_mac[0] >> 24) & 0xff; mac[2] = (np->orig_mac[0] >> 24) & 0xff;
dev->dev_addr[3] = (np->orig_mac[0] >> 16) & 0xff; mac[3] = (np->orig_mac[0] >> 16) & 0xff;
dev->dev_addr[4] = (np->orig_mac[0] >> 8) & 0xff; mac[4] = (np->orig_mac[0] >> 8) & 0xff;
dev->dev_addr[5] = (np->orig_mac[0] >> 0) & 0xff; mac[5] = (np->orig_mac[0] >> 0) & 0xff;
writel(txreg|NVREG_TRANSMITPOLL_MAC_ADDR_REV, base + NvRegTransmitPoll); writel(txreg|NVREG_TRANSMITPOLL_MAC_ADDR_REV, base + NvRegTransmitPoll);
dev_dbg(&pci_dev->dev, dev_dbg(&pci_dev->dev,
"%s: set workaround bit for reversed mac addr\n", "%s: set workaround bit for reversed mac addr\n",
__func__); __func__);
} }
if (!is_valid_ether_addr(dev->dev_addr)) { if (is_valid_ether_addr(mac)) {
eth_hw_addr_set(dev, mac);
} else {
/* /*
* Bad mac address. At least one bios sets the mac address * Bad mac address. At least one bios sets the mac address
* to 01:23:45:67:89:ab * to 01:23:45:67:89:ab
*/ */
dev_err(&pci_dev->dev, dev_err(&pci_dev->dev,
"Invalid MAC address detected: %pM - Please complain to your hardware vendor.\n", "Invalid MAC address detected: %pM - Please complain to your hardware vendor.\n",
dev->dev_addr); mac);
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
dev_err(&pci_dev->dev, dev_err(&pci_dev->dev,
"Using random MAC address: %pM\n", dev->dev_addr); "Using random MAC address: %pM\n", dev->dev_addr);
......
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