Skip to content

Commit

Permalink
[NET]: Introduce and use print_mac() and DECLARE_MAC_BUF()
Browse files Browse the repository at this point in the history
This is nicer than the MAC_FMT stuff.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
JoePerches authored and David S. Miller committed Oct 10, 2007
1 parent 95ea362 commit 0795af5
Show file tree
Hide file tree
Showing 228 changed files with 1,875 additions and 1,952 deletions.
4 changes: 3 additions & 1 deletion drivers/net/3c503.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
static unsigned version_printed;
unsigned long vendor_id;
DECLARE_MAC_BUF(mac);

if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
return -EBUSY;
Expand Down Expand Up @@ -226,7 +227,8 @@ el2_probe1(struct net_device *dev, int ioaddr)

/* Retrieve and print the ethernet address. */
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
dev->dev_addr[i] = inb(ioaddr + i);
printk("%s", print_mac(mac, dev->dev_addr));

/* Map the 8390 back into the window. */
outb(ECNTRL_THIN, ioaddr + 0x406);
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/3c505.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ static int __init elplus_setup(struct net_device *dev)
unsigned long timeout;
unsigned long cookie = 0;
int err = -ENODEV;
DECLARE_MAC_BUF(mac);

/*
* setup adapter structure
Expand Down Expand Up @@ -1521,11 +1522,10 @@ static int __init elplus_setup(struct net_device *dev)
/*
* print remainder of startup message
*/
printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, ",
dev->name, dev->base_addr, dev->irq, dev->dma);
printk("addr %02x:%02x:%02x:%02x:%02x:%02x, ",
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, "
"addr %s, ",
dev->name, dev->base_addr, dev->irq, dev->dma,
print_mac(mac, dev->dev_addr));

/*
* read more information from the adapter
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/3c507.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
static unsigned char init_ID_done, version_printed;
int i, irq, irqval, retval;
struct net_local *lp;
DECLARE_MAC_BUF(mac);

if (init_ID_done == 0) {
ushort lrs_state = 0xff;
Expand Down Expand Up @@ -402,10 +403,9 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
dev->base_addr = ioaddr;

outb(0x01, ioaddr + MISC_CTRL);
for (i = 0; i < 6; i++) {
for (i = 0; i < 6; i++)
dev->dev_addr[i] = inb(ioaddr + i);
printk(" %02x", dev->dev_addr[i]);
}
printk(" %s", print_mac(mac, dev->dev_addr));

if (mem_start)
net_debug = mem_start & 7;
Expand Down
18 changes: 6 additions & 12 deletions drivers/net/3c509.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ static int nopnp;
static int __init el3_common_init(struct net_device *dev)
{
struct el3_private *lp = netdev_priv(dev);
short i;
int err;
DECLARE_MAC_BUF(mac);
const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};

spin_lock_init(&lp->lock);

Expand Down Expand Up @@ -346,17 +347,10 @@ static int __init el3_common_init(struct net_device *dev)
return err;
}

{
const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
printk("%s: 3c5x9 found at %#3.3lx, %s port, address ",
dev->name, dev->base_addr,
if_names[(dev->if_port & 0x03)]);
}

/* Read in the station address. */
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i]);
printk(", IRQ %d.\n", dev->irq);
printk(KERN_INFO "%s: 3c5x9 found at %#3.3lx, %s port, "
"address %s, IRQ %d.\n",
dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)],
print_mac(mac, dev->dev_addr), dev->irq);

if (el3_debug > 0)
printk(KERN_INFO "%s", version);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/3c515.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
int i;
int irq;
DECLARE_MAC_BUF(mac);

if (idev) {
irq = pnp_irq(idev, 0);
Expand Down Expand Up @@ -630,8 +631,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
checksum = (checksum ^ (checksum >> 8)) & 0xff;
if (checksum != 0x00)
printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
for (i = 0; i < 6; i++)
printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
printk(" %s", print_mac(mac, dev->dev_addr));
if (eeprom[16] == 0x11c7) { /* Corkscrew */
if (request_dma(dev->dma, "3c515")) {
printk(", DMA %d allocation failed", dev->dma);
Expand Down
22 changes: 9 additions & 13 deletions drivers/net/3c523.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ void alloc586(struct net_device *dev)
static int elmc_getinfo(char *buf, int slot, void *d)
{
int len = 0;
struct net_device *dev = (struct net_device *) d;
int i;
struct net_device *dev = d;
DECLARE_MAC_BUF(mac);

if (dev == NULL)
return len;
Expand All @@ -399,12 +399,8 @@ static int elmc_getinfo(char *buf, int slot, void *d)
len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ?
"External" : "Internal");
len += sprintf(buf + len, "Device: %s\n", dev->name);
len += sprintf(buf + len, "Hardware Address:");
for (i = 0; i < 6; i++) {
len += sprintf(buf + len, " %02x", dev->dev_addr[i]);
}
buf[len++] = '\n';
buf[len] = 0;
len += sprintf(buf + len, "Hardware Address: %s\n",
print_mac(mac, dev->dev_addr));

return len;
} /* elmc_getinfo() */
Expand All @@ -422,6 +418,7 @@ static int __init do_elmc_probe(struct net_device *dev)
unsigned int size = 0;
int retval;
struct priv *pr = dev->priv;
DECLARE_MAC_BUF(mac);

if (MCA_bus == 0) {
return -ENODEV;
Expand Down Expand Up @@ -544,12 +541,11 @@ static int __init do_elmc_probe(struct net_device *dev)

/* The hardware address for the 3c523 is stored in the first six
bytes of the IO address. */
printk(KERN_INFO "%s: hardware address ", dev->name);
for (i = 0; i < 6; i++) {
for (i = 0; i < 6; i++)
dev->dev_addr[i] = inb(dev->base_addr + i);
printk(" %02x", dev->dev_addr[i]);
}
printk("\n");

printk(KERN_INFO "%s: hardware address %s\n",
dev->name, print_mac(mac, dev->dev_addr));

dev->open = &elmc_open;
dev->stop = &elmc_close;
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/3c527.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
"82586 initialisation failure",
"Adapter list configuration error"
};
DECLARE_MAC_BUF(mac);

/* Time to play MCA games */

Expand Down Expand Up @@ -396,17 +397,17 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
* Go PROM browsing
*/

printk("%s: Address ", dev->name);

/* Retrieve and print the ethernet address. */
for (i = 0; i < 6; i++)
{
mca_write_pos(slot, 6, i+12);
mca_write_pos(slot, 7, 0);

printk(" %2.2x", dev->dev_addr[i] = mca_read_pos(slot,3));
dev->dev_addr[i] = mca_read_pos(slot,3);
}

printk("%s: Address %s", dev->name, print_mac(mac, dev->dev_addr));

mca_write_pos(slot, 6, 0);
mca_write_pos(slot, 7, 0);

Expand Down
7 changes: 3 additions & 4 deletions drivers/net/3c59x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ static int __devinit vortex_probe1(struct device *gendev,
char *print_name = "3c59x";
struct pci_dev *pdev = NULL;
struct eisa_device *edev = NULL;
DECLARE_MAC_BUF(mac);

if (!printed_version) {
printk (version);
Expand Down Expand Up @@ -1205,10 +1206,8 @@ static int __devinit vortex_probe1(struct device *gendev,
for (i = 0; i < 3; i++)
((u16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
if (print_info) {
for (i = 0; i < 6; i++)
printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
}
if (print_info)
printk(" %s", print_mac(mac, dev->dev_addr));
/* Unfortunately an all zero eeprom passes the checksum and this
gets found in the wild in failure cases. Crypto is hard 8) */
if (!is_valid_ether_addr(dev->dev_addr)) {
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
void __iomem *regs;
resource_size_t pciaddr;
unsigned int addr_len, i, pci_using_dac;
DECLARE_MAC_BUF(mac);

#ifndef MODULE
static int version_printed;
Expand Down Expand Up @@ -1964,13 +1965,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_iomap;

printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
"%02x:%02x:%02x:%02x:%02x:%02x, "
"IRQ %d\n",
"%s, IRQ %d\n",
dev->name,
dev->base_addr,
dev->dev_addr[0], dev->dev_addr[1],
dev->dev_addr[2], dev->dev_addr[3],
dev->dev_addr[4], dev->dev_addr[5],
print_mac(mac, dev->dev_addr),
dev->irq);

pci_set_drvdata(pdev, dev);
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/8139too.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
int i, addr_len, option;
void __iomem *ioaddr;
static int board_idx = -1;
DECLARE_MAC_BUF(mac);

assert (pdev != NULL);
assert (ent != NULL);
Expand Down Expand Up @@ -1017,14 +1018,11 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
pci_set_drvdata (pdev, dev);

printk (KERN_INFO "%s: %s at 0x%lx, "
"%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
"IRQ %d\n",
"%s, IRQ %d\n",
dev->name,
board_info[ent->driver_data].name,
dev->base_addr,
dev->dev_addr[0], dev->dev_addr[1],
dev->dev_addr[2], dev->dev_addr[3],
dev->dev_addr[4], dev->dev_addr[5],
print_mac(mac, dev->dev_addr),
dev->irq);

printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n",
Expand Down
18 changes: 8 additions & 10 deletions drivers/net/82596.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,15 +1116,12 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)

static void print_eth(unsigned char *add, char *str)
{
int i;
DECLARE_MAC_BUF(mac);
DECLARE_MAC_BUF(mac2);

printk(KERN_DEBUG "i596 0x%p, ", add);
for (i = 0; i < 6; i++)
printk(" %02X", add[i + 6]);
printk(" -->");
for (i = 0; i < 6; i++)
printk(" %02X", add[i]);
printk(" %02X%02X, %s\n", add[12], add[13], str);
printk(KERN_DEBUG "i596 0x%p, %s --> %s %02X%02X, %s\n",
add, print_mac(mac, add + 6), print_mac(mac2, add),
add[12], add[13], str);
}

static int io = 0x300;
Expand Down Expand Up @@ -1539,6 +1536,7 @@ static void set_multicast_list(struct net_device *dev)
struct dev_mc_list *dmi;
unsigned char *cp;
struct mc_cmd *cmd;
DECLARE_MAC_BUF(mac);

if (wait_cfg(dev, &lp->mc_cmd.cmd, 1000, "multicast list change request timed out"))
return;
Expand All @@ -1549,8 +1547,8 @@ static void set_multicast_list(struct net_device *dev)
for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) {
memcpy(cp, dmi->dmi_addr, 6);
if (i596_debug > 1)
DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %s\n",
dev->name, print_mac(mac, cp)));
}
i596_add_cmd(dev, &cmd->cmd);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/a2065.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
unsigned long board, base_addr, mem_start;
struct resource *r1, *r2;
int err;
DECLARE_MAC_BUF(mac);

board = z->resource.start;
base_addr = board+A2065_LANCE;
Expand Down Expand Up @@ -792,9 +793,8 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
zorro_set_drvdata(z, dev);

printk(KERN_INFO "%s: A2065 at 0x%08lx, Ethernet Address "
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board,
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
"%s\n", dev->name, board,
print_mac(mac, dev->dev_addr));

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/ac3200.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ struct net_device * __init ac3200_probe(int unit)
static int __init ac_probe1(int ioaddr, struct net_device *dev)
{
int i, retval;
DECLARE_MAC_BUF(mac);

if (!request_region(ioaddr, AC_IO_EXTENT, DRV_NAME))
return -EBUSY;
Expand All @@ -167,10 +168,11 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
#endif

printk("AC3200 in EISA slot %d, node", ioaddr/0x1000);
for(i = 0; i < 6; i++)
printk(" %02x", dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i));
for (i = 0; i < 6; i++)
dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);

printk(KERN_DEBUG "AC3200 in EISA slot %d, node %s",
ioaddr/0x1000, print_mac(mac, dev->dev_addr));
#if 0
/* Check the vendor ID/prefix. Redundant after checking the EISA ID */
if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/acenic.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ static int __devinit ace_init(struct net_device *dev)
int board_idx, ecode = 0;
short i;
unsigned char cache_size;
DECLARE_MAC_BUF(mac);

ap = netdev_priv(dev);
regs = ap->regs;
Expand Down Expand Up @@ -1012,17 +1013,15 @@ static int __devinit ace_init(struct net_device *dev)
writel(mac1, &regs->MacAddrHi);
writel(mac2, &regs->MacAddrLo);

printk("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
(mac1 >> 8) & 0xff, mac1 & 0xff, (mac2 >> 24) &0xff,
(mac2 >> 16) & 0xff, (mac2 >> 8) & 0xff, mac2 & 0xff);

dev->dev_addr[0] = (mac1 >> 8) & 0xff;
dev->dev_addr[1] = mac1 & 0xff;
dev->dev_addr[2] = (mac2 >> 24) & 0xff;
dev->dev_addr[3] = (mac2 >> 16) & 0xff;
dev->dev_addr[4] = (mac2 >> 8) & 0xff;
dev->dev_addr[5] = mac2 & 0xff;

printk("MAC: %s\n", print_mac(mac, dev->dev_addr));

/*
* Looks like this is necessary to deal with on all architectures,
* even this %$#%$# N440BX Intel based thing doesn't get it right.
Expand Down
Loading

0 comments on commit 0795af5

Please sign in to comment.