aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ucc_geth.c
diff options
context:
space:
mode:
authorKevin Hao <kexin.hao@windriver.com>2009-05-26 23:49:03 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-26 23:49:03 -0400
commit3d6593e9cc40d0eacc03f75f90834794a4a477df (patch)
tree81bca4e8a94fc798aa870e7470cf0b1405744419 /drivers/net/ucc_geth.c
parent9c5cd6708008fcc3dbced6e4b97aa5ecd0634a85 (diff)
net/ucc_geth: allow to set mac address on running device
Inspired by the patch for 8139too (bda6a15a). Currently we can't set mac address on a running ucc_geth device. But this is needed when you use this device as a bonding slave in bonding device in balance-alb mode. So add this feature for ucc_geth device. Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ucc_geth.c')
-rw-r--r--drivers/net/ucc_geth.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index f18017dc0255..0cf22c4f123b 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3325,6 +3325,37 @@ static void ucc_netpoll(struct net_device *dev)
3325} 3325}
3326#endif /* CONFIG_NET_POLL_CONTROLLER */ 3326#endif /* CONFIG_NET_POLL_CONTROLLER */
3327 3327
3328static int ucc_geth_set_mac_addr(struct net_device *dev, void *p)
3329{
3330 struct ucc_geth_private *ugeth = netdev_priv(dev);
3331 struct sockaddr *addr = p;
3332
3333 if (!is_valid_ether_addr(addr->sa_data))
3334 return -EADDRNOTAVAIL;
3335
3336 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
3337
3338 /*
3339 * If device is not running, we will set mac addr register
3340 * when opening the device.
3341 */
3342 if (!netif_running(dev))
3343 return 0;
3344
3345 spin_lock_irq(&ugeth->lock);
3346 init_mac_station_addr_regs(dev->dev_addr[0],
3347 dev->dev_addr[1],
3348 dev->dev_addr[2],
3349 dev->dev_addr[3],
3350 dev->dev_addr[4],
3351 dev->dev_addr[5],
3352 &ugeth->ug_regs->macstnaddr1,
3353 &ugeth->ug_regs->macstnaddr2);
3354 spin_unlock_irq(&ugeth->lock);
3355
3356 return 0;
3357}
3358
3328/* Called when something needs to use the ethernet device */ 3359/* Called when something needs to use the ethernet device */
3329/* Returns 0 for success. */ 3360/* Returns 0 for success. */
3330static int ucc_geth_open(struct net_device *dev) 3361static int ucc_geth_open(struct net_device *dev)
@@ -3501,7 +3532,7 @@ static const struct net_device_ops ucc_geth_netdev_ops = {
3501 .ndo_stop = ucc_geth_close, 3532 .ndo_stop = ucc_geth_close,
3502 .ndo_start_xmit = ucc_geth_start_xmit, 3533 .ndo_start_xmit = ucc_geth_start_xmit,
3503 .ndo_validate_addr = eth_validate_addr, 3534 .ndo_validate_addr = eth_validate_addr,
3504 .ndo_set_mac_address = eth_mac_addr, 3535 .ndo_set_mac_address = ucc_geth_set_mac_addr,
3505 .ndo_change_mtu = eth_change_mtu, 3536 .ndo_change_mtu = eth_change_mtu,
3506 .ndo_set_multicast_list = ucc_geth_set_multi, 3537 .ndo_set_multicast_list = ucc_geth_set_multi,
3507 .ndo_tx_timeout = ucc_geth_timeout, 3538 .ndo_tx_timeout = ucc_geth_timeout,