mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
Merge branch 'dev_addr-conversions-part-two'
Jakub Kicinski says: ==================== ethernet: manual netdev->dev_addr conversions (part 2) Manual conversions of Ethernet drivers writing directly to netdev->dev_addr (part 2 out of 3). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
867a92846e
16 changed files with 80 additions and 45 deletions
|
@ -2925,10 +2925,14 @@ static void set_params(struct mv643xx_eth_private *mp,
|
|||
struct net_device *dev = mp->dev;
|
||||
unsigned int tx_ring_size;
|
||||
|
||||
if (is_valid_ether_addr(pd->mac_addr))
|
||||
if (is_valid_ether_addr(pd->mac_addr)) {
|
||||
eth_hw_addr_set(dev, pd->mac_addr);
|
||||
else
|
||||
uc_addr_get(mp, dev->dev_addr);
|
||||
} else {
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
uc_addr_get(mp, addr);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
}
|
||||
|
||||
mp->rx_ring_size = DEFAULT_RX_QUEUE_SIZE;
|
||||
if (pd->rx_queue_size)
|
||||
|
|
|
@ -3810,6 +3810,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
|
|||
{
|
||||
struct skge_port *skge;
|
||||
struct net_device *dev = alloc_etherdev(sizeof(*skge));
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
@ -3862,7 +3863,8 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
|
|||
}
|
||||
|
||||
/* read the mac address */
|
||||
memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN);
|
||||
memcpy_fromio(addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
|
|
@ -4721,9 +4721,12 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
|
|||
* 2) from internal registers set by bootloader
|
||||
*/
|
||||
ret = of_get_ethdev_address(hw->pdev->dev.of_node, dev);
|
||||
if (ret)
|
||||
memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
|
||||
ETH_ALEN);
|
||||
if (ret) {
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
memcpy_fromio(addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
}
|
||||
|
||||
/* if the address is invalid, use a random value */
|
||||
if (!is_valid_ether_addr(dev->dev_addr)) {
|
||||
|
|
|
@ -1232,6 +1232,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
|
|||
struct net_device *ndev;
|
||||
dma_addr_t dma_handle;
|
||||
struct resource *res;
|
||||
u8 addr[ETH_ALEN];
|
||||
int irq, ret;
|
||||
|
||||
/* Setup network interface for RMII or MII mode */
|
||||
|
@ -1347,7 +1348,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
|
|||
pldat->phy_node = of_parse_phandle(np, "phy-handle", 0);
|
||||
|
||||
/* Get MAC address from current HW setting (POR state is all zeros) */
|
||||
__lpc_get_mac(pldat, ndev->dev_addr);
|
||||
__lpc_get_mac(pldat, addr);
|
||||
eth_hw_addr_set(ndev, addr);
|
||||
|
||||
if (!is_valid_ether_addr(ndev->dev_addr)) {
|
||||
of_get_ethdev_address(np, ndev);
|
||||
|
|
|
@ -463,6 +463,7 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
|
|||
u64 mac_addr;
|
||||
struct net_device *netdev = adapter->netdev;
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
|
||||
if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0)
|
||||
|
@ -474,7 +475,8 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
|
|||
|
||||
p = (unsigned char *)&mac_addr;
|
||||
for (i = 0; i < 6; i++)
|
||||
netdev->dev_addr[i] = *(p + 5 - i);
|
||||
addr[i] = *(p + 5 - i);
|
||||
eth_hw_addr_set(netdev, addr);
|
||||
|
||||
memcpy(adapter->mac_addr, netdev->dev_addr, netdev->addr_len);
|
||||
|
||||
|
|
|
@ -5217,7 +5217,7 @@ static int rtl_get_ether_clk(struct rtl8169_private *tp)
|
|||
static void rtl_init_mac_address(struct rtl8169_private *tp)
|
||||
{
|
||||
struct net_device *dev = tp->dev;
|
||||
u8 *mac_addr = dev->dev_addr;
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
int rc;
|
||||
|
||||
rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
|
||||
|
@ -5235,6 +5235,7 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
|
|||
eth_hw_addr_random(dev);
|
||||
dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
|
||||
done:
|
||||
eth_hw_addr_set(dev, mac_addr);
|
||||
rtl_rar_set(tp, mac_addr);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,13 +136,15 @@ static void ravb_read_mac_address(struct device_node *np,
|
|||
if (ret) {
|
||||
u32 mahr = ravb_read(ndev, MAHR);
|
||||
u32 malr = ravb_read(ndev, MALR);
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
ndev->dev_addr[0] = (mahr >> 24) & 0xFF;
|
||||
ndev->dev_addr[1] = (mahr >> 16) & 0xFF;
|
||||
ndev->dev_addr[2] = (mahr >> 8) & 0xFF;
|
||||
ndev->dev_addr[3] = (mahr >> 0) & 0xFF;
|
||||
ndev->dev_addr[4] = (malr >> 8) & 0xFF;
|
||||
ndev->dev_addr[5] = (malr >> 0) & 0xFF;
|
||||
addr[0] = (mahr >> 24) & 0xFF;
|
||||
addr[1] = (mahr >> 16) & 0xFF;
|
||||
addr[2] = (mahr >> 8) & 0xFF;
|
||||
addr[3] = (mahr >> 0) & 0xFF;
|
||||
addr[4] = (malr >> 8) & 0xFF;
|
||||
addr[5] = (malr >> 0) & 0xFF;
|
||||
eth_hw_addr_set(ndev, addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1157,13 +1157,15 @@ static void read_mac_address(struct net_device *ndev, unsigned char *mac)
|
|||
} else {
|
||||
u32 mahr = sh_eth_read(ndev, MAHR);
|
||||
u32 malr = sh_eth_read(ndev, MALR);
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
ndev->dev_addr[0] = (mahr >> 24) & 0xFF;
|
||||
ndev->dev_addr[1] = (mahr >> 16) & 0xFF;
|
||||
ndev->dev_addr[2] = (mahr >> 8) & 0xFF;
|
||||
ndev->dev_addr[3] = (mahr >> 0) & 0xFF;
|
||||
ndev->dev_addr[4] = (malr >> 8) & 0xFF;
|
||||
ndev->dev_addr[5] = (malr >> 0) & 0xFF;
|
||||
addr[0] = (mahr >> 24) & 0xFF;
|
||||
addr[1] = (mahr >> 16) & 0xFF;
|
||||
addr[2] = (mahr >> 8) & 0xFF;
|
||||
addr[3] = (mahr >> 0) & 0xFF;
|
||||
addr[4] = (malr >> 8) & 0xFF;
|
||||
addr[5] = (malr >> 0) & 0xFF;
|
||||
eth_hw_addr_set(ndev, addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2545,11 +2545,13 @@ static void rocker_port_dev_addr_init(struct rocker_port *rocker_port)
|
|||
{
|
||||
const struct rocker *rocker = rocker_port->rocker;
|
||||
const struct pci_dev *pdev = rocker->pdev;
|
||||
u8 addr[ETH_ALEN];
|
||||
int err;
|
||||
|
||||
err = rocker_cmd_get_port_settings_macaddr(rocker_port,
|
||||
rocker_port->dev->dev_addr);
|
||||
if (err) {
|
||||
err = rocker_cmd_get_port_settings_macaddr(rocker_port, addr);
|
||||
if (!err) {
|
||||
eth_hw_addr_set(rocker_port->dev, addr);
|
||||
} else {
|
||||
dev_warn(&pdev->dev, "failed to get mac address, using random\n");
|
||||
eth_hw_addr_random(rocker_port->dev);
|
||||
}
|
||||
|
|
|
@ -931,10 +931,13 @@ static int sxgbe_get_hw_features(struct sxgbe_priv_data * const priv)
|
|||
static void sxgbe_check_ether_addr(struct sxgbe_priv_data *priv)
|
||||
{
|
||||
if (!is_valid_ether_addr(priv->dev->dev_addr)) {
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
priv->hw->mac->get_umac_addr((void __iomem *)
|
||||
priv->ioaddr,
|
||||
priv->dev->dev_addr, 0);
|
||||
if (!is_valid_ether_addr(priv->dev->dev_addr))
|
||||
priv->ioaddr, addr, 0);
|
||||
if (is_valid_ether_addr(addr))
|
||||
eth_hw_addr_set(priv->dev, addr);
|
||||
else
|
||||
eth_hw_addr_random(priv->dev);
|
||||
}
|
||||
dev_info(priv->device, "device MAC address %pM\n",
|
||||
|
|
|
@ -1631,6 +1631,7 @@ static int sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
|
|||
static const u16 ids[] = { 0x0965, 0x0966, 0x0968 };
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct pci_dev *isa_bridge;
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 reg, tmp8;
|
||||
unsigned int i;
|
||||
|
||||
|
@ -1659,8 +1660,9 @@ static int sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
|
|||
|
||||
for (i = 0; i < ETH_ALEN; i++) {
|
||||
outb(0x9 + i, 0x78);
|
||||
dev->dev_addr[i] = inb(0x79);
|
||||
addr[i] = inb(0x79);
|
||||
}
|
||||
eth_hw_addr_set(dev, addr);
|
||||
|
||||
outb(0x12, 0x78);
|
||||
reg = inb(0x79);
|
||||
|
|
|
@ -292,6 +292,7 @@ static int sis630e_get_mac_addr(struct pci_dev *pci_dev,
|
|||
struct net_device *net_dev)
|
||||
{
|
||||
struct pci_dev *isa_bridge = NULL;
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 reg;
|
||||
int i;
|
||||
|
||||
|
@ -308,8 +309,9 @@ static int sis630e_get_mac_addr(struct pci_dev *pci_dev,
|
|||
|
||||
for (i = 0; i < 6; i++) {
|
||||
outb(0x09 + i, 0x70);
|
||||
((u8 *)(net_dev->dev_addr))[i] = inb(0x71);
|
||||
addr[i] = inb(0x71);
|
||||
}
|
||||
eth_hw_addr_set(net_dev, addr);
|
||||
|
||||
pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40);
|
||||
pci_dev_put(isa_bridge);
|
||||
|
|
|
@ -1788,6 +1788,7 @@ static int smc911x_probe(struct net_device *dev)
|
|||
struct dma_slave_config config;
|
||||
dma_cap_mask_t mask;
|
||||
#endif
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
|
||||
|
||||
|
@ -1892,7 +1893,8 @@ static int smc911x_probe(struct net_device *dev)
|
|||
spin_lock_init(&lp->lock);
|
||||
|
||||
/* Get the MAC address */
|
||||
SMC_GET_MAC_ADDR(lp, dev->dev_addr);
|
||||
SMC_GET_MAC_ADDR(lp, addr);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
|
||||
/* now, reset the chip, and put it into a known state */
|
||||
smc911x_reset(dev);
|
||||
|
|
|
@ -1851,6 +1851,7 @@ static int smc_probe(struct net_device *dev, void __iomem *ioaddr,
|
|||
int retval;
|
||||
unsigned int val, revision_register;
|
||||
const char *version_string;
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
|
||||
|
||||
|
@ -1922,7 +1923,8 @@ static int smc_probe(struct net_device *dev, void __iomem *ioaddr,
|
|||
|
||||
/* Get the MAC address */
|
||||
SMC_SELECT_BANK(lp, 1);
|
||||
SMC_GET_MAC_ADDR(lp, dev->dev_addr);
|
||||
SMC_GET_MAC_ADDR(lp, addr);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
|
||||
/* now, reset the chip, and put it into a known state */
|
||||
smc_reset(dev);
|
||||
|
|
|
@ -2162,13 +2162,15 @@ static void smsc911x_read_mac_address(struct net_device *dev)
|
|||
struct smsc911x_data *pdata = netdev_priv(dev);
|
||||
u32 mac_high16 = smsc911x_mac_read(pdata, ADDRH);
|
||||
u32 mac_low32 = smsc911x_mac_read(pdata, ADDRL);
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
dev->dev_addr[0] = (u8)(mac_low32);
|
||||
dev->dev_addr[1] = (u8)(mac_low32 >> 8);
|
||||
dev->dev_addr[2] = (u8)(mac_low32 >> 16);
|
||||
dev->dev_addr[3] = (u8)(mac_low32 >> 24);
|
||||
dev->dev_addr[4] = (u8)(mac_high16);
|
||||
dev->dev_addr[5] = (u8)(mac_high16 >> 8);
|
||||
addr[0] = (u8)(mac_low32);
|
||||
addr[1] = (u8)(mac_low32 >> 8);
|
||||
addr[2] = (u8)(mac_low32 >> 16);
|
||||
addr[3] = (u8)(mac_low32 >> 24);
|
||||
addr[4] = (u8)(mac_high16);
|
||||
addr[5] = (u8)(mac_high16 >> 8);
|
||||
eth_hw_addr_set(dev, addr);
|
||||
}
|
||||
|
||||
/* Initializing private device structures, only called from probe */
|
||||
|
|
|
@ -416,6 +416,7 @@ static void smsc9420_set_mac_address(struct net_device *dev)
|
|||
static void smsc9420_check_mac_address(struct net_device *dev)
|
||||
{
|
||||
struct smsc9420_pdata *pd = netdev_priv(dev);
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
/* Check if mac address has been specified when bringing interface up */
|
||||
if (is_valid_ether_addr(dev->dev_addr)) {
|
||||
|
@ -427,15 +428,16 @@ static void smsc9420_check_mac_address(struct net_device *dev)
|
|||
* it will already have been set */
|
||||
u32 mac_high16 = smsc9420_reg_read(pd, ADDRH);
|
||||
u32 mac_low32 = smsc9420_reg_read(pd, ADDRL);
|
||||
dev->dev_addr[0] = (u8)(mac_low32);
|
||||
dev->dev_addr[1] = (u8)(mac_low32 >> 8);
|
||||
dev->dev_addr[2] = (u8)(mac_low32 >> 16);
|
||||
dev->dev_addr[3] = (u8)(mac_low32 >> 24);
|
||||
dev->dev_addr[4] = (u8)(mac_high16);
|
||||
dev->dev_addr[5] = (u8)(mac_high16 >> 8);
|
||||
addr[0] = (u8)(mac_low32);
|
||||
addr[1] = (u8)(mac_low32 >> 8);
|
||||
addr[2] = (u8)(mac_low32 >> 16);
|
||||
addr[3] = (u8)(mac_low32 >> 24);
|
||||
addr[4] = (u8)(mac_high16);
|
||||
addr[5] = (u8)(mac_high16 >> 8);
|
||||
|
||||
if (is_valid_ether_addr(dev->dev_addr)) {
|
||||
if (is_valid_ether_addr(addr)) {
|
||||
/* eeprom values are valid so use them */
|
||||
eth_hw_addr_set(dev, addr);
|
||||
netif_dbg(pd, probe, pd->dev,
|
||||
"Mac Address is read from EEPROM\n");
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue