aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Vandeginste <snowbender@gmail.com>2007-03-26 17:43:49 -0400
committerDavid S. Miller <davem@davemloft.net>2007-03-26 17:43:49 -0400
commit09c72ec8ed8f7499d115309a6e19cd5e66808d88 (patch)
tree0459dca4e9b04f8f44c914af744e940da5edb36a
parentd562f1f8a92035d5d4681c178fccb991ce57f33a (diff)
[SUNGEM]: Fix MAC address setting when interface is up.
This patch implements set_mac_address for the sungem driver. This allows changing the mac address of the interface, even when the interface is up. Signed-off-by: Ruben Vandeginste <snowbender@gmail.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/sungem.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 616be8d0fa85..08ea61db46fe 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2530,6 +2530,35 @@ static struct net_device_stats *gem_get_stats(struct net_device *dev)
2530 return &gp->net_stats; 2530 return &gp->net_stats;
2531} 2531}
2532 2532
2533static int gem_set_mac_address(struct net_device *dev, void *addr)
2534{
2535 struct sockaddr *macaddr = (struct sockaddr *) addr;
2536 struct gem *gp = dev->priv;
2537 unsigned char *e = &dev->dev_addr[0];
2538
2539 if (!is_valid_ether_addr(macaddr->sa_data))
2540 return -EADDRNOTAVAIL;
2541
2542 if (!netif_running(dev) || !netif_device_present(dev)) {
2543 /* We'll just catch it later when the
2544 * device is up'd or resumed.
2545 */
2546 memcpy(dev->dev_addr, macaddr->sa_data, dev->addr_len);
2547 return 0;
2548 }
2549
2550 mutex_lock(&gp->pm_mutex);
2551 memcpy(dev->dev_addr, macaddr->sa_data, dev->addr_len);
2552 if (gp->running) {
2553 writel((e[4] << 8) | e[5], gp->regs + MAC_ADDR0);
2554 writel((e[2] << 8) | e[3], gp->regs + MAC_ADDR1);
2555 writel((e[0] << 8) | e[1], gp->regs + MAC_ADDR2);
2556 }
2557 mutex_unlock(&gp->pm_mutex);
2558
2559 return 0;
2560}
2561
2533static void gem_set_multicast(struct net_device *dev) 2562static void gem_set_multicast(struct net_device *dev)
2534{ 2563{
2535 struct gem *gp = dev->priv; 2564 struct gem *gp = dev->priv;
@@ -3122,6 +3151,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3122 dev->change_mtu = gem_change_mtu; 3151 dev->change_mtu = gem_change_mtu;
3123 dev->irq = pdev->irq; 3152 dev->irq = pdev->irq;
3124 dev->dma = 0; 3153 dev->dma = 0;
3154 dev->set_mac_address = gem_set_mac_address;
3125#ifdef CONFIG_NET_POLL_CONTROLLER 3155#ifdef CONFIG_NET_POLL_CONTROLLER
3126 dev->poll_controller = gem_poll_controller; 3156 dev->poll_controller = gem_poll_controller;
3127#endif 3157#endif