Commit c90834cd authored by Tim Harvey's avatar Tim Harvey Committed by David S. Miller

lan743x: allow mac address to come from dt

If a valid mac address is present in dt, use that before using
CSR's or a random mac address.
Signed-off-by: default avatarTim Harvey <tharvey@gateworks.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8d8b238
......@@ -15,6 +15,7 @@
#include <linux/rtnetlink.h>
#include <linux/iopoll.h>
#include <linux/crc16.h>
#include <linux/of_net.h>
#include "lan743x_main.h"
#include "lan743x_ethtool.h"
......@@ -807,6 +808,7 @@ static int lan743x_mac_init(struct lan743x_adapter *adapter)
data |= MAC_CR_CNTR_RST_;
lan743x_csr_write(adapter, MAC_CR, data);
if (!is_valid_ether_addr(adapter->mac_address)) {
mac_addr_hi = lan743x_csr_read(adapter, MAC_RX_ADDRH);
mac_addr_lo = lan743x_csr_read(adapter, MAC_RX_ADDRL);
adapter->mac_address[0] = mac_addr_lo & 0xFF;
......@@ -825,8 +827,10 @@ static int lan743x_mac_init(struct lan743x_adapter *adapter)
if (!mac_address_valid)
eth_random_addr(adapter->mac_address);
}
lan743x_mac_set_address(adapter, adapter->mac_address);
ether_addr_copy(netdev->dev_addr, adapter->mac_address);
return 0;
}
......@@ -2817,6 +2821,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
{
struct lan743x_adapter *adapter = NULL;
struct net_device *netdev = NULL;
const void *mac_addr;
int ret = -ENODEV;
netdev = devm_alloc_etherdev(&pdev->dev,
......@@ -2833,6 +2838,10 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED;
netdev->max_mtu = LAN743X_MAX_FRAME_SIZE;
mac_addr = of_get_mac_address(pdev->dev.of_node);
if (!IS_ERR(mac_addr))
ether_addr_copy(adapter->mac_address, mac_addr);
ret = lan743x_pci_init(adapter, pdev);
if (ret)
goto return_error;
......
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