diff options
author | Jiri Pirko <jpirko@redhat.com> | 2009-03-13 14:47:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-13 14:47:48 -0400 |
commit | c048aaf4ca854fa67a3bfa9dab5b9ddc5083b3b7 (patch) | |
tree | 78952a5546444d3f79c66a50fa084164c4d422dd /drivers | |
parent | 6fc791ee631728b2beddda87560f1af59e32230e (diff) |
8139cp: allow to set mac address on running device
So far there was not a chance to set a mac address on running 8139cp device.
This is for example needed when you want to use this NIC as a bonding slave in
bonding device in mode balance-alb. This simple patch allows it.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/8139cp.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 35517b06ec3f..a09e3a7cac4f 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -1602,6 +1602,28 @@ static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) | |||
1602 | return rc; | 1602 | return rc; |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | static int cp_set_mac_address(struct net_device *dev, void *p) | ||
1606 | { | ||
1607 | struct cp_private *cp = netdev_priv(dev); | ||
1608 | struct sockaddr *addr = p; | ||
1609 | |||
1610 | if (!is_valid_ether_addr(addr->sa_data)) | ||
1611 | return -EADDRNOTAVAIL; | ||
1612 | |||
1613 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | ||
1614 | |||
1615 | spin_lock_irq(&cp->lock); | ||
1616 | |||
1617 | cpw8_f(Cfg9346, Cfg9346_Unlock); | ||
1618 | cpw32_f(MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); | ||
1619 | cpw32_f(MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); | ||
1620 | cpw8_f(Cfg9346, Cfg9346_Lock); | ||
1621 | |||
1622 | spin_unlock_irq(&cp->lock); | ||
1623 | |||
1624 | return 0; | ||
1625 | } | ||
1626 | |||
1605 | /* Serial EEPROM section. */ | 1627 | /* Serial EEPROM section. */ |
1606 | 1628 | ||
1607 | /* EEPROM_Ctrl bits. */ | 1629 | /* EEPROM_Ctrl bits. */ |
@@ -1821,7 +1843,7 @@ static const struct net_device_ops cp_netdev_ops = { | |||
1821 | .ndo_open = cp_open, | 1843 | .ndo_open = cp_open, |
1822 | .ndo_stop = cp_close, | 1844 | .ndo_stop = cp_close, |
1823 | .ndo_validate_addr = eth_validate_addr, | 1845 | .ndo_validate_addr = eth_validate_addr, |
1824 | .ndo_set_mac_address = eth_mac_addr, | 1846 | .ndo_set_mac_address = cp_set_mac_address, |
1825 | .ndo_set_multicast_list = cp_set_rx_mode, | 1847 | .ndo_set_multicast_list = cp_set_rx_mode, |
1826 | .ndo_get_stats = cp_get_stats, | 1848 | .ndo_get_stats = cp_get_stats, |
1827 | .ndo_do_ioctl = cp_ioctl, | 1849 | .ndo_do_ioctl = cp_ioctl, |