From patchwork Wed Mar 23 17:34:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 601306 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qVcCZ1STmz9s1h for ; Thu, 24 Mar 2016 04:35:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932279AbcCWRfF (ORCPT ); Wed, 23 Mar 2016 13:35:05 -0400 Received: from smtprelay0128.hostedemail.com ([216.40.44.128]:48362 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753072AbcCWRfE (ORCPT ); Wed, 23 Mar 2016 13:35:04 -0400 Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 83D4423412; Wed, 23 Mar 2016 17:35:01 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::, RULES_HIT:1:41:69:355:379:541:599:960:966:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1593:1594:1605:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:2639:2729:2828:2902:3138:3139:3140:3141:3142:3865:3867:3868:3870:3871:3874:4225:4250:4384:4385:4395:5007:6117:6119:6261:7903:8957:9040:10004:10848:11026:11473:11657:11658:11783:11914:12043:12291:12296:12438:12517:12519:12555:12683:12700:12737:12740:13439:13894:14110:14659:21080:21324:30010:30029:30051:30054:30070:30080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0, LFtime:2, LUA_SUMMARY:none X-HE-Tag: earth98_48c851fb1ab54 X-Filterd-Recvd-Size: 14595 Received: from joe-X200MA.home (pool-71-118-176-190.lsanca.fios.verizon.net [71.118.176.190]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Wed, 23 Mar 2016 17:35:00 +0000 (UTC) Message-ID: <1458754497.6819.10.camel@perches.com> Subject: Re: [PATCH 2/2] drivers: net: ethernet: dlink: dl2k: fix indent From: Joe Perches To: Maxim Zhukov , davem@davemloft.net Cc: linux@rainbow-software.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 23 Mar 2016 10:34:57 -0700 In-Reply-To: <1458748660-10571-2-git-send-email-mussitantesmortem@gmail.com> References: <1458748660-10571-1-git-send-email-mussitantesmortem@gmail.com> <1458748660-10571-2-git-send-email-mussitantesmortem@gmail.com> X-Mailer: Evolution 3.18.5.2-0ubuntu1 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If dl2k is modified at all, maybe convert the printks to netdev_ 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   @@ -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);