If dl2k is modified at all, maybe convert the printks to netdev_<level> too so that the logging output is more like other networking drivers.
Something like: --- drivers/net/ethernet/dlink/dl2k.c | 181 +++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 81 deletions(-) diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c index f92b6d9..0f0326b 100644 --- a/drivers/net/ethernet/dlink/dl2k.c +++ b/drivers/net/ethernet/dlink/dl2k.c @@ -10,9 +10,9 @@ (at your option) any later version. */ -#define DRV_NAME "DL2000/TC902x-based linux driver" #define DRV_VERSION "v1.19" #define DRV_RELDATE "2007/08/12" + #include "dl2k.h" #include <linux/dma-mapping.h> @@ -23,8 +23,6 @@ #define dr16(reg) ioread16(ioaddr + (reg)) #define dr8(reg) ioread8(ioaddr + (reg)) -static char version[] = - KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n"; #define MAX_UNITS 8 static int mtu[MAX_UNITS]; static int vlan[MAX_UNITS]; @@ -118,12 +116,11 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) int chip_idx = ent->driver_data; int err, irq; void __iomem *ioaddr; - static int version_printed; void *ring_space; dma_addr_t ring_dma; - if (!version_printed++) - printk ("%s", version); + pr_info_once("DL2000/TC902x-based linux driver %s %s\n", + DRV_VERSION, DRV_RELDATE); err = pci_enable_device (pdev); if (err) @@ -274,18 +271,20 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) card_idx++; - printk (KERN_INFO "%s: %s, %pM, IRQ %d\n", - dev->name, np->name, dev->dev_addr, irq); + netdev_info(dev, "%s, %pM, IRQ %d\n", + np->name, dev->dev_addr, irq); if (tx_coalesce > 1) - printk(KERN_INFO "tx_coalesce:\t%d packets\n", - tx_coalesce); - if (np->coalesce) - printk(KERN_INFO - "rx_coalesce:\t%d packets\n" - "rx_timeout: \t%d ns\n", - np->rx_coalesce, np->rx_timeout*640); + netdev_info(dev, "tx_coalesce:\t%d packets\n", + tx_coalesce); + if (np->coalesce) { + netdev_info(dev, "rx_coalesce:\t%d packets\n", + np->rx_coalesce); + netdev_info(dev, "rx_timeout: \t%d ns\n", + np->rx_timeout * 640); + } if (np->vlan) - printk(KERN_INFO "vlan(id):\t%d\n", np->vlan); + netdev_info(dev, "vlan(id):\t%d\n", np->vlan); + return 0; err_out_unmap_rx: @@ -322,7 +321,7 @@ find_miiphy (struct net_device *dev) } } if (!phy_found) { - printk (KERN_ERR "%s: No MII PHY found!\n", dev->name); + netdev_err(dev, "No MII PHY found!\n"); return -ENODEV; } return 0; @@ -348,8 +347,7 @@ parse_eeprom (struct net_device *dev) /* Check CRC */ crc = ~ether_crc_le (256 - 4, sromdata); if (psrom->crc != cpu_to_le32(crc)) { - printk (KERN_ERR "%s: EEPROM data CRC error.\n", - dev->name); + netdev_err(dev, "EEPROM data CRC error\n"); return -1; } } @@ -374,7 +372,7 @@ parse_eeprom (struct net_device *dev) cid = psib[i++]; next = psib[i++]; if ((cid == 0 && next == 0) || (cid == 0xff && next == 0xff)) { - printk (KERN_ERR "Cell data error\n"); + netdev_err(dev, "Cell data error\n"); return -1; } switch (cid) { @@ -664,7 +662,7 @@ rio_timer (unsigned long data) spin_lock_irqsave(&np->rx_lock, flags); /* Recover rx ring exhausted error */ if (np->cur_rx - np->old_rx >= RX_RING_SIZE) { - printk(KERN_INFO "Try to recover rx ring exhausted...\n"); + netdev_info(dev, "Trying to recover, rx ring exhausted...\n"); /* Re-allocate skbuffs to fill the descriptor ring */ for (; np->cur_rx - np->old_rx > 0; np->old_rx++) { struct sk_buff *skb; @@ -675,9 +673,8 @@ rio_timer (unsigned long data) np->rx_buf_sz); if (skb == NULL) { np->rx_ring[entry].fraginfo = 0; - printk (KERN_INFO - "%s: Still unable to re-allocate Rx skbuff.#%d\n", - dev->name, entry); + netdev_info(dev, "Still unable to re-allocate Rx skbuff.#%d\n", + entry); break; } np->rx_skbuff[entry] = skb; @@ -702,8 +699,8 @@ rio_tx_timeout (struct net_device *dev) struct netdev_private *np = netdev_priv(dev); void __iomem *ioaddr = np->ioaddr; - printk (KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n", - dev->name, dr32(TxStatus)); + netdev_info(dev, "Tx timed out (%04x), is buffer full?\n", + dr32(TxStatus)); rio_free_tx(dev, 0); dev->if_port = 0; dev->trans_start = jiffies; /* prevent tx timeout */ @@ -874,8 +871,8 @@ tx_error (struct net_device *dev, int tx_status) int i; frame_id = (tx_status & 0xffff0000); - printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n", - dev->name, tx_status, frame_id); + netdev_err(dev, "Transmit error, TxStatus %04x, FrameId %d\n", + tx_status, frame_id); np->stats.tx_errors++; /* Ttransmit Underrun */ if (tx_status & 0x10) { @@ -1007,10 +1004,8 @@ receive_packet (struct net_device *dev) skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); if (skb == NULL) { np->rx_ring[entry].fraginfo = 0; - printk (KERN_INFO - "%s: receive_packet: " - "Unable to re-allocate Rx skbuff.#%d\n", - dev->name, entry); + netdev_info(dev, "receive_packet: Unable to re-allocate Rx skbuff.#%d\n", + entry); break; } np->rx_skbuff[entry] = skb; @@ -1039,7 +1034,7 @@ rio_error (struct net_device *dev, int int_status) /* Link change event */ if (int_status & LinkEvent) { if (mii_wait_link (dev, 10) == 0) { - printk (KERN_INFO "%s: Link up\n", dev->name); + netdev_info(dev, "Link up\n"); if (np->phy_media) mii_get_media_pcs (dev); else @@ -1059,7 +1054,7 @@ rio_error (struct net_device *dev, int int_status) np->link_status = 1; netif_carrier_on(dev); } else { - printk (KERN_INFO "%s: Link off\n", dev->name); + netdev_info(dev, "Link off\n"); np->link_status = 0; netif_carrier_off(dev); } @@ -1073,8 +1068,7 @@ rio_error (struct net_device *dev, int int_status) /* PCI Error, a catastronphic error related to the bus interface occurs, set GlobalReset and HostReset to reset. */ if (int_status & HostError) { - printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n", - dev->name, int_status); + netdev_err(dev, "HostError! IntStatus %04x\n", int_status); dw16(ASICCtrl + 2, GlobalReset | HostReset); mdelay (500); rio_set_led_mode(dev); @@ -1325,7 +1319,7 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (np->speed == 1000) { ethtool_cmd_speed_set(cmd, SPEED_100); cmd->duplex = DUPLEX_FULL; - printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); + netdev_warn(dev, "Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex\n"); } switch (ethtool_cmd_speed(cmd)) { case SPEED_10: @@ -1515,6 +1509,9 @@ mii_get_media (struct net_device *dev) __u16 mssr; int phy_addr; struct netdev_private *np; + const char *how; + const char *speed; + const char *duplex; np = netdev_priv(dev); phy_addr = np->phy_addr; @@ -1525,6 +1522,7 @@ mii_get_media (struct net_device *dev) /* Auto-Negotiation not completed */ return -1; } + how = "Auto"; negotiate = mii_read (dev, phy_addr, MII_ADVERTISE) & mii_read (dev, phy_addr, MII_LPA); mscr = mii_read (dev, phy_addr, MII_CTRL1000); @@ -1532,27 +1530,36 @@ mii_get_media (struct net_device *dev) if (mscr & ADVERTISE_1000FULL && mssr & LPA_1000FULL) { np->speed = 1000; np->full_duplex = 1; - printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); + speed = "1000"; + duplex = "Full"; } else if (mscr & ADVERTISE_1000HALF && mssr & LPA_1000HALF) { np->speed = 1000; np->full_duplex = 0; - printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n"); + speed = "1000"; + duplex = "Half"; } else if (negotiate & ADVERTISE_100FULL) { np->speed = 100; np->full_duplex = 1; - printk (KERN_INFO "Auto 100 Mbps, Full duplex\n"); + speed = "100"; + duplex = "Full"; } else if (negotiate & ADVERTISE_100HALF) { np->speed = 100; np->full_duplex = 0; - printk (KERN_INFO "Auto 100 Mbps, Half duplex\n"); + speed = "100"; + duplex = "Half"; } else if (negotiate & ADVERTISE_10FULL) { np->speed = 10; np->full_duplex = 1; - printk (KERN_INFO "Auto 10 Mbps, Full duplex\n"); + speed = "10"; + duplex = "Full"; } else if (negotiate & ADVERTISE_10HALF) { np->speed = 10; np->full_duplex = 0; - printk (KERN_INFO "Auto 10 Mbps, Half duplex\n"); + speed = "10"; + duplex = "Half"; + } else { + speed = "unknown"; + duplex = "unknown"; } if (negotiate & ADVERTISE_PAUSE_CAP) { np->tx_flow &= 1; @@ -1564,30 +1571,33 @@ mii_get_media (struct net_device *dev) /* else tx_flow, rx_flow = user select */ } else { __u16 bmcr = mii_read (dev, phy_addr, MII_BMCR); + + how = "Operating at"; switch (bmcr & (BMCR_SPEED100 | BMCR_SPEED1000)) { case BMCR_SPEED1000: - printk (KERN_INFO "Operating at 1000 Mbps, "); + speed = "1000"; break; case BMCR_SPEED100: - printk (KERN_INFO "Operating at 100 Mbps, "); + speed = "100"; break; case 0: - printk (KERN_INFO "Operating at 10 Mbps, "); - } - if (bmcr & BMCR_FULLDPLX) { - printk (KERN_CONT "Full duplex\n"); - } else { - printk (KERN_CONT "Half duplex\n"); + speed = "10"; + break; + default: + speed = "unknown"; + break; } + if (bmcr & BMCR_FULLDPLX) + duplex = "Full"; + else + duplex = "Half"; + } - if (np->tx_flow) - printk(KERN_INFO "Enable Tx Flow Control\n"); - else - printk(KERN_INFO "Disable Tx Flow Control\n"); - if (np->rx_flow) - printk(KERN_INFO "Enable Rx Flow Control\n"); - else - printk(KERN_INFO "Disable Rx Flow Control\n"); + + netdev_info(dev, "%s %s Mbps, %s duplex, Tx Flow Control: %s Rx Flow Control: %s\n", + how, speed, duplex, + np->tx_flow ? "Enabled" : "Disabled", + np->rx_flow ? "Enabled" : "Disabled"); return 0; } @@ -1636,6 +1646,10 @@ mii_set_media (struct net_device *dev) mii_write (dev, phy_addr, MII_BMCR, bmcr); mdelay(1); } else { + const char *how = "Manual"; + const char *speed = "unknown"; + const char *duplex = "unknown"; + /* Force speed setting */ /* 1) Disable Auto crossover */ pscr = mii_read (dev, phy_addr, MII_PHY_SCR); @@ -1659,16 +1673,18 @@ mii_set_media (struct net_device *dev) bmcr = BMCR_PDOWN; if (np->speed == 100) { bmcr |= BMCR_SPEED100; - printk (KERN_INFO "Manual 100 Mbps, "); + speed = "100"; } else if (np->speed == 10) { - printk (KERN_INFO "Manual 10 Mbps, "); + speed = "10"; } if (np->full_duplex) { bmcr |= BMCR_FULLDPLX; - printk (KERN_CONT "Full duplex\n"); + duplex = "Full"; } else { - printk (KERN_CONT "Half duplex\n"); + duplex = "Half"; } + netdev_info(dev, "%s %s Mbps, %s duplex\n", + how, speed, duplex); #if 0 /* Set 1000BaseT Master/Slave setting */ mscr = mii_read (dev, phy_addr, MII_CTRL1000); @@ -1688,6 +1704,9 @@ mii_get_media_pcs (struct net_device *dev) __u16 bmsr; int phy_addr; struct netdev_private *np; + const char *how; + const char *speed; + const char *duplex; np = netdev_priv(dev); phy_addr = np->phy_addr; @@ -1698,15 +1717,17 @@ mii_get_media_pcs (struct net_device *dev) /* Auto-Negotiation not completed */ return -1; } + how = "Auto"; negotiate = mii_read (dev, phy_addr, PCS_ANAR) & mii_read (dev, phy_addr, PCS_ANLPAR); np->speed = 1000; + speed = "1000"; if (negotiate & PCS_ANAR_FULL_DUPLEX) { - printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); np->full_duplex = 1; + duplex = "Full"; } else { - printk (KERN_INFO "Auto 1000 Mbps, half duplex\n"); np->full_duplex = 0; + duplex = "Half"; } if (negotiate & PCS_ANAR_PAUSE) { np->tx_flow &= 1; @@ -1718,21 +1739,19 @@ mii_get_media_pcs (struct net_device *dev) /* else tx_flow, rx_flow = user select */ } else { __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR); - printk (KERN_INFO "Operating at 1000 Mbps, "); - if (bmcr & BMCR_FULLDPLX) { - printk (KERN_CONT "Full duplex\n"); - } else { - printk (KERN_CONT "Half duplex\n"); - } + + how = "Operating at"; + speed = "1000"; + if (bmcr & BMCR_FULLDPLX) + duplex = "Full"; + else + duplex = "Half"; } - if (np->tx_flow) - printk(KERN_INFO "Enable Tx Flow Control\n"); - else - printk(KERN_INFO "Disable Tx Flow Control\n"); - if (np->rx_flow) - printk(KERN_INFO "Enable Rx Flow Control\n"); - else - printk(KERN_INFO "Disable Rx Flow Control\n"); + + netdev_info(dev, "%s %s Mbps, %s duplex, Tx Flow Control: %s Rx Flow Control: %s\n", + how, speed, duplex, + np->tx_flow ? "Enabled" : "Disabled", + np->rx_flow ? "Enabled" : "Disabled"); return 0; } @@ -1775,10 +1794,10 @@ mii_set_media_pcs (struct net_device *dev) mdelay(10); if (np->full_duplex) { bmcr = BMCR_FULLDPLX; - printk (KERN_INFO "Manual full duplex\n"); + netdev_info(dev, "Manual full duplex\n"); } else { bmcr = 0; - printk (KERN_INFO "Manual half duplex\n"); + netdev_info(dev, "Manual half duplex\n"); } mii_write (dev, phy_addr, MII_BMCR, bmcr); mdelay(10);