1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 03:13:20 +02:00

ramips_eth: cleanup mac_address changing

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19464 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2010-01-31 17:56:36 +00:00
parent 1ca6778f34
commit c60a96964d

View File

@ -69,6 +69,14 @@ ramips_fe_int_enable(u32 mask)
ramips_fe_rr(RAMIPS_FE_INT_ENABLE);
}
static inline void
ramips_hw_set_macaddr(unsigned char *mac)
{
ramips_fe_wr((mac[0] << 8) | mac[1], RAMIPS_GDMA1_MAC_ADRH);
ramips_fe_wr((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5],
RAMIPS_GDMA1_MAC_ADRL);
}
static void
ramips_cleanup_dma(struct raeth_priv *re)
{
@ -268,21 +276,6 @@ ramips_eth_tx_housekeeping(unsigned long ptr)
ramips_fe_int_enable(RAMIPS_TX_DLY_INT);
}
static int
ramips_eth_set_mac_addr(struct net_device *dev, void *priv)
{
unsigned char *mac = priv;
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, ((struct sockaddr*)priv)->sa_data, dev->addr_len);
ramips_fe_wr((mac[0] << 8) | mac[1], RAMIPS_GDMA1_MAC_ADRH);
ramips_fe_wr((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5],
RAMIPS_GDMA1_MAC_ADRL);
return 0;
}
static void
ramips_eth_timeout(struct net_device *dev)
{
@ -325,6 +318,8 @@ ramips_eth_open(struct net_device *dev)
if (err)
goto err_free_irq;
ramips_hw_set_macaddr(dev->dev_addr);
ramips_setup_dma(priv);
ramips_fe_wr((ramips_fe_rr(RAMIPS_PDMA_GLO_CFG) & 0xff) |
(RAMIPS_TX_WB_DDONE | RAMIPS_RX_DMA_EN |
@ -380,13 +375,11 @@ static int __init
ramips_eth_probe(struct net_device *dev)
{
struct raeth_priv *priv = netdev_priv(dev);
struct sockaddr addr;
BUG_ON(!priv->plat->reset_fe);
priv->plat->reset_fe();
net_srandom(jiffies);
memcpy(addr.sa_data, priv->plat->mac, 6);
ramips_eth_set_mac_addr(dev, &addr);
memcpy(dev->dev_addr, priv->plat->mac, ETH_ALEN);
ether_setup(dev);
dev->mtu = 1500;
@ -403,7 +396,7 @@ static const struct net_device_ops ramips_eth_netdev_ops = {
.ndo_start_xmit = ramips_eth_hard_start_xmit,
.ndo_tx_timeout = ramips_eth_timeout,
.ndo_change_mtu = eth_change_mtu,
.ndo_set_mac_address = ramips_eth_set_mac_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};