linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-m68k@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net v4 08/13] net/mac89x0: Replace custom debug logging with netif_* calls
Date: Sun, 11 Feb 2018 22:08:43 -0500 (EST)	[thread overview]
Message-ID: <cfb28c8916059d1596b27607a3e84781a1e41aa9.1518397634.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1518397634.git.fthain@telegraphics.com.au>

Adopt the conventional style of debug logging because it is both
shorter and more flexible.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/net/ethernet/cirrus/mac89x0.c | 47 +++++++++++------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/mac89x0.c b/drivers/net/ethernet/cirrus/mac89x0.c
index 9cc8d4cf2785..165ea3c6be04 100644
--- a/drivers/net/ethernet/cirrus/mac89x0.c
+++ b/drivers/net/ethernet/cirrus/mac89x0.c
@@ -61,18 +61,6 @@
 static const char version[] =
 "cs89x0.c:v1.02 11/26/96 Russell Nelson <nelson@crynwr.com>\n";
 
-/* ======================= configure the driver here ======================= */
-
-/* use 0 for production, 1 for verification, >2 for debug */
-#ifndef NET_DEBUG
-#define NET_DEBUG 0
-#endif
-
-/* ======================= end of configuration ======================= */
-
-
-/* Always include 'config.h' first in case the user wants to turn on
-   or override something. */
 #include <linux/module.h>
 
 /*
@@ -108,14 +96,13 @@ static const char version[] =
 
 #include "cs89x0.h"
 
-static int debug;
+static int debug = -1;
 module_param(debug, int, 0);
-MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
-
-static unsigned int net_debug = NET_DEBUG;
+MODULE_PARM_DESC(debug, "debug message level");
 
 /* Information that need to be kept for each board. */
 struct net_local {
+	int msg_enable;
 	int chip_type;		/* one of: CS8900, CS8920, CS8920M */
 	char chip_revision;	/* revision letter of the chip ('A'...) */
 	int send_cmd;		/* the propercommand used to send a packet. */
@@ -178,7 +165,6 @@ static int mac89x0_device_probe(struct platform_device *pdev)
 {
 	struct net_device *dev;
 	struct net_local *lp;
-	static unsigned version_printed;
 	int i, slot;
 	unsigned rev_type = 0;
 	unsigned long ioaddr;
@@ -189,8 +175,6 @@ static int mac89x0_device_probe(struct platform_device *pdev)
 	if (!MACH_IS_MAC)
 		return -ENODEV;
 
-	net_debug = debug;
-
 	dev = alloc_etherdev(sizeof(struct net_local));
 	if (!dev)
 		return -ENOMEM;
@@ -225,6 +209,8 @@ static int mac89x0_device_probe(struct platform_device *pdev)
 	/* Initialize the net_device structure. */
 	lp = netdev_priv(dev);
 
+	lp->msg_enable = netif_msg_init(debug, 0);
+
 	/* Fill in the 'dev' fields. */
 	dev->base_addr = ioaddr;
 	dev->mem_start = (unsigned long)
@@ -247,8 +233,7 @@ static int mac89x0_device_probe(struct platform_device *pdev)
 	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
 		lp->send_cmd = TX_NOW;
 
-	if (net_debug && version_printed++ == 0)
-		printk(version);
+	netif_dbg(lp, drv, dev, "%s", version);
 
 	pr_info("cs89%c0%s rev %c found at %#8lx\n",
 		lp->chip_type == CS8900 ? '0' : '2',
@@ -348,11 +333,9 @@ net_send_packet(struct sk_buff *skb, struct net_device *dev)
 	struct net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 
-	if (net_debug > 3)
-		printk("%s: sent %d byte packet of type %x\n",
-		       dev->name, skb->len,
-		       (skb->data[ETH_ALEN+ETH_ALEN] << 8)
-		       | skb->data[ETH_ALEN+ETH_ALEN+1]);
+	netif_dbg(lp, tx_queued, dev, "sent %d byte packet of type %x\n",
+		  skb->len, skb->data[ETH_ALEN + ETH_ALEN] << 8 |
+		  skb->data[ETH_ALEN + ETH_ALEN + 1]);
 
 	/* keep the upload from being interrupted, since we
 	   ask the chip to start transmitting before the
@@ -401,7 +384,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
            faster than you can read them off, you're screwed.  Hasta la
            vista, baby!  */
 	while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) {
-		if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status);
+		netif_dbg(lp, intr, dev, "status=%04x\n", status);
 		switch(status & ISQ_EVENT_MASK) {
 		case ISQ_RECEIVER_EVENT:
 			/* Got a packet(s). */
@@ -431,7 +414,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 				netif_wake_queue(dev);
 			}
 			if (status & TX_UNDERRUN) {
-				if (net_debug > 0) printk("%s: transmit underrun\n", dev->name);
+				netif_dbg(lp, tx_err, dev, "transmit underrun\n");
                                 lp->send_underrun++;
                                 if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381;
                                 else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL;
@@ -452,6 +435,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 static void
 net_rx(struct net_device *dev)
 {
+	struct net_local *lp = netdev_priv(dev);
 	struct sk_buff *skb;
 	int status, length;
 
@@ -483,10 +467,9 @@ net_rx(struct net_device *dev)
 	skb_copy_to_linear_data(skb, (void *)(dev->mem_start + PP_RxFrame),
 				length);
 
-	if (net_debug > 3)printk("%s: received %d byte packet of type %x\n",
-                                 dev->name, length,
-                                 (skb->data[ETH_ALEN+ETH_ALEN] << 8)
-				 | skb->data[ETH_ALEN+ETH_ALEN+1]);
+	netif_dbg(lp, rx_status, dev, "received %d byte packet of type %x\n",
+		  length, skb->data[ETH_ALEN + ETH_ALEN] << 8 |
+		  skb->data[ETH_ALEN + ETH_ALEN + 1]);
 
         skb->protocol=eth_type_trans(skb,dev);
 	netif_rx(skb);
-- 
2.13.6

  reply	other threads:[~2018-02-12  3:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12  3:08 [PATCH net v4 00/13] Fixes, cleanup and modernization for some legacy ethernet NIC drivers Finn Thain
2018-02-12  3:08 ` Finn Thain [this message]
2018-02-12  3:08 ` [PATCH net v4 01/13] net/8390: Remove redundant make dependencies Finn Thain
2018-02-12  8:16   ` Geert Uytterhoeven
2018-02-12  3:08 ` [PATCH net v4 10/13] net/mac8390: Fix log messages Finn Thain
2018-02-12  3:08 ` [PATCH net v4 04/13] net/macmace: Fix and clean up " Finn Thain
2018-02-12  3:08 ` [PATCH net v4 11/13] net/macsonic: Convert to nubus_driver Finn Thain
2018-02-12  3:08 ` [PATCH net v4 02/13] net/8390: Fix msg_enable patch snafu Finn Thain
2018-02-12 15:39   ` David Miller
2018-02-13  5:03     ` Finn Thain
2018-02-13 14:58       ` David Miller
2018-02-14 22:11         ` Finn Thain
2018-02-14 22:15           ` David Miller
2018-02-16  3:47             ` Finn Thain
2018-02-12  3:08 ` [PATCH net v4 06/13] net/mac89x0: Convert to platform_driver Finn Thain
2018-02-12  8:25   ` Geert Uytterhoeven
2018-02-12  3:08 ` [PATCH net v4 07/13] net/mac89x0: Fix and modernize log messages Finn Thain
2018-02-12  3:08 ` [PATCH net v4 05/13] net/mac89x0: Remove dead or unreachable code Finn Thain
2018-02-12  3:08 ` [PATCH net v4 03/13] net/smc9194: Remove bogus CONFIG_MAC reference Finn Thain
2018-02-12  3:08 ` [PATCH net v4 09/13] net/mac8390: Convert to nubus_driver Finn Thain
2018-02-12  8:29   ` Geert Uytterhoeven
2018-02-13  5:03     ` Finn Thain
2018-02-12  3:08 ` [PATCH net v4 12/13] net/sonic: Clean up and modernize log messages Finn Thain
2018-02-12  3:08 ` [PATCH net v4 13/13] net/sonic: Replace custom debug logging with netif_* calls Finn Thain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfb28c8916059d1596b27607a3e84781a1e41aa9.1518397634.git.fthain@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).