]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Blackfin EMAC driver: add function to change the MAC address
authorAlex Landau <lirsb@yahoo.com>
Wed, 19 Sep 2007 15:14:18 +0000 (23:14 +0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:51:48 +0000 (16:51 -0700)
Alex Landau writes in the forums:
 Previously, changing the MAC address (e.g. via ifconfig) resulted
 in a generic function to be called that only changed a variable in
 memory. This patch also updated the Blackfin MAC address registers
 to filter the correct new MAC.

Signed-off-by: Alex Landau <lirsb@yahoo.com>
Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/bfin_mac.c

index cebe55440e13227f959bc7d0ba083fa08f8c46b9..ead7be9699752ba3a2b4c436ba2f9bf477a52d9d 100644 (file)
@@ -463,7 +463,7 @@ void setup_system_regs(struct net_device *dev)
        bfin_write_DMA1_Y_MODIFY(0);
 }
 
-void setup_mac_addr(u8 * mac_addr)
+static void setup_mac_addr(u8 *mac_addr)
 {
        u32 addr_low = le32_to_cpu(*(__le32 *) & mac_addr[0]);
        u16 addr_hi = le16_to_cpu(*(__le16 *) & mac_addr[4]);
@@ -473,6 +473,16 @@ void setup_mac_addr(u8 * mac_addr)
        bfin_write_EMAC_ADDRHI(addr_hi);
 }
 
+static int bf537mac_set_mac_address(struct net_device *dev, void *p)
+{
+       struct sockaddr *addr = p;
+       if (netif_running(dev))
+               return -EBUSY;
+       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+       setup_mac_addr(dev->dev_addr);
+       return 0;
+}
+
 static void adjust_tx_list(void)
 {
        int timeout_cnt = MAX_TIMEOUT_CNT;
@@ -876,6 +886,7 @@ static int __init bf537mac_probe(struct net_device *dev)
        dev->open = bf537mac_open;
        dev->stop = bf537mac_close;
        dev->hard_start_xmit = bf537mac_hard_start_xmit;
+       dev->set_mac_address = bf537mac_set_mac_address;
        dev->tx_timeout = bf537mac_timeout;
        dev->set_multicast_list = bf537mac_set_multicast_list;
 #ifdef CONFIG_NET_POLL_CONTROLLER