Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277964
b: refs/heads/master
c: a9a8de2
h: refs/heads/master
v: v3
  • Loading branch information
Ben Dooks authored and David S. Miller committed Nov 26, 2011
1 parent 1856fd3 commit 41829bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 072bc80156729f853e8bcafe1b17c48c74462887
refs/heads/master: a9a8de214c91eecf596b3e79c7986b74ef17f4ec
41 changes: 34 additions & 7 deletions trunk/drivers/net/ethernet/micrel/ks8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,48 @@ static int ks8851_write_mac_addr(struct net_device *dev)
return 0;
}

/**
* ks8851_read_mac_addr - read mac address from device registers
* @dev: The network device
*
* Update our copy of the KS8851 MAC address from the registers of @dev.
*/
static void ks8851_read_mac_addr(struct net_device *dev)
{
struct ks8851_net *ks = netdev_priv(dev);
int i;

mutex_lock(&ks->lock);

for (i = 0; i < ETH_ALEN; i++)
dev->dev_addr[i] = ks8851_rdreg8(ks, KS_MAR(i));

mutex_unlock(&ks->lock);
}

/**
* ks8851_init_mac - initialise the mac address
* @ks: The device structure
*
* Get or create the initial mac address for the device and then set that
* into the station address register. Currently we assume that the device
* does not have a valid mac address in it, and so we use random_ether_addr()
* into the station address register. If there is an EEPROM present, then
* we try that. If no valid mac address is found we use random_ether_addr()
* to create a new one.
*
* In future, the driver should check to see if the device has an EEPROM
* attached and whether that has a valid ethernet address in it.
*/
static void ks8851_init_mac(struct ks8851_net *ks)
{
struct net_device *dev = ks->netdev;

/* first, try reading what we've got already */
if (ks->rc_ccr & CCR_EEPROM) {
ks8851_read_mac_addr(dev);
if (is_valid_ether_addr(dev->dev_addr))
return;

netdev_err(ks->netdev, "invalid mac address read %pM\n",
dev->dev_addr);
}

random_ether_addr(dev->dev_addr);
ks8851_write_mac_addr(dev);
}
Expand Down Expand Up @@ -1674,9 +1700,10 @@ static int __devinit ks8851_probe(struct spi_device *spi)
goto err_netdev;
}

netdev_info(ndev, "revision %d, MAC %pM, IRQ %d\n",
netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n",
CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
ndev->dev_addr, ndev->irq);
ndev->dev_addr, ndev->irq,
ks->rc_ccr & CCR_EEPROM ? "has" : "no");

return 0;

Expand Down

0 comments on commit 41829bf

Please sign in to comment.