All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements
@ 2022-09-18 23:26 Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 01/13] sunhme: remove unused tx_dump_ring() Sean Anderson
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

This series is a continuation of [1] with a focus on logging improvements (in
the style of commit b11e5f6a3a5c ("net: sunhme: output link status with a single
print.")). I have included several of Rolf's patches in the series where
appropriate (with slight modifications). After this series is applied, many more
messages from this driver will come with driver/device information.
Additionally, most messages (especially debug messages) have been condensed onto
one line (as KERN_CONT messages get split).

[1] https://lore.kernel.org/netdev/4686583.GXAFRqVoOG@eto.sf-tec.de/


Rolf Eike Beer (3):
  sunhme: remove unused tx_dump_ring()
  sunhme: forward the error code from pci_enable_device()
  sunhme: switch to devres

Sean Anderson (10):
  sunhme: Remove version
  sunhme: Return an ERR_PTR from quattro_pci_find
  sunhme: Regularize probe errors
  sumhme: Convert FOO((...)) to FOO(...)
  sunhme: Clean up debug infrastructure
  sunhme: Convert printk(KERN_FOO ...) to pr_foo(...)
  sunhme: Use (net)dev_foo wherever possible
  sunhme: Combine continued messages
  sunhme: Use vdbg for spam-y prints
  sunhme: Add myself as a maintainer

 MAINTAINERS                       |   5 +
 drivers/net/ethernet/sun/sunhme.c | 641 ++++++++++++------------------
 2 files changed, 256 insertions(+), 390 deletions(-)

-- 
2.37.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH net-next 01/13] sunhme: remove unused tx_dump_ring()
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 02/13] sunhme: Remove version Sean Anderson
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

From: Rolf Eike Beer <eike-kernel@sf-tec.de>

I can't find a reference to it in the entire git history.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index e660902cfdf7..987f4c7338f5 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -135,25 +135,9 @@ static __inline__ void tx_dump_log(void)
 		this = (this + 1) & (TX_LOG_LEN - 1);
 	}
 }
-static __inline__ void tx_dump_ring(struct happy_meal *hp)
-{
-	struct hmeal_init_block *hb = hp->happy_block;
-	struct happy_meal_txd *tp = &hb->happy_meal_txd[0];
-	int i;
-
-	for (i = 0; i < TX_RING_SIZE; i+=4) {
-		printk("TXD[%d..%d]: [%08x:%08x] [%08x:%08x] [%08x:%08x] [%08x:%08x]\n",
-		       i, i + 4,
-		       le32_to_cpu(tp[i].tx_flags), le32_to_cpu(tp[i].tx_addr),
-		       le32_to_cpu(tp[i + 1].tx_flags), le32_to_cpu(tp[i + 1].tx_addr),
-		       le32_to_cpu(tp[i + 2].tx_flags), le32_to_cpu(tp[i + 2].tx_addr),
-		       le32_to_cpu(tp[i + 3].tx_flags), le32_to_cpu(tp[i + 3].tx_addr));
-	}
-}
 #else
 #define tx_add_log(hp, a, s)		do { } while(0)
 #define tx_dump_log()			do { } while(0)
-#define tx_dump_ring(hp)		do { } while(0)
 #endif
 
 #ifdef HMEDEBUG
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 02/13] sunhme: Remove version
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 01/13] sunhme: remove unused tx_dump_ring() Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device() Sean Anderson
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

Module versions are not very useful:

> The basic problem is, the version string does not identify the sources
> with enough accuracy. It says nothing about back ported fixes in
> stable kernels. It tells you nothing about vendor patches to the
> network core, etc.

https://lore.kernel.org/all/Yf6mtvA1zO7cdzr7@lunn.ch/

While we're at it, inline the author and use the driver name a bit more.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 987f4c7338f5..7340d0f2ef93 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -61,15 +61,8 @@
 #include "sunhme.h"
 
 #define DRV_NAME	"sunhme"
-#define DRV_VERSION	"3.10"
-#define DRV_RELDATE	"August 26, 2008"
-#define DRV_AUTHOR	"David S. Miller (davem@davemloft.net)"
 
-static char version[] =
-	DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
-
-MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR(DRV_AUTHOR);
+MODULE_AUTHOR("David S. Miller (davem@davemloft.net)");
 MODULE_DESCRIPTION("Sun HappyMealEthernet(HME) 10/100baseT ethernet driver");
 MODULE_LICENSE("GPL");
 
@@ -2451,8 +2444,7 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
 {
 	struct happy_meal *hp = netdev_priv(dev);
 
-	strscpy(info->driver, "sunhme", sizeof(info->driver));
-	strscpy(info->version, "2.02", sizeof(info->version));
+	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
 	if (hp->happy_flags & HFLAG_PCI) {
 		struct pci_dev *pdev = hp->happy_dev;
 		strscpy(info->bus_info, pci_name(pdev), sizeof(info->bus_info));
@@ -2488,8 +2480,6 @@ static const struct ethtool_ops hme_ethtool_ops = {
 	.set_link_ksettings	= hme_set_link_ksettings,
 };
 
-static int hme_version_printed;
-
 #ifdef CONFIG_SBUS
 /* Given a happy meal sbus device, find it's quattro parent.
  * If none exist, allocate and return a new one.
@@ -2973,9 +2963,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 		goto err_out;
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	if (hme_version_printed++ == 0)
-		printk(KERN_INFO "%s", version);
-
 	hp = netdev_priv(dev);
 
 	hp->happy_dev = pdev;
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device()
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 01/13] sunhme: remove unused tx_dump_ring() Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 02/13] sunhme: Remove version Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-20 19:37   ` Jakub Kicinski
  2022-09-18 23:26 ` [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find Sean Anderson
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

From: Rolf Eike Beer <eike-kernel@sf-tec.de>

This already returns a proper error value, so pass it to the caller.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 7340d0f2ef93..1fc16801f520 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2940,11 +2940,12 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 		strcpy(prom_name, "SUNW,hme");
 #endif
 
-	err = -ENODEV;
+	err = pci_enable_device(pdev);
 
-	if (pci_enable_device(pdev))
+	if (err)
 		goto err_out;
 	pci_set_master(pdev);
+	err = -ENODEV;
 
 	if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
 		qp = quattro_pci_find(pdev);
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (2 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device() Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-19 13:11   ` Rolf Eike Beer
  2022-09-20 19:36   ` Jakub Kicinski
  2022-09-18 23:26 ` [PATCH net-next 05/13] sunhme: Regularize probe errors Sean Anderson
                   ` (8 subsequent siblings)
  12 siblings, 2 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

In order to differentiate between a missing bridge and an OOM condition,
return ERR_PTRs from quattro_pci_find. This also does some general linting
in the area.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 33 +++++++++++++++++++------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 1fc16801f520..52247505d08e 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2569,30 +2569,33 @@ static void quattro_sbus_free_irqs(void)
 #ifdef CONFIG_PCI
 static struct quattro *quattro_pci_find(struct pci_dev *pdev)
 {
+	int i;
 	struct pci_dev *bdev = pdev->bus->self;
 	struct quattro *qp;
 
-	if (!bdev) return NULL;
+	if (!bdev)
+		return ERR_PTR(-ENODEV);
+
 	for (qp = qfe_pci_list; qp != NULL; qp = qp->next) {
 		struct pci_dev *qpdev = qp->quattro_dev;
 
 		if (qpdev == bdev)
 			return qp;
 	}
+
 	qp = kmalloc(sizeof(struct quattro), GFP_KERNEL);
-	if (qp != NULL) {
-		int i;
+	if (!qp)
+		return ERR_PTR(-ENOMEM);
 
-		for (i = 0; i < 4; i++)
-			qp->happy_meals[i] = NULL;
+	for (i = 0; i < 4; i++)
+		qp->happy_meals[i] = NULL;
 
-		qp->quattro_dev = bdev;
-		qp->next = qfe_pci_list;
-		qfe_pci_list = qp;
+	qp->quattro_dev = bdev;
+	qp->next = qfe_pci_list;
+	qfe_pci_list = qp;
 
-		/* No range tricks necessary on PCI. */
-		qp->nranges = 0;
-	}
+	/* No range tricks necessary on PCI. */
+	qp->nranges = 0;
 	return qp;
 }
 #endif /* CONFIG_PCI */
@@ -2949,11 +2952,15 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
 		qp = quattro_pci_find(pdev);
-		if (qp == NULL)
+		if (IS_ERR(qp)) {
+			err = PTR_ERR(qp);
 			goto err_out;
+		}
+
 		for (qfe_slot = 0; qfe_slot < 4; qfe_slot++)
-			if (qp->happy_meals[qfe_slot] == NULL)
+			if (!qp->happy_meals[qfe_slot])
 				break;
+
 		if (qfe_slot == 4)
 			goto err_out;
 	}
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 05/13] sunhme: Regularize probe errors
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (3 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-20 19:36   ` Jakub Kicinski
  2022-09-18 23:26 ` [PATCH net-next 06/13] sunhme: switch to devres Sean Anderson
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

This fixes several error paths to ensure they return an appropriate error
(instead of ENODEV).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 52247505d08e..f0b77bdf51dd 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2948,7 +2948,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	if (err)
 		goto err_out;
 	pci_set_master(pdev);
-	err = -ENODEV;
 
 	if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
 		qp = quattro_pci_find(pdev);
@@ -2985,18 +2984,22 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	}
 
 	hpreg_res = pci_resource_start(pdev, 0);
-	err = -ENODEV;
+	err = -EINVAL;
 	if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
 		printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
 		goto err_out_clear_quattro;
 	}
-	if (pci_request_regions(pdev, DRV_NAME)) {
+
+	err = pci_request_regions(pdev, DRV_NAME);
+	if (err) {
 		printk(KERN_ERR "happymeal(PCI): Cannot obtain PCI resources, "
 		       "aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
-	if ((hpreg_base = ioremap(hpreg_res, 0x8000)) == NULL) {
+	hpreg_base = ioremap(hpreg_res, 0x8000);
+	err = -ENOMEM;
+	if (!hpreg_base) {
 		printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
 		goto err_out_free_res;
 	}
@@ -3066,7 +3069,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
 					     &hp->hblock_dvma, GFP_KERNEL);
-	err = -ENODEV;
+	err = -ENOMEM;
 	if (!hp->happy_block)
 		goto err_out_iounmap;
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 06/13] sunhme: switch to devres
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (4 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 05/13] sunhme: Regularize probe errors Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 07/13] sumhme: Convert FOO((...)) to FOO(...) Sean Anderson
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

From: Rolf Eike Beer <eike-kernel@sf-tec.de>

This not only removes a lot of code, it also fixes the memleak of the DMA
memory when register_netdev() fails.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
[ rebased onto net-next/master; fixed error reporting ]
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 60 +++++++++----------------------
 1 file changed, 17 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index f0b77bdf51dd..cde0d8062fd3 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2926,7 +2926,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	struct happy_meal *hp;
 	struct net_device *dev;
 	void __iomem *hpreg_base;
-	unsigned long hpreg_res;
+	struct resource *hpreg_res;
 	int i, qfe_slot = -1;
 	char prom_name[64];
 	u8 addr[ETH_ALEN];
@@ -2943,7 +2943,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 		strcpy(prom_name, "SUNW,hme");
 #endif
 
-	err = pci_enable_device(pdev);
+	err = pcim_enable_device(pdev);
 
 	if (err)
 		goto err_out;
@@ -2964,10 +2964,11 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 			goto err_out;
 	}
 
-	dev = alloc_etherdev(sizeof(struct happy_meal));
-	err = -ENOMEM;
-	if (!dev)
+	dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal));
+	if (!dev) {
+		err = -ENOMEM;
 		goto err_out;
+	}
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	hp = netdev_priv(dev);
@@ -2983,25 +2984,26 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 		qp->happy_meals[qfe_slot] = dev;
 	}
 
-	hpreg_res = pci_resource_start(pdev, 0);
 	err = -EINVAL;
 	if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
 		printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
 		goto err_out_clear_quattro;
 	}
 
-	err = pci_request_regions(pdev, DRV_NAME);
-	if (err) {
+	hpreg_res = devm_request_region(&pdev->dev, pci_resource_start(pdev, 0),
+					pci_resource_len(pdev, 0), DRV_NAME);
+	if (IS_ERR(hpreg_res)) {
+		err = PTR_ERR(hpreg_res);
 		printk(KERN_ERR "happymeal(PCI): Cannot obtain PCI resources, "
 		       "aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
-	hpreg_base = ioremap(hpreg_res, 0x8000);
+	hpreg_base = pcim_iomap(pdev, 0, 0x8000);
 	err = -ENOMEM;
 	if (!hpreg_base) {
 		printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
-		goto err_out_free_res;
+		goto err_out_clear_quattro;
 	}
 
 	for (i = 0; i < 6; i++) {
@@ -3067,11 +3069,11 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	hp->happy_bursts = DMA_BURSTBITS;
 #endif
 
-	hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
-					     &hp->hblock_dvma, GFP_KERNEL);
+	hp->happy_block = dmam_alloc_coherent(&pdev->dev, PAGE_SIZE,
+					      &hp->hblock_dvma, GFP_KERNEL);
 	err = -ENOMEM;
 	if (!hp->happy_block)
-		goto err_out_iounmap;
+		goto err_out_clear_quattro;
 
 	hp->linkcheck = 0;
 	hp->timer_state = asleep;
@@ -3105,11 +3107,11 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	happy_meal_set_initial_advertisement(hp);
 	spin_unlock_irq(&hp->happy_lock);
 
-	err = register_netdev(hp->dev);
+	err = devm_register_netdev(&pdev->dev, dev);
 	if (err) {
 		printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
 		       "aborting.\n");
-		goto err_out_free_coherent;
+		goto err_out_clear_quattro;
 	}
 
 	pci_set_drvdata(pdev, hp);
@@ -3142,41 +3144,14 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	return 0;
 
-err_out_free_coherent:
-	dma_free_coherent(hp->dma_dev, PAGE_SIZE,
-			  hp->happy_block, hp->hblock_dvma);
-
-err_out_iounmap:
-	iounmap(hp->gregs);
-
-err_out_free_res:
-	pci_release_regions(pdev);
-
 err_out_clear_quattro:
 	if (qp != NULL)
 		qp->happy_meals[qfe_slot] = NULL;
 
-	free_netdev(dev);
-
 err_out:
 	return err;
 }
 
-static void happy_meal_pci_remove(struct pci_dev *pdev)
-{
-	struct happy_meal *hp = pci_get_drvdata(pdev);
-	struct net_device *net_dev = hp->dev;
-
-	unregister_netdev(net_dev);
-
-	dma_free_coherent(hp->dma_dev, PAGE_SIZE,
-			  hp->happy_block, hp->hblock_dvma);
-	iounmap(hp->gregs);
-	pci_release_regions(hp->happy_dev);
-
-	free_netdev(net_dev);
-}
-
 static const struct pci_device_id happymeal_pci_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL) },
 	{ }			/* Terminating entry */
@@ -3188,7 +3163,6 @@ static struct pci_driver hme_pci_driver = {
 	.name		= "hme",
 	.id_table	= happymeal_pci_ids,
 	.probe		= happy_meal_pci_probe,
-	.remove		= happy_meal_pci_remove,
 };
 
 static int __init happy_meal_pci_init(void)
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 07/13] sumhme: Convert FOO((...)) to FOO(...)
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (5 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 06/13] sunhme: switch to devres Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 08/13] sunhme: Clean up debug infrastructure Sean Anderson
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

With the power of variadic macros, double parentheses are unnecessary.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 272 +++++++++++++++---------------
 1 file changed, 136 insertions(+), 136 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index cde0d8062fd3..16b81beb3ffb 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -134,17 +134,17 @@ static __inline__ void tx_dump_log(void)
 #endif
 
 #ifdef HMEDEBUG
-#define HMD(x)  printk x
+#define HMD printk
 #else
-#define HMD(x)
+#define HMD(...)
 #endif
 
 /* #define AUTO_SWITCH_DEBUG */
 
 #ifdef AUTO_SWITCH_DEBUG
-#define ASD(x)  printk x
+#define ASD printk
 #else
-#define ASD(x)
+#define ASD(...)
 #endif
 
 #define DEFAULT_IPG0      16 /* For lance-mode only */
@@ -320,7 +320,7 @@ static int happy_meal_bb_read(struct happy_meal *hp,
 	int retval = 0;
 	int i;
 
-	ASD(("happy_meal_bb_read: reg=%d ", reg));
+	ASD("happy_meal_bb_read: reg=%d ", reg);
 
 	/* Enable the MIF BitBang outputs. */
 	hme_write32(hp, tregs + TCVR_BBOENAB, 1);
@@ -355,7 +355,7 @@ static int happy_meal_bb_read(struct happy_meal *hp,
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
-	ASD(("value=%x\n", retval));
+	ASD("value=%x\n", retval);
 	return retval;
 }
 
@@ -366,7 +366,7 @@ static void happy_meal_bb_write(struct happy_meal *hp,
 	u32 tmp;
 	int i;
 
-	ASD(("happy_meal_bb_write: reg=%d value=%x\n", reg, value));
+	ASD("happy_meal_bb_write: reg=%d value=%x\n", reg, value);
 
 	/* Enable the MIF BitBang outputs. */
 	hme_write32(hp, tregs + TCVR_BBOENAB, 1);
@@ -410,14 +410,14 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 	int tries = TCVR_READ_TRIES;
 	int retval;
 
-	ASD(("happy_meal_tcvr_read: reg=0x%02x ", reg));
+	ASD("happy_meal_tcvr_read: reg=0x%02x ", reg);
 	if (hp->tcvr_type == none) {
-		ASD(("no transceiver, value=TCVR_FAILURE\n"));
+		ASD("no transceiver, value=TCVR_FAILURE\n");
 		return TCVR_FAILURE;
 	}
 
 	if (!(hp->happy_flags & HFLAG_FENABLE)) {
-		ASD(("doing bit bang\n"));
+		ASD("doing bit bang\n");
 		return happy_meal_bb_read(hp, tregs, reg);
 	}
 
@@ -430,7 +430,7 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 		return TCVR_FAILURE;
 	}
 	retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff;
-	ASD(("value=%04x\n", retval));
+	ASD("value=%04x\n", retval);
 	return retval;
 }
 
@@ -442,7 +442,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
 {
 	int tries = TCVR_WRITE_TRIES;
 
-	ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));
+	ASD("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value);
 
 	/* Welcome to Sun Microsystems, can I take your order please? */
 	if (!(hp->happy_flags & HFLAG_FENABLE)) {
@@ -807,7 +807,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
 	int tries = TX_RESET_TRIES;
 
-	HMD(("happy_meal_tx_reset: reset, "));
+	HMD("happy_meal_tx_reset: reset, ");
 
 	/* Would you like to try our SMCC Delux? */
 	hme_write32(hp, bregs + BMAC_TXSWRESET, 0);
@@ -819,7 +819,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 		printk(KERN_ERR "happy meal: Transceiver BigMac ATTACK!");
 
 	/* Take care. */
-	HMD(("done\n"));
+	HMD("done\n");
 }
 
 /* hp->happy_lock must be held */
@@ -827,7 +827,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
 	int tries = RX_RESET_TRIES;
 
-	HMD(("happy_meal_rx_reset: reset, "));
+	HMD("happy_meal_rx_reset: reset, ");
 
 	/* We have a special on GNU/Viking hardware bugs today. */
 	hme_write32(hp, bregs + BMAC_RXSWRESET, 0);
@@ -839,7 +839,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 		printk(KERN_ERR "happy meal: Receiver BigMac ATTACK!");
 
 	/* Don't forget your vik_1137125_wa.  Have a nice day. */
-	HMD(("done\n"));
+	HMD("done\n");
 }
 
 #define STOP_TRIES         16
@@ -849,7 +849,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 {
 	int tries = STOP_TRIES;
 
-	HMD(("happy_meal_stop: reset, "));
+	HMD("happy_meal_stop: reset, ");
 
 	/* We're consolidating our STB products, it's your lucky day. */
 	hme_write32(hp, gregs + GREG_SWRESET, GREG_RESET_ALL);
@@ -861,7 +861,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 		printk(KERN_ERR "happy meal: Fry guys.");
 
 	/* Remember: "Different name, same old buggy as shit hardware." */
-	HMD(("done\n"));
+	HMD("done\n");
 }
 
 /* hp->happy_lock must be held */
@@ -890,21 +890,21 @@ static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs)
 /* hp->happy_lock must be held */
 static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs)
 {
-	ASD(("happy_meal_poll_stop: "));
+	ASD("happy_meal_poll_stop: ");
 
 	/* If polling disabled or not polling already, nothing to do. */
 	if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) !=
 	   (HFLAG_POLLENABLE | HFLAG_POLL)) {
-		HMD(("not polling, return\n"));
+		HMD("not polling, return\n");
 		return;
 	}
 
 	/* Shut up the MIF. */
-	ASD(("were polling, mif ints off, "));
+	ASD("were polling, mif ints off, ");
 	hme_write32(hp, tregs + TCVR_IMASK, 0xffff);
 
 	/* Turn off polling. */
-	ASD(("polling off, "));
+	ASD("polling off, ");
 	hme_write32(hp, tregs + TCVR_CFG,
 		    hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE));
 
@@ -913,7 +913,7 @@ static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs)
 
 	/* Let the bits set. */
 	udelay(200);
-	ASD(("done\n"));
+	ASD("done\n");
 }
 
 /* Only Sun can take such nice parts and fuck up the programming interface
@@ -929,44 +929,44 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 	int result, tries = TCVR_RESET_TRIES;
 
 	tconfig = hme_read32(hp, tregs + TCVR_CFG);
-	ASD(("happy_meal_tcvr_reset: tcfg<%08lx> ", tconfig));
+	ASD("happy_meal_tcvr_reset: tcfg<%08lx> ", tconfig);
 	if (hp->tcvr_type == external) {
-		ASD(("external<"));
+		ASD("external<");
 		hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT));
 		hp->tcvr_type = internal;
 		hp->paddr = TCV_PADDR_ITX;
-		ASD(("ISOLATE,"));
+		ASD("ISOLATE,");
 		happy_meal_tcvr_write(hp, tregs, MII_BMCR,
 				      (BMCR_LOOPBACK|BMCR_PDOWN|BMCR_ISOLATE));
 		result = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 		if (result == TCVR_FAILURE) {
-			ASD(("phyread_fail>\n"));
+			ASD("phyread_fail>\n");
 			return -1;
 		}
-		ASD(("phyread_ok,PSELECT>"));
+		ASD("phyread_ok,PSELECT>");
 		hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT);
 		hp->tcvr_type = external;
 		hp->paddr = TCV_PADDR_ETX;
 	} else {
 		if (tconfig & TCV_CFG_MDIO1) {
-			ASD(("internal<PSELECT,"));
+			ASD("internal<PSELECT,");
 			hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT));
-			ASD(("ISOLATE,"));
+			ASD("ISOLATE,");
 			happy_meal_tcvr_write(hp, tregs, MII_BMCR,
 					      (BMCR_LOOPBACK|BMCR_PDOWN|BMCR_ISOLATE));
 			result = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 			if (result == TCVR_FAILURE) {
-				ASD(("phyread_fail>\n"));
+				ASD("phyread_fail>\n");
 				return -1;
 			}
-			ASD(("phyread_ok,~PSELECT>"));
+			ASD("phyread_ok,~PSELECT>");
 			hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT)));
 			hp->tcvr_type = internal;
 			hp->paddr = TCV_PADDR_ITX;
 		}
 	}
 
-	ASD(("BMCR_RESET "));
+	ASD("BMCR_RESET ");
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET);
 
 	while (--tries) {
@@ -979,10 +979,10 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 		udelay(20);
 	}
 	if (!tries) {
-		ASD(("BMCR RESET FAILED!\n"));
+		ASD("BMCR RESET FAILED!\n");
 		return -1;
 	}
-	ASD(("RESET_OK\n"));
+	ASD("RESET_OK\n");
 
 	/* Get fresh copies of the PHY registers. */
 	hp->sw_bmsr      = happy_meal_tcvr_read(hp, tregs, MII_BMSR);
@@ -990,7 +990,7 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 	hp->sw_physid2   = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2);
 	hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE);
 
-	ASD(("UNISOLATE"));
+	ASD("UNISOLATE");
 	hp->sw_bmcr &= ~(BMCR_ISOLATE);
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -1004,10 +1004,10 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 		udelay(20);
 	}
 	if (!tries) {
-		ASD((" FAILED!\n"));
+		ASD(" FAILED!\n");
 		return -1;
 	}
-	ASD((" SUCCESS and CSCONFIG_DFBYPASS\n"));
+	ASD(" SUCCESS and CSCONFIG_DFBYPASS\n");
 	if (!is_lucent_phy(hp)) {
 		result = happy_meal_tcvr_read(hp, tregs,
 					      DP83840_CSCONFIG);
@@ -1025,60 +1025,60 @@ static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tr
 {
 	unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG);
 
-	ASD(("happy_meal_transceiver_check: tcfg=%08lx ", tconfig));
+	ASD("happy_meal_transceiver_check: tcfg=%08lx ", tconfig);
 	if (hp->happy_flags & HFLAG_POLL) {
 		/* If we are polling, we must stop to get the transceiver type. */
-		ASD(("<polling> "));
+		ASD("<polling> ");
 		if (hp->tcvr_type == internal) {
 			if (tconfig & TCV_CFG_MDIO1) {
-				ASD(("<internal> <poll stop> "));
+				ASD("<internal> <poll stop> ");
 				happy_meal_poll_stop(hp, tregs);
 				hp->paddr = TCV_PADDR_ETX;
 				hp->tcvr_type = external;
-				ASD(("<external>\n"));
+				ASD("<external>\n");
 				tconfig &= ~(TCV_CFG_PENABLE);
 				tconfig |= TCV_CFG_PSELECT;
 				hme_write32(hp, tregs + TCVR_CFG, tconfig);
 			}
 		} else {
 			if (hp->tcvr_type == external) {
-				ASD(("<external> "));
+				ASD("<external> ");
 				if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) {
-					ASD(("<poll stop> "));
+					ASD("<poll stop> ");
 					happy_meal_poll_stop(hp, tregs);
 					hp->paddr = TCV_PADDR_ITX;
 					hp->tcvr_type = internal;
-					ASD(("<internal>\n"));
+					ASD("<internal>\n");
 					hme_write32(hp, tregs + TCVR_CFG,
 						    hme_read32(hp, tregs + TCVR_CFG) &
 						    ~(TCV_CFG_PSELECT));
 				}
-				ASD(("\n"));
+				ASD("\n");
 			} else {
-				ASD(("<none>\n"));
+				ASD("<none>\n");
 			}
 		}
 	} else {
 		u32 reread = hme_read32(hp, tregs + TCVR_CFG);
 
 		/* Else we can just work off of the MDIO bits. */
-		ASD(("<not polling> "));
+		ASD("<not polling> ");
 		if (reread & TCV_CFG_MDIO1) {
 			hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT);
 			hp->paddr = TCV_PADDR_ETX;
 			hp->tcvr_type = external;
-			ASD(("<external>\n"));
+			ASD("<external>\n");
 		} else {
 			if (reread & TCV_CFG_MDIO0) {
 				hme_write32(hp, tregs + TCVR_CFG,
 					    tconfig & ~(TCV_CFG_PSELECT));
 				hp->paddr = TCV_PADDR_ITX;
 				hp->tcvr_type = internal;
-				ASD(("<internal>\n"));
+				ASD("<internal>\n");
 			} else {
 				printk(KERN_ERR "happy meal: Transceiver and a coke please.");
 				hp->tcvr_type = none; /* Grrr... */
-				ASD(("<none>\n"));
+				ASD("<none>\n");
 			}
 		}
 	}
@@ -1185,15 +1185,15 @@ static void happy_meal_init_rings(struct happy_meal *hp)
 	struct hmeal_init_block *hb = hp->happy_block;
 	int i;
 
-	HMD(("happy_meal_init_rings: counters to zero, "));
+	HMD("happy_meal_init_rings: counters to zero, ");
 	hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0;
 
 	/* Free any skippy bufs left around in the rings. */
-	HMD(("clean, "));
+	HMD("clean, ");
 	happy_meal_clean_rings(hp);
 
 	/* Now get new skippy bufs for the receive ring. */
-	HMD(("init rxring, "));
+	HMD("init rxring, ");
 	for (i = 0; i < RX_RING_SIZE; i++) {
 		struct sk_buff *skb;
 		u32 mapping;
@@ -1220,11 +1220,11 @@ static void happy_meal_init_rings(struct happy_meal *hp)
 		skb_reserve(skb, RX_OFFSET);
 	}
 
-	HMD(("init txring, "));
+	HMD("init txring, ");
 	for (i = 0; i < TX_RING_SIZE; i++)
 		hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0);
 
-	HMD(("done\n"));
+	HMD("done\n");
 }
 
 /* hp->happy_lock must be held */
@@ -1272,15 +1272,15 @@ happy_meal_begin_auto_negotiation(struct happy_meal *hp,
 		 */
 
 #ifdef AUTO_SWITCH_DEBUG
-		ASD(("%s: Advertising [ ", hp->dev->name));
+		ASD("%s: Advertising [ ", hp->dev->name);
 		if (hp->sw_advertise & ADVERTISE_10HALF)
-			ASD(("10H "));
+			ASD("10H ");
 		if (hp->sw_advertise & ADVERTISE_10FULL)
-			ASD(("10F "));
+			ASD("10F ");
 		if (hp->sw_advertise & ADVERTISE_100HALF)
-			ASD(("100H "));
+			ASD("100H ");
 		if (hp->sw_advertise & ADVERTISE_100FULL)
-			ASD(("100F "));
+			ASD("100F ");
 #endif
 
 		/* Enable Auto-Negotiation, this is usually on already... */
@@ -1364,65 +1364,65 @@ static int happy_meal_init(struct happy_meal *hp)
 	/* If auto-negotiation timer is running, kill it. */
 	del_timer(&hp->happy_timer);
 
-	HMD(("happy_meal_init: happy_flags[%08x] ",
-	     hp->happy_flags));
+	HMD("happy_meal_init: happy_flags[%08x] ",
+	    hp->happy_flags);
 	if (!(hp->happy_flags & HFLAG_INIT)) {
-		HMD(("set HFLAG_INIT, "));
+		HMD("set HFLAG_INIT, ");
 		hp->happy_flags |= HFLAG_INIT;
 		happy_meal_get_counters(hp, bregs);
 	}
 
 	/* Stop polling. */
-	HMD(("to happy_meal_poll_stop\n"));
+	HMD("to happy_meal_poll_stop\n");
 	happy_meal_poll_stop(hp, tregs);
 
 	/* Stop transmitter and receiver. */
-	HMD(("happy_meal_init: to happy_meal_stop\n"));
+	HMD("happy_meal_init: to happy_meal_stop\n");
 	happy_meal_stop(hp, gregs);
 
 	/* Alloc and reset the tx/rx descriptor chains. */
-	HMD(("happy_meal_init: to happy_meal_init_rings\n"));
+	HMD("happy_meal_init: to happy_meal_init_rings\n");
 	happy_meal_init_rings(hp);
 
 	/* Shut up the MIF. */
-	HMD(("happy_meal_init: Disable all MIF irqs (old[%08x]), ",
-	     hme_read32(hp, tregs + TCVR_IMASK)));
+	HMD("happy_meal_init: Disable all MIF irqs (old[%08x]), ",
+	    hme_read32(hp, tregs + TCVR_IMASK));
 	hme_write32(hp, tregs + TCVR_IMASK, 0xffff);
 
 	/* See if we can enable the MIF frame on this card to speak to the DP83840. */
 	if (hp->happy_flags & HFLAG_FENABLE) {
-		HMD(("use frame old[%08x], ",
-		     hme_read32(hp, tregs + TCVR_CFG)));
+		HMD("use frame old[%08x], ",
+		    hme_read32(hp, tregs + TCVR_CFG));
 		hme_write32(hp, tregs + TCVR_CFG,
 			    hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE));
 	} else {
-		HMD(("use bitbang old[%08x], ",
-		     hme_read32(hp, tregs + TCVR_CFG)));
+		HMD("use bitbang old[%08x], ",
+		    hme_read32(hp, tregs + TCVR_CFG));
 		hme_write32(hp, tregs + TCVR_CFG,
 			    hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE);
 	}
 
 	/* Check the state of the transceiver. */
-	HMD(("to happy_meal_transceiver_check\n"));
+	HMD("to happy_meal_transceiver_check\n");
 	happy_meal_transceiver_check(hp, tregs);
 
 	/* Put the Big Mac into a sane state. */
-	HMD(("happy_meal_init: "));
+	HMD("happy_meal_init: ");
 	switch(hp->tcvr_type) {
 	case none:
 		/* Cannot operate if we don't know the transceiver type! */
-		HMD(("AAIEEE no transceiver type, EAGAIN"));
+		HMD("AAIEEE no transceiver type, EAGAIN");
 		return -EAGAIN;
 
 	case internal:
 		/* Using the MII buffers. */
-		HMD(("internal, using MII, "));
+		HMD("internal, using MII, ");
 		hme_write32(hp, bregs + BMAC_XIFCFG, 0);
 		break;
 
 	case external:
 		/* Not using the MII, disable it. */
-		HMD(("external, disable MII, "));
+		HMD("external, disable MII, ");
 		hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB);
 		break;
 	}
@@ -1431,18 +1431,18 @@ static int happy_meal_init(struct happy_meal *hp)
 		return -EAGAIN;
 
 	/* Reset the Happy Meal Big Mac transceiver and the receiver. */
-	HMD(("tx/rx reset, "));
+	HMD("tx/rx reset, ");
 	happy_meal_tx_reset(hp, bregs);
 	happy_meal_rx_reset(hp, bregs);
 
 	/* Set jam size and inter-packet gaps to reasonable defaults. */
-	HMD(("jsize/ipg1/ipg2, "));
+	HMD("jsize/ipg1/ipg2, ");
 	hme_write32(hp, bregs + BMAC_JSIZE, DEFAULT_JAMSIZE);
 	hme_write32(hp, bregs + BMAC_IGAP1, DEFAULT_IPG1);
 	hme_write32(hp, bregs + BMAC_IGAP2, DEFAULT_IPG2);
 
 	/* Load up the MAC address and random seed. */
-	HMD(("rseed/macaddr, "));
+	HMD("rseed/macaddr, ");
 
 	/* The docs recommend to use the 10LSB of our MAC here. */
 	hme_write32(hp, bregs + BMAC_RSEED, ((e[5] | e[4]<<8)&0x3ff));
@@ -1451,7 +1451,7 @@ static int happy_meal_init(struct happy_meal *hp)
 	hme_write32(hp, bregs + BMAC_MACADDR1, ((e[2] << 8) | e[3]));
 	hme_write32(hp, bregs + BMAC_MACADDR0, ((e[0] << 8) | e[1]));
 
-	HMD(("htable, "));
+	HMD("htable, ");
 	if ((hp->dev->flags & IFF_ALLMULTI) ||
 	    (netdev_mc_count(hp->dev) > 64)) {
 		hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff);
@@ -1481,9 +1481,9 @@ static int happy_meal_init(struct happy_meal *hp)
 	}
 
 	/* Set the RX and TX ring ptrs. */
-	HMD(("ring ptrs rxr[%08x] txr[%08x]\n",
-	     ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)),
-	     ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))));
+	HMD("ring ptrs rxr[%08x] txr[%08x]\n",
+	    ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)),
+	    ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0)));
 	hme_write32(hp, erxregs + ERX_RING,
 		    ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)));
 	hme_write32(hp, etxregs + ETX_RING,
@@ -1501,8 +1501,8 @@ static int happy_meal_init(struct happy_meal *hp)
 			    | 0x4);
 
 	/* Set the supported burst sizes. */
-	HMD(("happy_meal_init: old[%08x] bursts<",
-	     hme_read32(hp, gregs + GREG_CFG)));
+	HMD("happy_meal_init: old[%08x] bursts<",
+	    hme_read32(hp, gregs + GREG_CFG));
 
 #ifndef CONFIG_SPARC
 	/* It is always PCI and can handle 64byte bursts. */
@@ -1531,34 +1531,34 @@ static int happy_meal_init(struct happy_meal *hp)
 		}
 #endif
 
-		HMD(("64>"));
+		HMD("64>");
 		hme_write32(hp, gregs + GREG_CFG, gcfg);
 	} else if (hp->happy_bursts & DMA_BURST32) {
-		HMD(("32>"));
+		HMD("32>");
 		hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST32);
 	} else if (hp->happy_bursts & DMA_BURST16) {
-		HMD(("16>"));
+		HMD("16>");
 		hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST16);
 	} else {
-		HMD(("XXX>"));
+		HMD("XXX>");
 		hme_write32(hp, gregs + GREG_CFG, 0);
 	}
 #endif /* CONFIG_SPARC */
 
 	/* Turn off interrupts we do not want to hear. */
-	HMD((", enable global interrupts, "));
+	HMD(", enable global interrupts, ");
 	hme_write32(hp, gregs + GREG_IMASK,
 		    (GREG_IMASK_GOTFRAME | GREG_IMASK_RCNTEXP |
 		     GREG_IMASK_SENTFRAME | GREG_IMASK_TXPERR));
 
 	/* Set the transmit ring buffer size. */
-	HMD(("tx rsize=%d oreg[%08x], ", (int)TX_RING_SIZE,
-	     hme_read32(hp, etxregs + ETX_RSIZE)));
+	HMD("tx rsize=%d oreg[%08x], ", (int)TX_RING_SIZE,
+	    hme_read32(hp, etxregs + ETX_RSIZE));
 	hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1);
 
 	/* Enable transmitter DVMA. */
-	HMD(("tx dma enable old[%08x], ",
-	     hme_read32(hp, etxregs + ETX_CFG)));
+	HMD("tx dma enable old[%08x], ",
+	    hme_read32(hp, etxregs + ETX_CFG));
 	hme_write32(hp, etxregs + ETX_CFG,
 		    hme_read32(hp, etxregs + ETX_CFG) | ETX_CFG_DMAENABLE);
 
@@ -1567,8 +1567,8 @@ static int happy_meal_init(struct happy_meal *hp)
 	 * properly.  I cannot think of a sane way to provide complete
 	 * coverage for this hardware bug yet.
 	 */
-	HMD(("erx regs bug old[%08x]\n",
-	     hme_read32(hp, erxregs + ERX_CFG)));
+	HMD("erx regs bug old[%08x]\n",
+	    hme_read32(hp, erxregs + ERX_CFG));
 	hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET));
 	regtmp = hme_read32(hp, erxregs + ERX_CFG);
 	hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET));
@@ -1580,8 +1580,8 @@ static int happy_meal_init(struct happy_meal *hp)
 	}
 
 	/* Enable Big Mac hash table filter. */
-	HMD(("happy_meal_init: enable hash rx_cfg_old[%08x], ",
-	     hme_read32(hp, bregs + BMAC_RXCFG)));
+	HMD("happy_meal_init: enable hash rx_cfg_old[%08x], ",
+	    hme_read32(hp, bregs + BMAC_RXCFG));
 	rxcfg = BIGMAC_RXCFG_HENABLE | BIGMAC_RXCFG_REJME;
 	if (hp->dev->flags & IFF_PROMISC)
 		rxcfg |= BIGMAC_RXCFG_PMISC;
@@ -1591,7 +1591,7 @@ static int happy_meal_init(struct happy_meal *hp)
 	udelay(10);
 
 	/* Ok, configure the Big Mac transmitter. */
-	HMD(("BIGMAC init, "));
+	HMD("BIGMAC init, ");
 	regtmp = 0;
 	if (hp->happy_flags & HFLAG_FULL)
 		regtmp |= BIGMAC_TXCFG_FULLDPLX;
@@ -1615,14 +1615,14 @@ static int happy_meal_init(struct happy_meal *hp)
 	if (hp->tcvr_type == external)
 		regtmp |= BIGMAC_XCFG_MIIDISAB;
 
-	HMD(("XIF config old[%08x], ",
-	     hme_read32(hp, bregs + BMAC_XIFCFG)));
+	HMD("XIF config old[%08x], ",
+	    hme_read32(hp, bregs + BMAC_XIFCFG));
 	hme_write32(hp, bregs + BMAC_XIFCFG, regtmp);
 
 	/* Start things up. */
-	HMD(("tx old[%08x] and rx [%08x] ON!\n",
-	     hme_read32(hp, bregs + BMAC_TXCFG),
-	     hme_read32(hp, bregs + BMAC_RXCFG)));
+	HMD("tx old[%08x] and rx [%08x] ON!\n",
+	    hme_read32(hp, bregs + BMAC_TXCFG),
+	    hme_read32(hp, bregs + BMAC_RXCFG));
 
 	/* Set larger TX/RX size to allow for 802.1q */
 	hme_write32(hp, bregs + BMAC_TXMAX, ETH_FRAME_LEN + 8);
@@ -1843,9 +1843,9 @@ static void happy_meal_mif_interrupt(struct happy_meal *hp)
 }
 
 #ifdef TXDEBUG
-#define TXD(x) printk x
+#define TXD printk
 #else
-#define TXD(x)
+#define TXD(...)
 #endif
 
 /* hp->happy_lock must be held */
@@ -1857,13 +1857,13 @@ static void happy_meal_tx(struct happy_meal *hp)
 	int elem;
 
 	elem = hp->tx_old;
-	TXD(("TX<"));
+	TXD("TX<");
 	while (elem != hp->tx_new) {
 		struct sk_buff *skb;
 		u32 flags, dma_addr, dma_len;
 		int frag;
 
-		TXD(("[%d]", elem));
+		TXD("[%d]", elem);
 		this = &txbase[elem];
 		flags = hme_read_desc32(hp, &this->tx_flags);
 		if (flags & TXFLAG_OWN)
@@ -1899,7 +1899,7 @@ static void happy_meal_tx(struct happy_meal *hp)
 		dev->stats.tx_packets++;
 	}
 	hp->tx_old = elem;
-	TXD((">"));
+	TXD(">");
 
 	if (netif_queue_stopped(dev) &&
 	    TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1))
@@ -1907,9 +1907,9 @@ static void happy_meal_tx(struct happy_meal *hp)
 }
 
 #ifdef RXDEBUG
-#define RXD(x) printk x
+#define RXD printk
 #else
-#define RXD(x)
+#define RXD(...)
 #endif
 
 /* Originally I used to handle the allocation failure by just giving back just
@@ -1928,7 +1928,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	int elem = hp->rx_new, drops = 0;
 	u32 flags;
 
-	RXD(("RX<"));
+	RXD("RX<");
 	this = &rxbase[elem];
 	while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) {
 		struct sk_buff *skb;
@@ -1936,11 +1936,11 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 		u16 csum = flags & RXFLAG_CSUM;
 		u32 dma_addr = hme_read_desc32(hp, &this->rx_addr);
 
-		RXD(("[%d ", elem));
+		RXD("[%d ", elem);
 
 		/* Check for errors. */
 		if ((len < ETH_ZLEN) || (flags & RXFLAG_OVERFLOW)) {
-			RXD(("ERR(%08x)]", flags));
+			RXD("ERR(%08x)]", flags);
 			dev->stats.rx_errors++;
 			if (len < ETH_ZLEN)
 				dev->stats.rx_length_errors++;
@@ -2012,7 +2012,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 		skb->csum = csum_unfold(~(__force __sum16)htons(csum));
 		skb->ip_summed = CHECKSUM_COMPLETE;
 
-		RXD(("len=%d csum=%4x]", len, csum));
+		RXD("len=%d csum=%4x]", len, csum);
 		skb->protocol = eth_type_trans(skb, dev);
 		netif_rx(skb);
 
@@ -2025,7 +2025,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	hp->rx_new = elem;
 	if (drops)
 		printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", hp->dev->name);
-	RXD((">"));
+	RXD(">");
 }
 
 static irqreturn_t happy_meal_interrupt(int irq, void *dev_id)
@@ -2034,32 +2034,32 @@ static irqreturn_t happy_meal_interrupt(int irq, void *dev_id)
 	struct happy_meal *hp  = netdev_priv(dev);
 	u32 happy_status       = hme_read32(hp, hp->gregs + GREG_STAT);
 
-	HMD(("happy_meal_interrupt: status=%08x ", happy_status));
+	HMD("happy_meal_interrupt: status=%08x ", happy_status);
 
 	spin_lock(&hp->happy_lock);
 
 	if (happy_status & GREG_STAT_ERRORS) {
-		HMD(("ERRORS "));
+		HMD("ERRORS ");
 		if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status))
 			goto out;
 	}
 
 	if (happy_status & GREG_STAT_MIFIRQ) {
-		HMD(("MIFIRQ "));
+		HMD("MIFIRQ ");
 		happy_meal_mif_interrupt(hp);
 	}
 
 	if (happy_status & GREG_STAT_TXALL) {
-		HMD(("TXALL "));
+		HMD("TXALL ");
 		happy_meal_tx(hp);
 	}
 
 	if (happy_status & GREG_STAT_RXTOHOST) {
-		HMD(("RXTOHOST "));
+		HMD("RXTOHOST ");
 		happy_meal_rx(hp, dev);
 	}
 
-	HMD(("done\n"));
+	HMD("done\n");
 out:
 	spin_unlock(&hp->happy_lock);
 
@@ -2077,7 +2077,7 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
 		struct happy_meal *hp  = netdev_priv(dev);
 		u32 happy_status       = hme_read32(hp, hp->gregs + GREG_STAT);
 
-		HMD(("quattro_interrupt: status=%08x ", happy_status));
+		HMD("quattro_interrupt: status=%08x ", happy_status);
 
 		if (!(happy_status & (GREG_STAT_ERRORS |
 				      GREG_STAT_MIFIRQ |
@@ -2088,30 +2088,30 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
 		spin_lock(&hp->happy_lock);
 
 		if (happy_status & GREG_STAT_ERRORS) {
-			HMD(("ERRORS "));
+			HMD("ERRORS ");
 			if (happy_meal_is_not_so_happy(hp, happy_status))
 				goto next;
 		}
 
 		if (happy_status & GREG_STAT_MIFIRQ) {
-			HMD(("MIFIRQ "));
+			HMD("MIFIRQ ");
 			happy_meal_mif_interrupt(hp);
 		}
 
 		if (happy_status & GREG_STAT_TXALL) {
-			HMD(("TXALL "));
+			HMD("TXALL ");
 			happy_meal_tx(hp);
 		}
 
 		if (happy_status & GREG_STAT_RXTOHOST) {
-			HMD(("RXTOHOST "));
+			HMD("RXTOHOST ");
 			happy_meal_rx(hp, dev);
 		}
 
 	next:
 		spin_unlock(&hp->happy_lock);
 	}
-	HMD(("done\n"));
+	HMD("done\n");
 
 	return IRQ_HANDLED;
 }
@@ -2122,7 +2122,7 @@ static int happy_meal_open(struct net_device *dev)
 	struct happy_meal *hp = netdev_priv(dev);
 	int res;
 
-	HMD(("happy_meal_open: "));
+	HMD("happy_meal_open: ");
 
 	/* On SBUS Quattro QFE cards, all hme interrupts are concentrated
 	 * into a single source which we register handling at probe time.
@@ -2131,7 +2131,7 @@ static int happy_meal_open(struct net_device *dev)
 		res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED,
 				  dev->name, dev);
 		if (res) {
-			HMD(("EAGAIN\n"));
+			HMD("EAGAIN\n");
 			printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n",
 			       hp->irq);
 
@@ -2139,7 +2139,7 @@ static int happy_meal_open(struct net_device *dev)
 		}
 	}
 
-	HMD(("to happy_meal_init\n"));
+	HMD("to happy_meal_init\n");
 
 	spin_lock_irq(&hp->happy_lock);
 	res = happy_meal_init(hp);
@@ -2174,9 +2174,9 @@ static int happy_meal_close(struct net_device *dev)
 }
 
 #ifdef SXDEBUG
-#define SXD(x) printk x
+#define SXD printk
 #else
-#define SXD(x)
+#define SXD(...)
 #endif
 
 static void happy_meal_tx_timeout(struct net_device *dev, unsigned int txqueue)
@@ -2244,7 +2244,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 	}
 
 	entry = hp->tx_new;
-	SXD(("SX<l[%d]e[%d]>", len, entry));
+	SXD("SX<l[%d]e[%d]>", len, entry);
 	hp->tx_skbs[entry] = skb;
 
 	if (skb_shinfo(skb)->nr_frags == 0) {
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 08/13] sunhme: Clean up debug infrastructure
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (6 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 07/13] sumhme: Convert FOO((...)) to FOO(...) Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 09/13] sunhme: Convert printk(KERN_FOO ...) to pr_foo(...) Sean Anderson
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

Remove all the single-use debug conditionals, and just collect the debug
defines at the top of the file. HMD seems like it is used for general debug
info, so just redefine it as pr_debug. Additionally, instead of using the
default loglevel, use the debug loglevel for debugging.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 72 ++++++++++++++-----------------
 1 file changed, 32 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 16b81beb3ffb..ae206d552c27 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -80,13 +80,37 @@ static struct quattro *qfe_sbus_list;
 static struct quattro *qfe_pci_list;
 #endif
 
-#undef HMEDEBUG
-#undef SXDEBUG
-#undef RXDEBUG
-#undef TXDEBUG
-#undef TXLOGGING
+#define HMD pr_debug
 
-#ifdef TXLOGGING
+/* "Auto Switch Debug" aka phy debug */
+#if 0
+#define ASD pr_debug
+#else
+#define ASD(...)
+#endif
+
+/* Transmit debug */
+#if 0
+#define TXD pr_debug
+#else
+#define TXD(...)
+#endif
+
+/* Skid buffer debug */
+#if 0
+#define SXD pr_debug
+#else
+#define SXD(...)
+#endif
+
+/* Receive debug */
+#if 0
+#define RXD pr_debug
+#else
+#define RXD(...)
+#endif
+
+#if 0
 struct hme_tx_logent {
 	unsigned int tstamp;
 	int tx_new, tx_old;
@@ -129,22 +153,8 @@ static __inline__ void tx_dump_log(void)
 	}
 }
 #else
-#define tx_add_log(hp, a, s)		do { } while(0)
-#define tx_dump_log()			do { } while(0)
-#endif
-
-#ifdef HMEDEBUG
-#define HMD printk
-#else
-#define HMD(...)
-#endif
-
-/* #define AUTO_SWITCH_DEBUG */
-
-#ifdef AUTO_SWITCH_DEBUG
-#define ASD printk
-#else
-#define ASD(...)
+#define tx_add_log(hp, a, s)
+#define tx_dump_log()
 #endif
 
 #define DEFAULT_IPG0      16 /* For lance-mode only */
@@ -1842,12 +1852,6 @@ static void happy_meal_mif_interrupt(struct happy_meal *hp)
 	happy_meal_poll_stop(hp, tregs);
 }
 
-#ifdef TXDEBUG
-#define TXD printk
-#else
-#define TXD(...)
-#endif
-
 /* hp->happy_lock must be held */
 static void happy_meal_tx(struct happy_meal *hp)
 {
@@ -1906,12 +1910,6 @@ static void happy_meal_tx(struct happy_meal *hp)
 		netif_wake_queue(dev);
 }
 
-#ifdef RXDEBUG
-#define RXD printk
-#else
-#define RXD(...)
-#endif
-
 /* Originally I used to handle the allocation failure by just giving back just
  * that one ring buffer to the happy meal.  Problem is that usually when that
  * condition is triggered, the happy meal expects you to do something reasonable
@@ -2173,12 +2171,6 @@ static int happy_meal_close(struct net_device *dev)
 	return 0;
 }
 
-#ifdef SXDEBUG
-#define SXD printk
-#else
-#define SXD(...)
-#endif
-
 static void happy_meal_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
 	struct happy_meal *hp = netdev_priv(dev);
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 09/13] sunhme: Convert printk(KERN_FOO ...) to pr_foo(...)
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (7 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 08/13] sunhme: Clean up debug infrastructure Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 10/13] sunhme: Use (net)dev_foo wherever possible Sean Anderson
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

This is a mostly-mechanical translation of the existing printks into
pr_foos. In several places, I have pasted messages which were broken over
several lines to allow for easier grepping.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 152 +++++++++++++++---------------
 1 file changed, 78 insertions(+), 74 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index ae206d552c27..fab0c73e27ed 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -145,7 +145,7 @@ static __inline__ void tx_dump_log(void)
 
 	this = txlog_cur_entry;
 	for (i = 0; i < TX_LOG_LEN; i++) {
-		printk("TXLOG[%d]: j[%08x] tx[N(%d)O(%d)] action[%08x] stat[%08x]\n", i,
+		pr_err("TXLOG[%d]: j[%08x] tx[N(%d)O(%d)] action[%08x] stat[%08x]\n", i,
 		       tx_log[this].tstamp,
 		       tx_log[this].tx_new, tx_log[this].tx_old,
 		       tx_log[this].action, tx_log[this].status);
@@ -436,7 +436,7 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 	while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
 		udelay(20);
 	if (!tries) {
-		printk(KERN_ERR "happy meal: Aieee, transceiver MIF read bolixed\n");
+		pr_err("happy meal: Aieee, transceiver MIF read bolixed\n");
 		return TCVR_FAILURE;
 	}
 	retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff;
@@ -469,7 +469,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
 
 	/* Anything else? */
 	if (!tries)
-		printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");
+		pr_err("happy meal: Aieee, transceiver MIF write bolixed\n");
 
 	/* Fifty-two cents is your change, have a nice day. */
 }
@@ -647,8 +647,8 @@ static void happy_meal_timer(struct timer_list *t)
 			/* Enter force mode. */
 	do_force_mode:
 			hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
-			printk(KERN_NOTICE "%s: Auto-Negotiation unsuccessful, trying force link mode\n",
-			       hp->dev->name);
+			pr_notice("%s: Auto-Negotiation unsuccessful, trying force link mode\n",
+				  hp->dev->name);
 			hp->sw_bmcr = BMCR_SPEED100;
 			happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -707,8 +707,8 @@ static void happy_meal_timer(struct timer_list *t)
 			restart_timer = 0;
 		} else {
 			if (hp->timer_ticks >= 10) {
-				printk(KERN_NOTICE "%s: Auto negotiation successful, link still "
-				       "not completely up.\n", hp->dev->name);
+				pr_notice("%s: Auto negotiation successful, link still not completely up.\n",
+					  hp->dev->name);
 				hp->timer_ticks = 0;
 				restart_timer = 1;
 			} else {
@@ -763,14 +763,14 @@ static void happy_meal_timer(struct timer_list *t)
 					 */
 
 					/* Let the user know... */
-					printk(KERN_NOTICE "%s: Link down, cable problem?\n",
-					       hp->dev->name);
+					pr_notice("%s: Link down, cable problem?\n",
+						  hp->dev->name);
 
 					ret = happy_meal_init(hp);
 					if (ret) {
 						/* ho hum... */
-						printk(KERN_ERR "%s: Error, cannot re-init the "
-						       "Happy Meal.\n", hp->dev->name);
+						pr_err("%s: Error, cannot re-init the Happy Meal.\n",
+						       hp->dev->name);
 					}
 					goto out;
 				}
@@ -792,7 +792,7 @@ static void happy_meal_timer(struct timer_list *t)
 	case asleep:
 	default:
 		/* Can't happens.... */
-		printk(KERN_ERR "%s: Aieee, link timer is asleep but we got one anyways!\n",
+		pr_err("%s: Aieee, link timer is asleep but we got one anyways!\n",
 		       hp->dev->name);
 		restart_timer = 0;
 		hp->timer_ticks = 0;
@@ -826,7 +826,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 
 	/* Lettuce, tomato, buggy hardware (no extra charge)? */
 	if (!tries)
-		printk(KERN_ERR "happy meal: Transceiver BigMac ATTACK!");
+		pr_err("happy meal: Transceiver BigMac ATTACK!");
 
 	/* Take care. */
 	HMD("done\n");
@@ -846,7 +846,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 
 	/* Will that be all? */
 	if (!tries)
-		printk(KERN_ERR "happy meal: Receiver BigMac ATTACK!");
+		pr_err("happy meal: Receiver BigMac ATTACK!");
 
 	/* Don't forget your vik_1137125_wa.  Have a nice day. */
 	HMD("done\n");
@@ -868,7 +868,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 
 	/* Come back next week when we are "Sun Microelectronics". */
 	if (!tries)
-		printk(KERN_ERR "happy meal: Fry guys.");
+		pr_err("happy meal: Fry guys.");
 
 	/* Remember: "Different name, same old buggy as shit hardware." */
 	HMD("done\n");
@@ -1086,7 +1086,7 @@ static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tr
 				hp->tcvr_type = internal;
 				ASD("<internal>\n");
 			} else {
-				printk(KERN_ERR "happy meal: Transceiver and a coke please.");
+				pr_err("happy meal: Transceiver and a coke please.");
 				hp->tcvr_type = none; /* Grrr... */
 				ASD("<none>\n");
 			}
@@ -1311,10 +1311,10 @@ happy_meal_begin_auto_negotiation(struct happy_meal *hp,
 			udelay(10);
 		}
 		if (!timeout) {
-			printk(KERN_ERR "%s: Happy Meal would not start auto negotiation "
-			       "BMCR=0x%04x\n", hp->dev->name, hp->sw_bmcr);
-			printk(KERN_NOTICE "%s: Performing force link detection.\n",
-			       hp->dev->name);
+			pr_err("%s: Happy Meal would not start auto negotiation BMCR=0x%04x\n",
+			       hp->dev->name, hp->sw_bmcr);
+			pr_notice("%s: Performing force link detection.\n",
+				  hp->dev->name);
 			goto force_link;
 		} else {
 			hp->timer_state = arbwait;
@@ -1583,8 +1583,8 @@ static int happy_meal_init(struct happy_meal *hp)
 	regtmp = hme_read32(hp, erxregs + ERX_CFG);
 	hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET));
 	if (hme_read32(hp, erxregs + ERX_CFG) != ERX_CFG_DEFAULT(RX_OFFSET)) {
-		printk(KERN_ERR "happy meal: Eieee, rx config register gets greasy fries.\n");
-		printk(KERN_ERR "happy meal: Trying to set %08x, reread gives %08x\n",
+		pr_err("happy meal: Eieee, rx config register gets greasy fries.\n");
+		pr_err("happy meal: Trying to set %08x, reread gives %08x\n",
 		       ERX_CFG_DEFAULT(RX_OFFSET), regtmp);
 		/* XXX Should return failure here... */
 	}
@@ -1722,24 +1722,26 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		      GREG_STAT_MIFIRQ | GREG_STAT_TXEACK | GREG_STAT_TXLERR |
 		      GREG_STAT_TXPERR | GREG_STAT_TXTERR | GREG_STAT_SLVERR |
 		      GREG_STAT_SLVPERR))
-		printk(KERN_ERR "%s: Error interrupt for happy meal, status = %08x\n",
+		pr_err("%s: Error interrupt for happy meal, status = %08x\n",
 		       hp->dev->name, status);
 
 	if (status & GREG_STAT_RFIFOVF) {
 		/* Receive FIFO overflow is harmless and the hardware will take
 		   care of it, just some packets are lost. Who cares. */
-		printk(KERN_DEBUG "%s: Happy Meal receive FIFO overflow.\n", hp->dev->name);
+		pr_debug("%s: Happy Meal receive FIFO overflow.\n",
+			 hp->dev->name);
 	}
 
 	if (status & GREG_STAT_STSTERR) {
 		/* BigMAC SQE link test failed. */
-		printk(KERN_ERR "%s: Happy Meal BigMAC SQE test failed.\n", hp->dev->name);
+		pr_err("%s: Happy Meal BigMAC SQE test failed.\n",
+		       hp->dev->name);
 		reset = 1;
 	}
 
 	if (status & GREG_STAT_TFIFO_UND) {
 		/* Transmit FIFO underrun, again DMA error likely. */
-		printk(KERN_ERR "%s: Happy Meal transmitter FIFO underrun, DMA error.\n",
+		pr_err("%s: Happy Meal transmitter FIFO underrun, DMA error.\n",
 		       hp->dev->name);
 		reset = 1;
 	}
@@ -1748,7 +1750,8 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Driver error, tried to transmit something larger
 		 * than ethernet max mtu.
 		 */
-		printk(KERN_ERR "%s: Happy Meal MAX Packet size error.\n", hp->dev->name);
+		pr_err("%s: Happy Meal MAX Packet size error.\n",
+		       hp->dev->name);
 		reset = 1;
 	}
 
@@ -1758,14 +1761,13 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		 * faster than the interrupt handler could keep up
 		 * with.
 		 */
-		printk(KERN_INFO "%s: Happy Meal out of receive "
-		       "descriptors, packet dropped.\n",
-		       hp->dev->name);
+		pr_info("%s: Happy Meal out of receive descriptors, packet dropped.\n",
+			hp->dev->name);
 	}
 
 	if (status & (GREG_STAT_RXERR|GREG_STAT_RXPERR|GREG_STAT_RXTERR)) {
 		/* All sorts of DMA receive errors. */
-		printk(KERN_ERR "%s: Happy Meal rx DMA errors [ ", hp->dev->name);
+		pr_err("%s: Happy Meal rx DMA errors [ ", hp->dev->name);
 		if (status & GREG_STAT_RXERR)
 			printk("GenericError ");
 		if (status & GREG_STAT_RXPERR)
@@ -1780,20 +1782,20 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Driver bug, didn't set EOP bit in tx descriptor given
 		 * to the happy meal.
 		 */
-		printk(KERN_ERR "%s: EOP not set in happy meal transmit descriptor!\n",
+		pr_err("%s: EOP not set in happy meal transmit descriptor!\n",
 		       hp->dev->name);
 		reset = 1;
 	}
 
 	if (status & GREG_STAT_MIFIRQ) {
 		/* MIF signalled an interrupt, were we polling it? */
-		printk(KERN_ERR "%s: Happy Meal MIF interrupt.\n", hp->dev->name);
+		pr_err("%s: Happy Meal MIF interrupt.\n", hp->dev->name);
 	}
 
 	if (status &
 	    (GREG_STAT_TXEACK|GREG_STAT_TXLERR|GREG_STAT_TXPERR|GREG_STAT_TXTERR)) {
 		/* All sorts of transmit DMA errors. */
-		printk(KERN_ERR "%s: Happy Meal tx DMA errors [ ", hp->dev->name);
+		pr_err("%s: Happy Meal tx DMA errors [ ", hp->dev->name);
 		if (status & GREG_STAT_TXEACK)
 			printk("GenericError ");
 		if (status & GREG_STAT_TXLERR)
@@ -1810,14 +1812,14 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Bus or parity error when cpu accessed happy meal registers
 		 * or it's internal FIFO's.  Should never see this.
 		 */
-		printk(KERN_ERR "%s: Happy Meal register access SBUS slave (%s) error.\n",
+		pr_err("%s: Happy Meal register access SBUS slave (%s) error.\n",
 		       hp->dev->name,
 		       (status & GREG_STAT_SLVPERR) ? "parity" : "generic");
 		reset = 1;
 	}
 
 	if (reset) {
-		printk(KERN_NOTICE "%s: Resetting...\n", hp->dev->name);
+		pr_notice("%s: Resetting...\n", hp->dev->name);
 		happy_meal_init(hp);
 		return 1;
 	}
@@ -1829,22 +1831,25 @@ static void happy_meal_mif_interrupt(struct happy_meal *hp)
 {
 	void __iomem *tregs = hp->tcvregs;
 
-	printk(KERN_INFO "%s: Link status change.\n", hp->dev->name);
+	pr_info("%s: Link status change.\n", hp->dev->name);
 	hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 	hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA);
 
 	/* Use the fastest transmission protocol possible. */
 	if (hp->sw_lpa & LPA_100FULL) {
-		printk(KERN_INFO "%s: Switching to 100Mbps at full duplex.", hp->dev->name);
+		pr_info("%s: Switching to 100Mbps at full duplex.",
+			hp->dev->name);
 		hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100);
 	} else if (hp->sw_lpa & LPA_100HALF) {
-		printk(KERN_INFO "%s: Switching to 100MBps at half duplex.", hp->dev->name);
+		pr_info("%s: Switching to 100MBps at half duplex.",
+			hp->dev->name);
 		hp->sw_bmcr |= BMCR_SPEED100;
 	} else if (hp->sw_lpa & LPA_10FULL) {
-		printk(KERN_INFO "%s: Switching to 10MBps at full duplex.", hp->dev->name);
+		pr_info("%s: Switching to 10MBps at full duplex.",
+			hp->dev->name);
 		hp->sw_bmcr |= BMCR_FULLDPLX;
 	} else {
-		printk(KERN_INFO "%s: Using 10Mbps at half duplex.", hp->dev->name);
+		pr_info("%s: Using 10Mbps at half duplex.", hp->dev->name);
 	}
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -2022,7 +2027,8 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	}
 	hp->rx_new = elem;
 	if (drops)
-		printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", hp->dev->name);
+		pr_info("%s: Memory squeeze, deferring packet.\n",
+			hp->dev->name);
 	RXD(">");
 }
 
@@ -2130,7 +2136,7 @@ static int happy_meal_open(struct net_device *dev)
 				  dev->name, dev);
 		if (res) {
 			HMD("EAGAIN\n");
-			printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n",
+			pr_err("happy_meal(SBUS): Can't order irq %d to go.\n",
 			       hp->irq);
 
 			return -EAGAIN;
@@ -2175,12 +2181,12 @@ static void happy_meal_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
 	struct happy_meal *hp = netdev_priv(dev);
 
-	printk (KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
+	pr_err("%s: transmit timed out, resetting\n", dev->name);
 	tx_dump_log();
-	printk (KERN_ERR "%s: Happy Status %08x TX[%08x:%08x]\n", dev->name,
-		hme_read32(hp, hp->gregs + GREG_STAT),
-		hme_read32(hp, hp->etxregs + ETX_CFG),
-		hme_read32(hp, hp->bigmacregs + BMAC_TXCFG));
+	pr_err("%s: Happy Status %08x TX[%08x:%08x]\n", dev->name,
+	       hme_read32(hp, hp->gregs + GREG_STAT),
+	       hme_read32(hp, hp->etxregs + ETX_CFG),
+	       hme_read32(hp, hp->bigmacregs + BMAC_TXCFG));
 
 	spin_lock_irq(&hp->happy_lock);
 	happy_meal_init(hp);
@@ -2230,7 +2236,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 	if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) {
 		netif_stop_queue(dev);
 		spin_unlock_irq(&hp->happy_lock);
-		printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n",
+		pr_err("%s: BUG! Tx Ring full when queue awake!\n",
 		       dev->name);
 		return NETDEV_TX_BUSY;
 	}
@@ -2529,8 +2535,8 @@ static int __init quattro_sbus_register_irqs(void)
 				  IRQF_SHARED, "Quattro",
 				  qp);
 		if (err != 0) {
-			printk(KERN_ERR "Quattro HME: IRQ registration "
-			       "error %d.\n", err);
+			pr_err("Quattro HME: IRQ registration error %d.\n",
+			       err);
 			return err;
 		}
 	}
@@ -2638,7 +2644,7 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 	SET_NETDEV_DEV(dev, &op->dev);
 
 	if (hme_version_printed++ == 0)
-		printk(KERN_INFO "%s", version);
+		pr_info("%s", version);
 
 	/* If user did not specify a MAC address specifically, use
 	 * the Quattro local-mac-address property...
@@ -2681,35 +2687,35 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 	hp->gregs = of_ioremap(&op->resource[0], 0,
 			       GREG_REG_SIZE, "HME Global Regs");
 	if (!hp->gregs) {
-		printk(KERN_ERR "happymeal: Cannot map global registers.\n");
+		pr_err("happymeal: Cannot map global registers.\n");
 		goto err_out_free_netdev;
 	}
 
 	hp->etxregs = of_ioremap(&op->resource[1], 0,
 				 ETX_REG_SIZE, "HME TX Regs");
 	if (!hp->etxregs) {
-		printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n");
+		pr_err("happymeal: Cannot map MAC TX registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->erxregs = of_ioremap(&op->resource[2], 0,
 				 ERX_REG_SIZE, "HME RX Regs");
 	if (!hp->erxregs) {
-		printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n");
+		pr_err("happymeal: Cannot map MAC RX registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->bigmacregs = of_ioremap(&op->resource[3], 0,
 				    BMAC_REG_SIZE, "HME BIGMAC Regs");
 	if (!hp->bigmacregs) {
-		printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n");
+		pr_err("happymeal: Cannot map BIGMAC registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->tcvregs = of_ioremap(&op->resource[4], 0,
 				 TCVR_REG_SIZE, "HME Tranceiver Regs");
 	if (!hp->tcvregs) {
-		printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n");
+		pr_err("happymeal: Cannot map TCVR registers.\n");
 		goto err_out_iounmap;
 	}
 
@@ -2776,19 +2782,18 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 
 	err = register_netdev(hp->dev);
 	if (err) {
-		printk(KERN_ERR "happymeal: Cannot register net device, "
-		       "aborting.\n");
+		pr_err("happymeal: Cannot register net device, aborting.\n");
 		goto err_out_free_coherent;
 	}
 
 	platform_set_drvdata(op, hp);
 
 	if (qfe_slot != -1)
-		printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
-		       dev->name, qfe_slot);
+		pr_info("%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
+			dev->name, qfe_slot);
 	else
-		printk(KERN_INFO "%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ",
-		       dev->name);
+		pr_info("%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ",
+			dev->name);
 
 	printk("%pM\n", dev->dev_addr);
 
@@ -2978,7 +2983,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	err = -EINVAL;
 	if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
-		printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
+		pr_err("happymeal(PCI): Cannot find proper PCI device base address.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -2986,15 +2991,14 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 					pci_resource_len(pdev, 0), DRV_NAME);
 	if (IS_ERR(hpreg_res)) {
 		err = PTR_ERR(hpreg_res);
-		printk(KERN_ERR "happymeal(PCI): Cannot obtain PCI resources, "
-		       "aborting.\n");
+		pr_err("happymeal(PCI): Cannot obtain PCI resources, aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
 	hpreg_base = pcim_iomap(pdev, 0, 0x8000);
 	err = -ENOMEM;
 	if (!hpreg_base) {
-		printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
+		pr_err("happymeal(PCI): Unable to remap card memory.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -3101,8 +3105,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	err = devm_register_netdev(&pdev->dev, dev);
 	if (err) {
-		printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
-		       "aborting.\n");
+		pr_err("happymeal(PCI): Cannot register net device, aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -3116,7 +3119,8 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 			int i = simple_strtoul(dev->name + 3, NULL, 10);
 			sprintf(prom_name, "-%d", i + 3);
 		}
-		printk(KERN_INFO "%s%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet ", dev->name, prom_name);
+		pr_info("%s%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet ",
+			dev->name, prom_name);
 		if (qpdev->vendor == PCI_VENDOR_ID_DEC &&
 		    qpdev->device == PCI_DEVICE_ID_DEC_21153)
 			printk("DEC 21153 PCI Bridge\n");
@@ -3126,11 +3130,11 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	}
 
 	if (qfe_slot != -1)
-		printk(KERN_INFO "%s: Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet ",
-		       dev->name, qfe_slot);
+		pr_info("%s: Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet ",
+			dev->name, qfe_slot);
 	else
-		printk(KERN_INFO "%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ",
-		       dev->name);
+		pr_info("%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ",
+			dev->name);
 
 	printk("%pM\n", dev->dev_addr);
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 10/13] sunhme: Use (net)dev_foo wherever possible
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (8 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 09/13] sunhme: Convert printk(KERN_FOO ...) to pr_foo(...) Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 11/13] sunhme: Combine continued messages Sean Anderson
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

Wherever possible, use the associated netdev (or device) when printing
errors or other messages. This makes it immediately clear what device
caused the error, and provides more information than just the device name.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 174 +++++++++++++++---------------
 1 file changed, 85 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index fab0c73e27ed..98c38e213bab 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -436,7 +436,7 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 	while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
 		udelay(20);
 	if (!tries) {
-		pr_err("happy meal: Aieee, transceiver MIF read bolixed\n");
+		netdev_err(hp->dev, "Aieee, transceiver MIF read bolixed\n");
 		return TCVR_FAILURE;
 	}
 	retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff;
@@ -469,7 +469,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
 
 	/* Anything else? */
 	if (!tries)
-		pr_err("happy meal: Aieee, transceiver MIF write bolixed\n");
+		netdev_err(hp->dev, "Aieee, transceiver MIF write bolixed\n");
 
 	/* Fifty-two cents is your change, have a nice day. */
 }
@@ -647,8 +647,8 @@ static void happy_meal_timer(struct timer_list *t)
 			/* Enter force mode. */
 	do_force_mode:
 			hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
-			pr_notice("%s: Auto-Negotiation unsuccessful, trying force link mode\n",
-				  hp->dev->name);
+			netdev_notice(hp->dev,
+				      "Auto-Negotiation unsuccessful, trying force link mode\n");
 			hp->sw_bmcr = BMCR_SPEED100;
 			happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -707,8 +707,8 @@ static void happy_meal_timer(struct timer_list *t)
 			restart_timer = 0;
 		} else {
 			if (hp->timer_ticks >= 10) {
-				pr_notice("%s: Auto negotiation successful, link still not completely up.\n",
-					  hp->dev->name);
+				netdev_notice(hp->dev,
+					      "Auto negotiation successful, link still not completely up.\n");
 				hp->timer_ticks = 0;
 				restart_timer = 1;
 			} else {
@@ -763,14 +763,14 @@ static void happy_meal_timer(struct timer_list *t)
 					 */
 
 					/* Let the user know... */
-					pr_notice("%s: Link down, cable problem?\n",
-						  hp->dev->name);
+					netdev_notice(hp->dev,
+						      "Link down, cable problem?\n");
 
 					ret = happy_meal_init(hp);
 					if (ret) {
 						/* ho hum... */
-						pr_err("%s: Error, cannot re-init the Happy Meal.\n",
-						       hp->dev->name);
+						netdev_err(hp->dev,
+							   "Error, cannot re-init the Happy Meal.\n");
 					}
 					goto out;
 				}
@@ -792,8 +792,8 @@ static void happy_meal_timer(struct timer_list *t)
 	case asleep:
 	default:
 		/* Can't happens.... */
-		pr_err("%s: Aieee, link timer is asleep but we got one anyways!\n",
-		       hp->dev->name);
+		netdev_err(hp->dev,
+			   "Aieee, link timer is asleep but we got one anyways!\n");
 		restart_timer = 0;
 		hp->timer_ticks = 0;
 		hp->timer_state = asleep; /* foo on you */
@@ -826,7 +826,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 
 	/* Lettuce, tomato, buggy hardware (no extra charge)? */
 	if (!tries)
-		pr_err("happy meal: Transceiver BigMac ATTACK!");
+		netdev_err(hp->dev, "Transceiver BigMac ATTACK!");
 
 	/* Take care. */
 	HMD("done\n");
@@ -846,7 +846,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 
 	/* Will that be all? */
 	if (!tries)
-		pr_err("happy meal: Receiver BigMac ATTACK!");
+		netdev_err(hp->dev, "Receiver BigMac ATTACK!");
 
 	/* Don't forget your vik_1137125_wa.  Have a nice day. */
 	HMD("done\n");
@@ -868,7 +868,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 
 	/* Come back next week when we are "Sun Microelectronics". */
 	if (!tries)
-		pr_err("happy meal: Fry guys.");
+		netdev_err(hp->dev, "Fry guys.");
 
 	/* Remember: "Different name, same old buggy as shit hardware." */
 	HMD("done\n");
@@ -1086,7 +1086,8 @@ static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tr
 				hp->tcvr_type = internal;
 				ASD("<internal>\n");
 			} else {
-				pr_err("happy meal: Transceiver and a coke please.");
+				netdev_err(hp->dev,
+					   "Transceiver and a coke please.");
 				hp->tcvr_type = none; /* Grrr... */
 				ASD("<none>\n");
 			}
@@ -1282,7 +1283,7 @@ happy_meal_begin_auto_negotiation(struct happy_meal *hp,
 		 */
 
 #ifdef AUTO_SWITCH_DEBUG
-		ASD("%s: Advertising [ ", hp->dev->name);
+		ASD("%s: Advertising [ ");
 		if (hp->sw_advertise & ADVERTISE_10HALF)
 			ASD("10H ");
 		if (hp->sw_advertise & ADVERTISE_10FULL)
@@ -1311,10 +1312,11 @@ happy_meal_begin_auto_negotiation(struct happy_meal *hp,
 			udelay(10);
 		}
 		if (!timeout) {
-			pr_err("%s: Happy Meal would not start auto negotiation BMCR=0x%04x\n",
-			       hp->dev->name, hp->sw_bmcr);
-			pr_notice("%s: Performing force link detection.\n",
-				  hp->dev->name);
+			netdev_err(hp->dev,
+				   "Happy Meal would not start auto negotiation BMCR=0x%04x\n",
+				   hp->sw_bmcr);
+			netdev_notice(hp->dev,
+				      "Performing force link detection.\n");
 			goto force_link;
 		} else {
 			hp->timer_state = arbwait;
@@ -1583,9 +1585,11 @@ static int happy_meal_init(struct happy_meal *hp)
 	regtmp = hme_read32(hp, erxregs + ERX_CFG);
 	hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET));
 	if (hme_read32(hp, erxregs + ERX_CFG) != ERX_CFG_DEFAULT(RX_OFFSET)) {
-		pr_err("happy meal: Eieee, rx config register gets greasy fries.\n");
-		pr_err("happy meal: Trying to set %08x, reread gives %08x\n",
-		       ERX_CFG_DEFAULT(RX_OFFSET), regtmp);
+		netdev_err(hp->dev,
+			   "Eieee, rx config register gets greasy fries.\n");
+		netdev_err(hp->dev,
+			   "Trying to set %08x, reread gives %08x\n",
+			   ERX_CFG_DEFAULT(RX_OFFSET), regtmp);
 		/* XXX Should return failure here... */
 	}
 
@@ -1722,27 +1726,26 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		      GREG_STAT_MIFIRQ | GREG_STAT_TXEACK | GREG_STAT_TXLERR |
 		      GREG_STAT_TXPERR | GREG_STAT_TXTERR | GREG_STAT_SLVERR |
 		      GREG_STAT_SLVPERR))
-		pr_err("%s: Error interrupt for happy meal, status = %08x\n",
-		       hp->dev->name, status);
+		netdev_err(hp->dev,
+			   "Error interrupt for happy meal, status = %08x\n",
+			   status);
 
 	if (status & GREG_STAT_RFIFOVF) {
 		/* Receive FIFO overflow is harmless and the hardware will take
 		   care of it, just some packets are lost. Who cares. */
-		pr_debug("%s: Happy Meal receive FIFO overflow.\n",
-			 hp->dev->name);
+		netdev_dbg(hp->dev, "Happy Meal receive FIFO overflow.\n");
 	}
 
 	if (status & GREG_STAT_STSTERR) {
 		/* BigMAC SQE link test failed. */
-		pr_err("%s: Happy Meal BigMAC SQE test failed.\n",
-		       hp->dev->name);
+		netdev_err(hp->dev, "Happy Meal BigMAC SQE test failed.\n");
 		reset = 1;
 	}
 
 	if (status & GREG_STAT_TFIFO_UND) {
 		/* Transmit FIFO underrun, again DMA error likely. */
-		pr_err("%s: Happy Meal transmitter FIFO underrun, DMA error.\n",
-		       hp->dev->name);
+		netdev_err(hp->dev,
+			   "Happy Meal transmitter FIFO underrun, DMA error.\n");
 		reset = 1;
 	}
 
@@ -1750,8 +1753,7 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Driver error, tried to transmit something larger
 		 * than ethernet max mtu.
 		 */
-		pr_err("%s: Happy Meal MAX Packet size error.\n",
-		       hp->dev->name);
+		netdev_err(hp->dev, "Happy Meal MAX Packet size error.\n");
 		reset = 1;
 	}
 
@@ -1761,13 +1763,13 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		 * faster than the interrupt handler could keep up
 		 * with.
 		 */
-		pr_info("%s: Happy Meal out of receive descriptors, packet dropped.\n",
-			hp->dev->name);
+		netdev_info(hp->dev,
+			    "Happy Meal out of receive descriptors, packet dropped.\n");
 	}
 
 	if (status & (GREG_STAT_RXERR|GREG_STAT_RXPERR|GREG_STAT_RXTERR)) {
 		/* All sorts of DMA receive errors. */
-		pr_err("%s: Happy Meal rx DMA errors [ ", hp->dev->name);
+		netdev_err(hp->dev, "Happy Meal rx DMA errors [ ");
 		if (status & GREG_STAT_RXERR)
 			printk("GenericError ");
 		if (status & GREG_STAT_RXPERR)
@@ -1782,20 +1784,20 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Driver bug, didn't set EOP bit in tx descriptor given
 		 * to the happy meal.
 		 */
-		pr_err("%s: EOP not set in happy meal transmit descriptor!\n",
-		       hp->dev->name);
+		netdev_err(hp->dev,
+			   "EOP not set in happy meal transmit descriptor!\n");
 		reset = 1;
 	}
 
 	if (status & GREG_STAT_MIFIRQ) {
 		/* MIF signalled an interrupt, were we polling it? */
-		pr_err("%s: Happy Meal MIF interrupt.\n", hp->dev->name);
+		netdev_err(hp->dev, "Happy Meal MIF interrupt.\n");
 	}
 
 	if (status &
 	    (GREG_STAT_TXEACK|GREG_STAT_TXLERR|GREG_STAT_TXPERR|GREG_STAT_TXTERR)) {
 		/* All sorts of transmit DMA errors. */
-		pr_err("%s: Happy Meal tx DMA errors [ ", hp->dev->name);
+		netdev_err(hp->dev, "Happy Meal tx DMA errors [ ");
 		if (status & GREG_STAT_TXEACK)
 			printk("GenericError ");
 		if (status & GREG_STAT_TXLERR)
@@ -1812,14 +1814,14 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 		/* Bus or parity error when cpu accessed happy meal registers
 		 * or it's internal FIFO's.  Should never see this.
 		 */
-		pr_err("%s: Happy Meal register access SBUS slave (%s) error.\n",
-		       hp->dev->name,
-		       (status & GREG_STAT_SLVPERR) ? "parity" : "generic");
+		netdev_err(hp->dev,
+			   "Happy Meal register access SBUS slave (%s) error.\n",
+			   (status & GREG_STAT_SLVPERR) ? "parity" : "generic");
 		reset = 1;
 	}
 
 	if (reset) {
-		pr_notice("%s: Resetting...\n", hp->dev->name);
+		netdev_notice(hp->dev, "Resetting...\n");
 		happy_meal_init(hp);
 		return 1;
 	}
@@ -1831,25 +1833,22 @@ static void happy_meal_mif_interrupt(struct happy_meal *hp)
 {
 	void __iomem *tregs = hp->tcvregs;
 
-	pr_info("%s: Link status change.\n", hp->dev->name);
+	netdev_info(hp->dev, "Link status change.\n");
 	hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 	hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA);
 
 	/* Use the fastest transmission protocol possible. */
 	if (hp->sw_lpa & LPA_100FULL) {
-		pr_info("%s: Switching to 100Mbps at full duplex.",
-			hp->dev->name);
+		netdev_info(hp->dev, "Switching to 100Mbps at full duplex.");
 		hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100);
 	} else if (hp->sw_lpa & LPA_100HALF) {
-		pr_info("%s: Switching to 100MBps at half duplex.",
-			hp->dev->name);
+		netdev_info(hp->dev, "Switching to 100MBps at half duplex.");
 		hp->sw_bmcr |= BMCR_SPEED100;
 	} else if (hp->sw_lpa & LPA_10FULL) {
-		pr_info("%s: Switching to 10MBps at full duplex.",
-			hp->dev->name);
+		netdev_info(hp->dev, "Switching to 10MBps at full duplex.");
 		hp->sw_bmcr |= BMCR_FULLDPLX;
 	} else {
-		pr_info("%s: Using 10Mbps at half duplex.", hp->dev->name);
+		netdev_info(hp->dev, "Using 10Mbps at half duplex.");
 	}
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -2027,8 +2026,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	}
 	hp->rx_new = elem;
 	if (drops)
-		pr_info("%s: Memory squeeze, deferring packet.\n",
-			hp->dev->name);
+		netdev_info(hp->dev, "Memory squeeze, deferring packet.\n");
 	RXD(">");
 }
 
@@ -2136,8 +2134,7 @@ static int happy_meal_open(struct net_device *dev)
 				  dev->name, dev);
 		if (res) {
 			HMD("EAGAIN\n");
-			pr_err("happy_meal(SBUS): Can't order irq %d to go.\n",
-			       hp->irq);
+			netdev_err(dev, "Can't order irq %d to go.\n", hp->irq);
 
 			return -EAGAIN;
 		}
@@ -2181,12 +2178,12 @@ static void happy_meal_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
 	struct happy_meal *hp = netdev_priv(dev);
 
-	pr_err("%s: transmit timed out, resetting\n", dev->name);
+	netdev_err(dev, "transmit timed out, resetting\n");
 	tx_dump_log();
-	pr_err("%s: Happy Status %08x TX[%08x:%08x]\n", dev->name,
-	       hme_read32(hp, hp->gregs + GREG_STAT),
-	       hme_read32(hp, hp->etxregs + ETX_CFG),
-	       hme_read32(hp, hp->bigmacregs + BMAC_TXCFG));
+	netdev_err(dev, "Happy Status %08x TX[%08x:%08x]\n",
+		   hme_read32(hp, hp->gregs + GREG_STAT),
+		   hme_read32(hp, hp->etxregs + ETX_CFG),
+		   hme_read32(hp, hp->bigmacregs + BMAC_TXCFG));
 
 	spin_lock_irq(&hp->happy_lock);
 	happy_meal_init(hp);
@@ -2236,8 +2233,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 	if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) {
 		netif_stop_queue(dev);
 		spin_unlock_irq(&hp->happy_lock);
-		pr_err("%s: BUG! Tx Ring full when queue awake!\n",
-		       dev->name);
+		netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
 		return NETDEV_TX_BUSY;
 	}
 
@@ -2535,8 +2531,9 @@ static int __init quattro_sbus_register_irqs(void)
 				  IRQF_SHARED, "Quattro",
 				  qp);
 		if (err != 0) {
-			pr_err("Quattro HME: IRQ registration error %d.\n",
-			       err);
+			dev_err(&op->dev,
+				"Quattro HME: IRQ registration error %d.\n",
+				err);
 			return err;
 		}
 	}
@@ -2643,9 +2640,6 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 		goto err_out;
 	SET_NETDEV_DEV(dev, &op->dev);
 
-	if (hme_version_printed++ == 0)
-		pr_info("%s", version);
-
 	/* If user did not specify a MAC address specifically, use
 	 * the Quattro local-mac-address property...
 	 */
@@ -2687,35 +2681,35 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 	hp->gregs = of_ioremap(&op->resource[0], 0,
 			       GREG_REG_SIZE, "HME Global Regs");
 	if (!hp->gregs) {
-		pr_err("happymeal: Cannot map global registers.\n");
+		dev_err(&op->dev, "Cannot map global registers.\n");
 		goto err_out_free_netdev;
 	}
 
 	hp->etxregs = of_ioremap(&op->resource[1], 0,
 				 ETX_REG_SIZE, "HME TX Regs");
 	if (!hp->etxregs) {
-		pr_err("happymeal: Cannot map MAC TX registers.\n");
+		dev_err(&op->dev, "Cannot map MAC TX registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->erxregs = of_ioremap(&op->resource[2], 0,
 				 ERX_REG_SIZE, "HME RX Regs");
 	if (!hp->erxregs) {
-		pr_err("happymeal: Cannot map MAC RX registers.\n");
+		dev_err(&op->dev, "Cannot map MAC RX registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->bigmacregs = of_ioremap(&op->resource[3], 0,
 				    BMAC_REG_SIZE, "HME BIGMAC Regs");
 	if (!hp->bigmacregs) {
-		pr_err("happymeal: Cannot map BIGMAC registers.\n");
+		dev_err(&op->dev, "Cannot map BIGMAC registers.\n");
 		goto err_out_iounmap;
 	}
 
 	hp->tcvregs = of_ioremap(&op->resource[4], 0,
 				 TCVR_REG_SIZE, "HME Tranceiver Regs");
 	if (!hp->tcvregs) {
-		pr_err("happymeal: Cannot map TCVR registers.\n");
+		dev_err(&op->dev, "Cannot map TCVR registers.\n");
 		goto err_out_iounmap;
 	}
 
@@ -2782,18 +2776,17 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 
 	err = register_netdev(hp->dev);
 	if (err) {
-		pr_err("happymeal: Cannot register net device, aborting.\n");
+		dev_err(&op->dev, "Cannot register net device, aborting.\n");
 		goto err_out_free_coherent;
 	}
 
 	platform_set_drvdata(op, hp);
 
 	if (qfe_slot != -1)
-		pr_info("%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
-			dev->name, qfe_slot);
+		netdev_info(dev, "Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
+			    qfe_slot);
 	else
-		pr_info("%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ",
-			dev->name);
+		netdev_info(dev, "HAPPY MEAL (SBUS) 10/100baseT Ethernet ");
 
 	printk("%pM\n", dev->dev_addr);
 
@@ -2983,7 +2976,8 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	err = -EINVAL;
 	if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
-		pr_err("happymeal(PCI): Cannot find proper PCI device base address.\n");
+		dev_err(&pdev->dev,
+			"Cannot find proper PCI device base address.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -2991,14 +2985,14 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 					pci_resource_len(pdev, 0), DRV_NAME);
 	if (IS_ERR(hpreg_res)) {
 		err = PTR_ERR(hpreg_res);
-		pr_err("happymeal(PCI): Cannot obtain PCI resources, aborting.\n");
+		dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
 	hpreg_base = pcim_iomap(pdev, 0, 0x8000);
 	err = -ENOMEM;
 	if (!hpreg_base) {
-		pr_err("happymeal(PCI): Unable to remap card memory.\n");
+		dev_err(&pdev->dev, "Unable to remap card memory.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -3105,7 +3099,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	err = devm_register_netdev(&pdev->dev, dev);
 	if (err) {
-		pr_err("happymeal(PCI): Cannot register net device, aborting.\n");
+		dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
 		goto err_out_clear_quattro;
 	}
 
@@ -3119,8 +3113,9 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 			int i = simple_strtoul(dev->name + 3, NULL, 10);
 			sprintf(prom_name, "-%d", i + 3);
 		}
-		pr_info("%s%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet ",
-			dev->name, prom_name);
+		netdev_info(dev,
+			    "%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet ",
+			    prom_name);
 		if (qpdev->vendor == PCI_VENDOR_ID_DEC &&
 		    qpdev->device == PCI_DEVICE_ID_DEC_21153)
 			printk("DEC 21153 PCI Bridge\n");
@@ -3130,11 +3125,12 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	}
 
 	if (qfe_slot != -1)
-		pr_info("%s: Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet ",
-			dev->name, qfe_slot);
+		netdev_info(dev,
+			    "Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet ",
+			    qfe_slot);
 	else
-		pr_info("%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ",
-			dev->name);
+		netdev_info(dev,
+			    "HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ");
 
 	printk("%pM\n", dev->dev_addr);
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 11/13] sunhme: Combine continued messages
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (9 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 10/13] sunhme: Use (net)dev_foo wherever possible Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-19 13:23   ` Rolf Eike Beer
  2022-09-18 23:26 ` [PATCH net-next 12/13] sunhme: Use vdbg for spam-y prints Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 13/13] sunhme: Add myself as a maintainer Sean Anderson
  12 siblings, 1 reply; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

This driver seems to have been written under the assumption that messages
can be continued arbitrarily. I'm not when this changed (if ever), but such
ad-hoc continuations are liable to be rudely interrupted. Convert all such
instances to single prints. This loses a bit of timing information (such as
when a line was constructed piecemeal as the function executed), but it's
easy to add a few prints if necessary. This also adds newlines to the ends
of any prints without them.

Since (almost every) debug print included the name of the function, include
it automatically.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 278 ++++++++++++------------------
 1 file changed, 106 insertions(+), 172 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 98c38e213bab..9965c9c872a6 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -80,32 +80,33 @@ static struct quattro *qfe_sbus_list;
 static struct quattro *qfe_pci_list;
 #endif
 
-#define HMD pr_debug
+#define hme_debug(fmt, ...) pr_debug("%s: " fmt, __func__, ##__VA_ARGS__)
+#define HMD hme_debug
 
 /* "Auto Switch Debug" aka phy debug */
-#if 0
-#define ASD pr_debug
+#if 1
+#define ASD hme_debug
 #else
 #define ASD(...)
 #endif
 
 /* Transmit debug */
-#if 0
-#define TXD pr_debug
+#if 1
+#define TXD hme_debug
 #else
 #define TXD(...)
 #endif
 
 /* Skid buffer debug */
-#if 0
-#define SXD pr_debug
+#if 1
+#define SXD hme_debug
 #else
 #define SXD(...)
 #endif
 
 /* Receive debug */
-#if 0
-#define RXD pr_debug
+#if 1
+#define RXD hme_debug
 #else
 #define RXD(...)
 #endif
@@ -330,7 +331,6 @@ static int happy_meal_bb_read(struct happy_meal *hp,
 	int retval = 0;
 	int i;
 
-	ASD("happy_meal_bb_read: reg=%d ", reg);
 
 	/* Enable the MIF BitBang outputs. */
 	hme_write32(hp, tregs + TCVR_BBOENAB, 1);
@@ -365,7 +365,7 @@ static int happy_meal_bb_read(struct happy_meal *hp,
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
 	(void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal));
-	ASD("value=%x\n", retval);
+	ASD("reg=%d value=%x\n", reg, retval);
 	return retval;
 }
 
@@ -376,7 +376,7 @@ static void happy_meal_bb_write(struct happy_meal *hp,
 	u32 tmp;
 	int i;
 
-	ASD("happy_meal_bb_write: reg=%d value=%x\n", reg, value);
+	ASD("reg=%d value=%x\n", reg, value);
 
 	/* Enable the MIF BitBang outputs. */
 	hme_write32(hp, tregs + TCVR_BBOENAB, 1);
@@ -420,7 +420,6 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 	int tries = TCVR_READ_TRIES;
 	int retval;
 
-	ASD("happy_meal_tcvr_read: reg=0x%02x ", reg);
 	if (hp->tcvr_type == none) {
 		ASD("no transceiver, value=TCVR_FAILURE\n");
 		return TCVR_FAILURE;
@@ -440,7 +439,7 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 		return TCVR_FAILURE;
 	}
 	retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff;
-	ASD("value=%04x\n", retval);
+	ASD("reg=0x%02x value=%04x\n", reg, retval);
 	return retval;
 }
 
@@ -452,7 +451,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
 {
 	int tries = TCVR_WRITE_TRIES;
 
-	ASD("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value);
+	ASD("reg=0x%02x value=%04x\n", reg, value);
 
 	/* Welcome to Sun Microsystems, can I take your order please? */
 	if (!(hp->happy_flags & HFLAG_FENABLE)) {
@@ -817,7 +816,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
 	int tries = TX_RESET_TRIES;
 
-	HMD("happy_meal_tx_reset: reset, ");
+	HMD("reset...\n");
 
 	/* Would you like to try our SMCC Delux? */
 	hme_write32(hp, bregs + BMAC_TXSWRESET, 0);
@@ -837,7 +836,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
 	int tries = RX_RESET_TRIES;
 
-	HMD("happy_meal_rx_reset: reset, ");
+	HMD("reset...\n");
 
 	/* We have a special on GNU/Viking hardware bugs today. */
 	hme_write32(hp, bregs + BMAC_RXSWRESET, 0);
@@ -846,7 +845,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 
 	/* Will that be all? */
 	if (!tries)
-		netdev_err(hp->dev, "Receiver BigMac ATTACK!");
+		netdev_err(hp->dev, "Receiver BigMac ATTACK!\n");
 
 	/* Don't forget your vik_1137125_wa.  Have a nice day. */
 	HMD("done\n");
@@ -859,7 +858,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 {
 	int tries = STOP_TRIES;
 
-	HMD("happy_meal_stop: reset, ");
+	HMD("reset...\n");
 
 	/* We're consolidating our STB products, it's your lucky day. */
 	hme_write32(hp, gregs + GREG_SWRESET, GREG_RESET_ALL);
@@ -868,7 +867,7 @@ static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 
 	/* Come back next week when we are "Sun Microelectronics". */
 	if (!tries)
-		netdev_err(hp->dev, "Fry guys.");
+		netdev_err(hp->dev, "Fry guys.\n");
 
 	/* Remember: "Different name, same old buggy as shit hardware." */
 	HMD("done\n");
@@ -900,21 +899,18 @@ static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs)
 /* hp->happy_lock must be held */
 static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs)
 {
-	ASD("happy_meal_poll_stop: ");
-
 	/* If polling disabled or not polling already, nothing to do. */
 	if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) !=
 	   (HFLAG_POLLENABLE | HFLAG_POLL)) {
-		HMD("not polling, return\n");
+		ASD("not polling, return\n");
 		return;
 	}
 
 	/* Shut up the MIF. */
-	ASD("were polling, mif ints off, ");
+	ASD("were polling, mif ints off, polling off\n");
 	hme_write32(hp, tregs + TCVR_IMASK, 0xffff);
 
 	/* Turn off polling. */
-	ASD("polling off, ");
 	hme_write32(hp, tregs + TCVR_CFG,
 		    hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE));
 
@@ -939,29 +935,25 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 	int result, tries = TCVR_RESET_TRIES;
 
 	tconfig = hme_read32(hp, tregs + TCVR_CFG);
-	ASD("happy_meal_tcvr_reset: tcfg<%08lx> ", tconfig);
+	ASD("tcfg=%08x\n", tconfig);
 	if (hp->tcvr_type == external) {
-		ASD("external<");
 		hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT));
 		hp->tcvr_type = internal;
 		hp->paddr = TCV_PADDR_ITX;
-		ASD("ISOLATE,");
 		happy_meal_tcvr_write(hp, tregs, MII_BMCR,
 				      (BMCR_LOOPBACK|BMCR_PDOWN|BMCR_ISOLATE));
 		result = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 		if (result == TCVR_FAILURE) {
-			ASD("phyread_fail>\n");
+			ASD("phyread_fail\n");
 			return -1;
 		}
-		ASD("phyread_ok,PSELECT>");
+		ASD("external: ISOLATE, phyread_ok, PSELECT\n");
 		hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT);
 		hp->tcvr_type = external;
 		hp->paddr = TCV_PADDR_ETX;
 	} else {
 		if (tconfig & TCV_CFG_MDIO1) {
-			ASD("internal<PSELECT,");
 			hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT));
-			ASD("ISOLATE,");
 			happy_meal_tcvr_write(hp, tregs, MII_BMCR,
 					      (BMCR_LOOPBACK|BMCR_PDOWN|BMCR_ISOLATE));
 			result = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
@@ -969,14 +961,14 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 				ASD("phyread_fail>\n");
 				return -1;
 			}
-			ASD("phyread_ok,~PSELECT>");
+			ASD("internal: PSELECT, ISOLATE, phyread_ok, ~PSELECT\n");
 			hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT)));
 			hp->tcvr_type = internal;
 			hp->paddr = TCV_PADDR_ITX;
 		}
 	}
 
-	ASD("BMCR_RESET ");
+	ASD("BMCR_RESET...\n");
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET);
 
 	while (--tries) {
@@ -1000,7 +992,7 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 	hp->sw_physid2   = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2);
 	hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE);
 
-	ASD("UNISOLATE");
+	ASD("UNISOLATE...\n");
 	hp->sw_bmcr &= ~(BMCR_ISOLATE);
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -1014,10 +1006,10 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 		udelay(20);
 	}
 	if (!tries) {
-		ASD(" FAILED!\n");
+		ASD("UNISOLATE FAILED!\n");
 		return -1;
 	}
-	ASD(" SUCCESS and CSCONFIG_DFBYPASS\n");
+	ASD("SUCCESS and CSCONFIG_DFBYPASS\n");
 	if (!is_lucent_phy(hp)) {
 		result = happy_meal_tcvr_read(hp, tregs,
 					      DP83840_CSCONFIG);
@@ -1035,61 +1027,55 @@ static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tr
 {
 	unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG);
 
-	ASD("happy_meal_transceiver_check: tcfg=%08lx ", tconfig);
+	ASD("tcfg=%08lx\n", tconfig);
 	if (hp->happy_flags & HFLAG_POLL) {
 		/* If we are polling, we must stop to get the transceiver type. */
-		ASD("<polling> ");
 		if (hp->tcvr_type == internal) {
 			if (tconfig & TCV_CFG_MDIO1) {
-				ASD("<internal> <poll stop> ");
 				happy_meal_poll_stop(hp, tregs);
 				hp->paddr = TCV_PADDR_ETX;
 				hp->tcvr_type = external;
-				ASD("<external>\n");
 				tconfig &= ~(TCV_CFG_PENABLE);
 				tconfig |= TCV_CFG_PSELECT;
 				hme_write32(hp, tregs + TCVR_CFG, tconfig);
+				ASD("poll stop, internal->external\n");
 			}
 		} else {
 			if (hp->tcvr_type == external) {
-				ASD("<external> ");
 				if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) {
-					ASD("<poll stop> ");
 					happy_meal_poll_stop(hp, tregs);
 					hp->paddr = TCV_PADDR_ITX;
 					hp->tcvr_type = internal;
-					ASD("<internal>\n");
 					hme_write32(hp, tregs + TCVR_CFG,
 						    hme_read32(hp, tregs + TCVR_CFG) &
 						    ~(TCV_CFG_PSELECT));
+					ASD("poll stop, external->internal\n");
 				}
-				ASD("\n");
 			} else {
-				ASD("<none>\n");
+				ASD("polling, none\n");
 			}
 		}
 	} else {
 		u32 reread = hme_read32(hp, tregs + TCVR_CFG);
 
 		/* Else we can just work off of the MDIO bits. */
-		ASD("<not polling> ");
 		if (reread & TCV_CFG_MDIO1) {
 			hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT);
 			hp->paddr = TCV_PADDR_ETX;
 			hp->tcvr_type = external;
-			ASD("<external>\n");
+			ASD("not polling, external\n");
 		} else {
 			if (reread & TCV_CFG_MDIO0) {
 				hme_write32(hp, tregs + TCVR_CFG,
 					    tconfig & ~(TCV_CFG_PSELECT));
 				hp->paddr = TCV_PADDR_ITX;
 				hp->tcvr_type = internal;
-				ASD("<internal>\n");
+				ASD("not polling, internal\n");
 			} else {
 				netdev_err(hp->dev,
 					   "Transceiver and a coke please.");
 				hp->tcvr_type = none; /* Grrr... */
-				ASD("<none>\n");
+				ASD("not polling, none\n");
 			}
 		}
 	}
@@ -1196,15 +1182,15 @@ static void happy_meal_init_rings(struct happy_meal *hp)
 	struct hmeal_init_block *hb = hp->happy_block;
 	int i;
 
-	HMD("happy_meal_init_rings: counters to zero, ");
+	HMD("counters to zero\n");
 	hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0;
 
 	/* Free any skippy bufs left around in the rings. */
-	HMD("clean, ");
+	HMD("clean\n");
 	happy_meal_clean_rings(hp);
 
 	/* Now get new skippy bufs for the receive ring. */
-	HMD("init rxring, ");
+	HMD("init rxring\n");
 	for (i = 0; i < RX_RING_SIZE; i++) {
 		struct sk_buff *skb;
 		u32 mapping;
@@ -1231,7 +1217,7 @@ static void happy_meal_init_rings(struct happy_meal *hp)
 		skb_reserve(skb, RX_OFFSET);
 	}
 
-	HMD("init txring, ");
+	HMD("init txring\n");
 	for (i = 0; i < TX_RING_SIZE; i++)
 		hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0);
 
@@ -1282,17 +1268,11 @@ happy_meal_begin_auto_negotiation(struct happy_meal *hp,
 		 * XXX so I completely skip checking for it in the BMSR for now.
 		 */
 
-#ifdef AUTO_SWITCH_DEBUG
-		ASD("%s: Advertising [ ");
-		if (hp->sw_advertise & ADVERTISE_10HALF)
-			ASD("10H ");
-		if (hp->sw_advertise & ADVERTISE_10FULL)
-			ASD("10F ");
-		if (hp->sw_advertise & ADVERTISE_100HALF)
-			ASD("100H ");
-		if (hp->sw_advertise & ADVERTISE_100FULL)
-			ASD("100F ");
-#endif
+		ASD("Advertising [ %s%s%s%s]\n",
+		    hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "",
+		    hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "",
+		    hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "",
+		    hp->sw_advertise & ADVERTISE_100FULL ? "100F " : "");
 
 		/* Enable Auto-Negotiation, this is usually on already... */
 		hp->sw_bmcr |= BMCR_ANENABLE;
@@ -1371,15 +1351,15 @@ static int happy_meal_init(struct happy_meal *hp)
 	void __iomem *erxregs      = hp->erxregs;
 	void __iomem *bregs        = hp->bigmacregs;
 	void __iomem *tregs        = hp->tcvregs;
+	const char *bursts;
 	u32 regtmp, rxcfg;
 
 	/* If auto-negotiation timer is running, kill it. */
 	del_timer(&hp->happy_timer);
 
-	HMD("happy_meal_init: happy_flags[%08x] ",
-	    hp->happy_flags);
+	HMD("happy_flags[%08x]\n", hp->happy_flags);
 	if (!(hp->happy_flags & HFLAG_INIT)) {
-		HMD("set HFLAG_INIT, ");
+		HMD("set HFLAG_INIT\n");
 		hp->happy_flags |= HFLAG_INIT;
 		happy_meal_get_counters(hp, bregs);
 	}
@@ -1389,26 +1369,26 @@ static int happy_meal_init(struct happy_meal *hp)
 	happy_meal_poll_stop(hp, tregs);
 
 	/* Stop transmitter and receiver. */
-	HMD("happy_meal_init: to happy_meal_stop\n");
+	HMD("to happy_meal_stop\n");
 	happy_meal_stop(hp, gregs);
 
 	/* Alloc and reset the tx/rx descriptor chains. */
-	HMD("happy_meal_init: to happy_meal_init_rings\n");
+	HMD("to happy_meal_init_rings\n");
 	happy_meal_init_rings(hp);
 
 	/* Shut up the MIF. */
-	HMD("happy_meal_init: Disable all MIF irqs (old[%08x]), ",
+	HMD("Disable all MIF irqs (old[%08x])\n",
 	    hme_read32(hp, tregs + TCVR_IMASK));
 	hme_write32(hp, tregs + TCVR_IMASK, 0xffff);
 
 	/* See if we can enable the MIF frame on this card to speak to the DP83840. */
 	if (hp->happy_flags & HFLAG_FENABLE) {
-		HMD("use frame old[%08x], ",
+		HMD("use frame old[%08x]\n",
 		    hme_read32(hp, tregs + TCVR_CFG));
 		hme_write32(hp, tregs + TCVR_CFG,
 			    hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE));
 	} else {
-		HMD("use bitbang old[%08x], ",
+		HMD("use bitbang old[%08x]\n",
 		    hme_read32(hp, tregs + TCVR_CFG));
 		hme_write32(hp, tregs + TCVR_CFG,
 			    hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE);
@@ -1419,22 +1399,21 @@ static int happy_meal_init(struct happy_meal *hp)
 	happy_meal_transceiver_check(hp, tregs);
 
 	/* Put the Big Mac into a sane state. */
-	HMD("happy_meal_init: ");
 	switch(hp->tcvr_type) {
 	case none:
 		/* Cannot operate if we don't know the transceiver type! */
-		HMD("AAIEEE no transceiver type, EAGAIN");
+		HMD("AAIEEE no transceiver type, EAGAIN\n");
 		return -EAGAIN;
 
 	case internal:
 		/* Using the MII buffers. */
-		HMD("internal, using MII, ");
+		HMD("internal, using MII\n");
 		hme_write32(hp, bregs + BMAC_XIFCFG, 0);
 		break;
 
 	case external:
 		/* Not using the MII, disable it. */
-		HMD("external, disable MII, ");
+		HMD("external, disable MII\n");
 		hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB);
 		break;
 	}
@@ -1443,18 +1422,16 @@ static int happy_meal_init(struct happy_meal *hp)
 		return -EAGAIN;
 
 	/* Reset the Happy Meal Big Mac transceiver and the receiver. */
-	HMD("tx/rx reset, ");
+	HMD("tx/rx reset\n");
 	happy_meal_tx_reset(hp, bregs);
 	happy_meal_rx_reset(hp, bregs);
 
 	/* Set jam size and inter-packet gaps to reasonable defaults. */
-	HMD("jsize/ipg1/ipg2, ");
 	hme_write32(hp, bregs + BMAC_JSIZE, DEFAULT_JAMSIZE);
 	hme_write32(hp, bregs + BMAC_IGAP1, DEFAULT_IPG1);
 	hme_write32(hp, bregs + BMAC_IGAP2, DEFAULT_IPG2);
 
 	/* Load up the MAC address and random seed. */
-	HMD("rseed/macaddr, ");
 
 	/* The docs recommend to use the 10LSB of our MAC here. */
 	hme_write32(hp, bregs + BMAC_RSEED, ((e[5] | e[4]<<8)&0x3ff));
@@ -1463,7 +1440,6 @@ static int happy_meal_init(struct happy_meal *hp)
 	hme_write32(hp, bregs + BMAC_MACADDR1, ((e[2] << 8) | e[3]));
 	hme_write32(hp, bregs + BMAC_MACADDR0, ((e[0] << 8) | e[1]));
 
-	HMD("htable, ");
 	if ((hp->dev->flags & IFF_ALLMULTI) ||
 	    (netdev_mc_count(hp->dev) > 64)) {
 		hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff);
@@ -1513,9 +1489,6 @@ static int happy_meal_init(struct happy_meal *hp)
 			    | 0x4);
 
 	/* Set the supported burst sizes. */
-	HMD("happy_meal_init: old[%08x] bursts<",
-	    hme_read32(hp, gregs + GREG_CFG));
-
 #ifndef CONFIG_SPARC
 	/* It is always PCI and can handle 64byte bursts. */
 	hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64);
@@ -1543,34 +1516,35 @@ static int happy_meal_init(struct happy_meal *hp)
 		}
 #endif
 
-		HMD("64>");
+		bursts = "64";
 		hme_write32(hp, gregs + GREG_CFG, gcfg);
 	} else if (hp->happy_bursts & DMA_BURST32) {
-		HMD("32>");
+		bursts = "32";
 		hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST32);
 	} else if (hp->happy_bursts & DMA_BURST16) {
-		HMD("16>");
+		bursts = "16";
 		hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST16);
 	} else {
-		HMD("XXX>");
+		bursts = "XXX";
 		hme_write32(hp, gregs + GREG_CFG, 0);
 	}
 #endif /* CONFIG_SPARC */
 
+	HMD("old[%08x] bursts<%s>\n",
+	    hme_read32(hp, gregs + GREG_CFG), bursts);
+
 	/* Turn off interrupts we do not want to hear. */
-	HMD(", enable global interrupts, ");
 	hme_write32(hp, gregs + GREG_IMASK,
 		    (GREG_IMASK_GOTFRAME | GREG_IMASK_RCNTEXP |
 		     GREG_IMASK_SENTFRAME | GREG_IMASK_TXPERR));
 
 	/* Set the transmit ring buffer size. */
-	HMD("tx rsize=%d oreg[%08x], ", (int)TX_RING_SIZE,
+	HMD("tx rsize=%d oreg[%08x]\n", (int)TX_RING_SIZE,
 	    hme_read32(hp, etxregs + ETX_RSIZE));
 	hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1);
 
 	/* Enable transmitter DVMA. */
-	HMD("tx dma enable old[%08x], ",
-	    hme_read32(hp, etxregs + ETX_CFG));
+	HMD("tx dma enable old[%08x]\n", hme_read32(hp, etxregs + ETX_CFG));
 	hme_write32(hp, etxregs + ETX_CFG,
 		    hme_read32(hp, etxregs + ETX_CFG) | ETX_CFG_DMAENABLE);
 
@@ -1594,7 +1568,7 @@ static int happy_meal_init(struct happy_meal *hp)
 	}
 
 	/* Enable Big Mac hash table filter. */
-	HMD("happy_meal_init: enable hash rx_cfg_old[%08x], ",
+	HMD("enable hash rx_cfg_old[%08x]\n",
 	    hme_read32(hp, bregs + BMAC_RXCFG));
 	rxcfg = BIGMAC_RXCFG_HENABLE | BIGMAC_RXCFG_REJME;
 	if (hp->dev->flags & IFF_PROMISC)
@@ -1605,7 +1579,7 @@ static int happy_meal_init(struct happy_meal *hp)
 	udelay(10);
 
 	/* Ok, configure the Big Mac transmitter. */
-	HMD("BIGMAC init, ");
+	HMD("BIGMAC init\n");
 	regtmp = 0;
 	if (hp->happy_flags & HFLAG_FULL)
 		regtmp |= BIGMAC_TXCFG_FULLDPLX;
@@ -1629,8 +1603,7 @@ static int happy_meal_init(struct happy_meal *hp)
 	if (hp->tcvr_type == external)
 		regtmp |= BIGMAC_XCFG_MIIDISAB;
 
-	HMD("XIF config old[%08x], ",
-	    hme_read32(hp, bregs + BMAC_XIFCFG));
+	HMD("XIF config old[%08x]\n", hme_read32(hp, bregs + BMAC_XIFCFG));
 	hme_write32(hp, bregs + BMAC_XIFCFG, regtmp);
 
 	/* Start things up. */
@@ -1769,14 +1742,10 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 
 	if (status & (GREG_STAT_RXERR|GREG_STAT_RXPERR|GREG_STAT_RXTERR)) {
 		/* All sorts of DMA receive errors. */
-		netdev_err(hp->dev, "Happy Meal rx DMA errors [ ");
-		if (status & GREG_STAT_RXERR)
-			printk("GenericError ");
-		if (status & GREG_STAT_RXPERR)
-			printk("ParityError ");
-		if (status & GREG_STAT_RXTERR)
-			printk("RxTagBotch ");
-		printk("]\n");
+		netdev_err(hp->dev, "Happy Meal rx DMA errors [ %s%s%s]\n",
+			   status & GREG_STAT_RXERR ? "GenericError " : "",
+			   status & GREG_STAT_RXPERR ? "ParityError " : "",
+			   status & GREG_STAT_RXTERR ? "RxTagBotch " : "");
 		reset = 1;
 	}
 
@@ -1797,16 +1766,11 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 	if (status &
 	    (GREG_STAT_TXEACK|GREG_STAT_TXLERR|GREG_STAT_TXPERR|GREG_STAT_TXTERR)) {
 		/* All sorts of transmit DMA errors. */
-		netdev_err(hp->dev, "Happy Meal tx DMA errors [ ");
-		if (status & GREG_STAT_TXEACK)
-			printk("GenericError ");
-		if (status & GREG_STAT_TXLERR)
-			printk("LateError ");
-		if (status & GREG_STAT_TXPERR)
-			printk("ParityError ");
-		if (status & GREG_STAT_TXTERR)
-			printk("TagBotch ");
-		printk("]\n");
+		netdev_err(hp->dev, "Happy Meal tx DMA errors [ %s%s%s%s]\n",
+			   status & GREG_STAT_TXEACK ? "GenericError " : "",
+			   status & GREG_STAT_TXLERR ? "LateError " : "",
+			   status & GREG_STAT_TXPERR ? "ParityError " : "",
+			   status & GREG_STAT_TXTERR ? "TagBotch " : "");
 		reset = 1;
 	}
 
@@ -1839,16 +1803,16 @@ static void happy_meal_mif_interrupt(struct happy_meal *hp)
 
 	/* Use the fastest transmission protocol possible. */
 	if (hp->sw_lpa & LPA_100FULL) {
-		netdev_info(hp->dev, "Switching to 100Mbps at full duplex.");
+		netdev_info(hp->dev, "Switching to 100Mbps at full duplex.\n");
 		hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100);
 	} else if (hp->sw_lpa & LPA_100HALF) {
-		netdev_info(hp->dev, "Switching to 100MBps at half duplex.");
+		netdev_info(hp->dev, "Switching to 100MBps at half duplex.\n");
 		hp->sw_bmcr |= BMCR_SPEED100;
 	} else if (hp->sw_lpa & LPA_10FULL) {
-		netdev_info(hp->dev, "Switching to 10MBps at full duplex.");
+		netdev_info(hp->dev, "Switching to 10MBps at full duplex.\n");
 		hp->sw_bmcr |= BMCR_FULLDPLX;
 	} else {
-		netdev_info(hp->dev, "Using 10Mbps at half duplex.");
+		netdev_info(hp->dev, "Using 10Mbps at half duplex.\n");
 	}
 	happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
 
@@ -1865,13 +1829,12 @@ static void happy_meal_tx(struct happy_meal *hp)
 	int elem;
 
 	elem = hp->tx_old;
-	TXD("TX<");
 	while (elem != hp->tx_new) {
 		struct sk_buff *skb;
 		u32 flags, dma_addr, dma_len;
 		int frag;
 
-		TXD("[%d]", elem);
+		TXD("TX[%d]\n", elem);
 		this = &txbase[elem];
 		flags = hme_read_desc32(hp, &this->tx_flags);
 		if (flags & TXFLAG_OWN)
@@ -1907,7 +1870,6 @@ static void happy_meal_tx(struct happy_meal *hp)
 		dev->stats.tx_packets++;
 	}
 	hp->tx_old = elem;
-	TXD(">");
 
 	if (netif_queue_stopped(dev) &&
 	    TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1))
@@ -1930,7 +1892,6 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	int elem = hp->rx_new, drops = 0;
 	u32 flags;
 
-	RXD("RX<");
 	this = &rxbase[elem];
 	while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) {
 		struct sk_buff *skb;
@@ -1938,11 +1899,9 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 		u16 csum = flags & RXFLAG_CSUM;
 		u32 dma_addr = hme_read_desc32(hp, &this->rx_addr);
 
-		RXD("[%d ", elem);
-
 		/* Check for errors. */
 		if ((len < ETH_ZLEN) || (flags & RXFLAG_OVERFLOW)) {
-			RXD("ERR(%08x)]", flags);
+			RXD("RX[%d ERR(%08x)]", elem, flags);
 			dev->stats.rx_errors++;
 			if (len < ETH_ZLEN)
 				dev->stats.rx_length_errors++;
@@ -2014,7 +1973,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 		skb->csum = csum_unfold(~(__force __sum16)htons(csum));
 		skb->ip_summed = CHECKSUM_COMPLETE;
 
-		RXD("len=%d csum=%4x]", len, csum);
+		RXD("RX[%d len=%d csum=%4x]", elem, len, csum);
 		skb->protocol = eth_type_trans(skb, dev);
 		netif_rx(skb);
 
@@ -2027,7 +1986,6 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 	hp->rx_new = elem;
 	if (drops)
 		netdev_info(hp->dev, "Memory squeeze, deferring packet.\n");
-	RXD(">");
 }
 
 static irqreturn_t happy_meal_interrupt(int irq, void *dev_id)
@@ -2036,30 +1994,23 @@ static irqreturn_t happy_meal_interrupt(int irq, void *dev_id)
 	struct happy_meal *hp  = netdev_priv(dev);
 	u32 happy_status       = hme_read32(hp, hp->gregs + GREG_STAT);
 
-	HMD("happy_meal_interrupt: status=%08x ", happy_status);
+	HMD("status=%08x\n", happy_status);
 
 	spin_lock(&hp->happy_lock);
 
 	if (happy_status & GREG_STAT_ERRORS) {
-		HMD("ERRORS ");
 		if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status))
 			goto out;
 	}
 
-	if (happy_status & GREG_STAT_MIFIRQ) {
-		HMD("MIFIRQ ");
+	if (happy_status & GREG_STAT_MIFIRQ)
 		happy_meal_mif_interrupt(hp);
-	}
 
-	if (happy_status & GREG_STAT_TXALL) {
-		HMD("TXALL ");
+	if (happy_status & GREG_STAT_TXALL)
 		happy_meal_tx(hp);
-	}
 
-	if (happy_status & GREG_STAT_RXTOHOST) {
-		HMD("RXTOHOST ");
+	if (happy_status & GREG_STAT_RXTOHOST)
 		happy_meal_rx(hp, dev);
-	}
 
 	HMD("done\n");
 out:
@@ -2079,7 +2030,7 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
 		struct happy_meal *hp  = netdev_priv(dev);
 		u32 happy_status       = hme_read32(hp, hp->gregs + GREG_STAT);
 
-		HMD("quattro_interrupt: status=%08x ", happy_status);
+		HMD("status=%08x\n", happy_status);
 
 		if (!(happy_status & (GREG_STAT_ERRORS |
 				      GREG_STAT_MIFIRQ |
@@ -2089,26 +2040,18 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
 
 		spin_lock(&hp->happy_lock);
 
-		if (happy_status & GREG_STAT_ERRORS) {
-			HMD("ERRORS ");
+		if (happy_status & GREG_STAT_ERRORS)
 			if (happy_meal_is_not_so_happy(hp, happy_status))
 				goto next;
-		}
 
-		if (happy_status & GREG_STAT_MIFIRQ) {
-			HMD("MIFIRQ ");
+		if (happy_status & GREG_STAT_MIFIRQ)
 			happy_meal_mif_interrupt(hp);
-		}
 
-		if (happy_status & GREG_STAT_TXALL) {
-			HMD("TXALL ");
+		if (happy_status & GREG_STAT_TXALL)
 			happy_meal_tx(hp);
-		}
 
-		if (happy_status & GREG_STAT_RXTOHOST) {
-			HMD("RXTOHOST ");
+		if (happy_status & GREG_STAT_RXTOHOST)
 			happy_meal_rx(hp, dev);
-		}
 
 	next:
 		spin_unlock(&hp->happy_lock);
@@ -2124,8 +2067,6 @@ static int happy_meal_open(struct net_device *dev)
 	struct happy_meal *hp = netdev_priv(dev);
 	int res;
 
-	HMD("happy_meal_open: ");
-
 	/* On SBUS Quattro QFE cards, all hme interrupts are concentrated
 	 * into a single source which we register handling at probe time.
 	 */
@@ -2238,7 +2179,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 	}
 
 	entry = hp->tx_new;
-	SXD("SX<l[%d]e[%d]>", len, entry);
+	SXD("SX<l[%d]e[%d]>\n", skb->len, entry);
 	hp->tx_skbs[entry] = skb;
 
 	if (skb_shinfo(skb)->nr_frags == 0) {
@@ -2783,12 +2724,12 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 	platform_set_drvdata(op, hp);
 
 	if (qfe_slot != -1)
-		netdev_info(dev, "Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
-			    qfe_slot);
+		netdev_info(dev,
+			    "Quattro HME slot %d (SBUS) 10/100baseT Ethernet %pM\n",
+			    qfe_slot, dev->dev_addr);
 	else
-		netdev_info(dev, "HAPPY MEAL (SBUS) 10/100baseT Ethernet ");
-
-	printk("%pM\n", dev->dev_addr);
+		netdev_info(dev, "HAPPY MEAL (SBUS) 10/100baseT Ethernet %pM\n",
+			    dev->dev_addr);
 
 	return 0;
 
@@ -3114,25 +3055,18 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 			sprintf(prom_name, "-%d", i + 3);
 		}
 		netdev_info(dev,
-			    "%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet ",
-			    prom_name);
-		if (qpdev->vendor == PCI_VENDOR_ID_DEC &&
-		    qpdev->device == PCI_DEVICE_ID_DEC_21153)
-			printk("DEC 21153 PCI Bridge\n");
-		else
-			printk("unknown bridge %04x.%04x\n",
-				qpdev->vendor, qpdev->device);
+			    "%s: Quattro HME (PCI/CheerIO) 10/100baseT Ethernet bridge %04x.%04x\n",
+			    prom_name, qpdev->vendor, qpdev->device);
 	}
 
 	if (qfe_slot != -1)
 		netdev_info(dev,
-			    "Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet ",
-			    qfe_slot);
+			    "Quattro HME slot %d (PCI/CheerIO) 10/100baseT Ethernet %pM\n",
+			    qfe_slot, dev->dev_addr);
 	else
 		netdev_info(dev,
-			    "HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ");
-
-	printk("%pM\n", dev->dev_addr);
+			    "HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet %pM\n",
+			    dev->dev_addr);
 
 	return 0;
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 12/13] sunhme: Use vdbg for spam-y prints
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (10 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 11/13] sunhme: Combine continued messages Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  2022-09-18 23:26 ` [PATCH net-next 13/13] sunhme: Add myself as a maintainer Sean Anderson
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

The SXD, TXD, and RXD macros are used only once (or twice). Just use the
vdbg print, which seems to have been devised for these sorts of very
verbose messages.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/net/ethernet/sun/sunhme.c | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 9965c9c872a6..8e4927589524 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -90,27 +90,6 @@ static struct quattro *qfe_pci_list;
 #define ASD(...)
 #endif
 
-/* Transmit debug */
-#if 1
-#define TXD hme_debug
-#else
-#define TXD(...)
-#endif
-
-/* Skid buffer debug */
-#if 1
-#define SXD hme_debug
-#else
-#define SXD(...)
-#endif
-
-/* Receive debug */
-#if 1
-#define RXD hme_debug
-#else
-#define RXD(...)
-#endif
-
 #if 0
 struct hme_tx_logent {
 	unsigned int tstamp;
@@ -1834,7 +1813,7 @@ static void happy_meal_tx(struct happy_meal *hp)
 		u32 flags, dma_addr, dma_len;
 		int frag;
 
-		TXD("TX[%d]\n", elem);
+		netdev_vdbg(hp->dev, "TX[%d]\n", elem);
 		this = &txbase[elem];
 		flags = hme_read_desc32(hp, &this->tx_flags);
 		if (flags & TXFLAG_OWN)
@@ -1901,7 +1880,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 
 		/* Check for errors. */
 		if ((len < ETH_ZLEN) || (flags & RXFLAG_OVERFLOW)) {
-			RXD("RX[%d ERR(%08x)]", elem, flags);
+			netdev_vdbg(dev, "RX[%d ERR(%08x)]", elem, flags);
 			dev->stats.rx_errors++;
 			if (len < ETH_ZLEN)
 				dev->stats.rx_length_errors++;
@@ -1973,7 +1952,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
 		skb->csum = csum_unfold(~(__force __sum16)htons(csum));
 		skb->ip_summed = CHECKSUM_COMPLETE;
 
-		RXD("RX[%d len=%d csum=%4x]", elem, len, csum);
+		netdev_vdbg(dev, "RX[%d len=%d csum=%4x]", elem, len, csum);
 		skb->protocol = eth_type_trans(skb, dev);
 		netif_rx(skb);
 
@@ -2179,7 +2158,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 	}
 
 	entry = hp->tx_new;
-	SXD("SX<l[%d]e[%d]>\n", skb->len, entry);
+	netdev_vdbg(dev, "SX<l[%d]e[%d]>\n", skb->len, entry);
 	hp->tx_skbs[entry] = skb;
 
 	if (skb_shinfo(skb)->nr_frags == 0) {
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH net-next 13/13] sunhme: Add myself as a maintainer
  2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
                   ` (11 preceding siblings ...)
  2022-09-18 23:26 ` [PATCH net-next 12/13] sunhme: Use vdbg for spam-y prints Sean Anderson
@ 2022-09-18 23:26 ` Sean Anderson
  12 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-18 23:26 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: open list, Zheyu Ma, Nick Bowler, Rolf Eike Beer, Sean Anderson

I have the hardware so at the very least I can test things.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 74036b51911d..381e1457f601 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19491,6 +19491,11 @@ L:	netdev@vger.kernel.org
 S:	Maintained
 F:	drivers/net/ethernet/dlink/sundance.c
 
+SUN HAPPY MEAL ETHERNET DRIVER
+M:	Sean Anderson <seanga2@gmail.com>
+S:	Maintained
+F:	drivers/net/ethernet/sun/sunhme.*
+
 SUNPLUS ETHERNET DRIVER
 M:	Wells Lu <wellslutw@gmail.com>
 L:	netdev@vger.kernel.org
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find
  2022-09-18 23:26 ` [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find Sean Anderson
@ 2022-09-19 13:11   ` Rolf Eike Beer
  2022-09-19 14:08     ` Sean Anderson
  2022-09-20 19:36   ` Jakub Kicinski
  1 sibling, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2022-09-19 13:11 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Sean Anderson
  Cc: linux-kernel, Zheyu Ma, Nick Bowler, Sean Anderson

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

Am Montag, 19. September 2022, 01:26:17 CEST schrieb Sean Anderson:
> In order to differentiate between a missing bridge and an OOM condition,
> return ERR_PTRs from quattro_pci_find. This also does some general linting
> in the area.
> 
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> 
>  drivers/net/ethernet/sun/sunhme.c | 33 +++++++++++++++++++------------
>  1 file changed, 20 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sun/sunhme.c
> b/drivers/net/ethernet/sun/sunhme.c index 1fc16801f520..52247505d08e 100644
> --- a/drivers/net/ethernet/sun/sunhme.c
> +++ b/drivers/net/ethernet/sun/sunhme.c
> @@ -2569,30 +2569,33 @@ static void quattro_sbus_free_irqs(void)
>  #ifdef CONFIG_PCI
>  static struct quattro *quattro_pci_find(struct pci_dev *pdev)
>  {
> +	int i;
>  	struct pci_dev *bdev = pdev->bus->self;
>  	struct quattro *qp;
> 
> -	if (!bdev) return NULL;
> +	if (!bdev)
> +		return ERR_PTR(-ENODEV);
> +
>  	for (qp = qfe_pci_list; qp != NULL; qp = qp->next) {
>  		struct pci_dev *qpdev = qp->quattro_dev;
> 
>  		if (qpdev == bdev)
>  			return qp;
>  	}
> +
>  	qp = kmalloc(sizeof(struct quattro), GFP_KERNEL);
> -	if (qp != NULL) {
> -		int i;
> +	if (!qp)
> +		return ERR_PTR(-ENOMEM);
> 
> -		for (i = 0; i < 4; i++)
> -			qp->happy_meals[i] = NULL;
> +	for (i = 0; i < 4; i++)
> +		qp->happy_meals[i] = NULL;

I know you are only reindenting it, but I dislike moving the variable up to 
the top of the function. Since the kernel is C99 meanwhile the variable could 
be declared just in the for loop. And when touching this anyway I think we 
could get rid of the magic "4" by using ARRAY_SIZE(qp->happy_meals). Or just 
replace the whole thing with memset(qp->happy_meals, 0, sizeof(qp-
>happy_meals)).

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 11/13] sunhme: Combine continued messages
  2022-09-18 23:26 ` [PATCH net-next 11/13] sunhme: Combine continued messages Sean Anderson
@ 2022-09-19 13:23   ` Rolf Eike Beer
  2022-09-19 14:14     ` Sean Anderson
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2022-09-19 13:23 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Sean Anderson
  Cc: linux-kernel, Zheyu Ma, Nick Bowler, Sean Anderson

[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]

Am Montag, 19. September 2022, 01:26:24 CEST schrieb Sean Anderson:
> This driver seems to have been written under the assumption that messages
> can be continued arbitrarily. I'm not when this changed (if ever), but such
> ad-hoc continuations are liable to be rudely interrupted. Convert all such
> instances to single prints. This loses a bit of timing information (such as
> when a line was constructed piecemeal as the function executed), but it's
> easy to add a few prints if necessary. This also adds newlines to the ends
> of any prints without them.

I have a similar patch around, but yours catches more places.

> diff --git a/drivers/net/ethernet/sun/sunhme.c
> b/drivers/net/ethernet/sun/sunhme.c index 98c38e213bab..9965c9c872a6 100644
> --- a/drivers/net/ethernet/sun/sunhme.c
> +++ b/drivers/net/ethernet/sun/sunhme.c
> @@ -330,7 +331,6 @@ static int happy_meal_bb_read(struct happy_meal *hp,
>  	int retval = 0;
>  	int i;
> 
> -	ASD("happy_meal_bb_read: reg=%d ", reg);
> 
>  	/* Enable the MIF BitBang outputs. */
>  	hme_write32(hp, tregs + TCVR_BBOENAB, 1);

You can remove one of the empty lines here.

> @@ -1196,15 +1182,15 @@ static void happy_meal_init_rings(struct happy_meal
> *hp) struct hmeal_init_block *hb = hp->happy_block;
>  	int i;
> 
> -	HMD("happy_meal_init_rings: counters to zero, ");
> +	HMD("counters to zero\n");
>  	hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0;
> 
>  	/* Free any skippy bufs left around in the rings. */
> -	HMD("clean, ");
> +	HMD("clean\n");

I don't think this one is actually needed, there isn't much than can happen in 
between these 2 prints.

> @@ -1282,17 +1268,11 @@ happy_meal_begin_auto_negotiation(struct happy_meal
> *hp, * XXX so I completely skip checking for it in the BMSR for now. */
> 
> -#ifdef AUTO_SWITCH_DEBUG
> -		ASD("%s: Advertising [ ");
> -		if (hp->sw_advertise & ADVERTISE_10HALF)
> -			ASD("10H ");
> -		if (hp->sw_advertise & ADVERTISE_10FULL)
> -			ASD("10F ");
> -		if (hp->sw_advertise & ADVERTISE_100HALF)
> -			ASD("100H ");
> -		if (hp->sw_advertise & ADVERTISE_100FULL)
> -			ASD("100F ");
> -#endif
> +		ASD("Advertising [ %s%s%s%s]\n",
> +		    hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "",
> +		    hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "",
> +		    hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "",
> +		    hp->sw_advertise & ADVERTISE_100FULL ? "100F " : 
"");
> 
>  		/* Enable Auto-Negotiation, this is usually on 
already... */
>  		hp->sw_bmcr |= BMCR_ANENABLE;

Completely independent of this driver, but I wonder if there is no generic 
function to print these 10/100/* full/half duplex strings? There are several 
drivers doing this as a quick grep shows.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find
  2022-09-19 13:11   ` Rolf Eike Beer
@ 2022-09-19 14:08     ` Sean Anderson
  0 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-19 14:08 UTC (permalink / raw)
  To: Rolf Eike Beer, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev
  Cc: linux-kernel, Zheyu Ma, Nick Bowler

On 9/19/22 09:11, Rolf Eike Beer wrote:
> Am Montag, 19. September 2022, 01:26:17 CEST schrieb Sean Anderson:
>> In order to differentiate between a missing bridge and an OOM condition,
>> return ERR_PTRs from quattro_pci_find. This also does some general linting
>> in the area.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>>   drivers/net/ethernet/sun/sunhme.c | 33 +++++++++++++++++++------------
>>   1 file changed, 20 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/sun/sunhme.c
>> b/drivers/net/ethernet/sun/sunhme.c index 1fc16801f520..52247505d08e 100644
>> --- a/drivers/net/ethernet/sun/sunhme.c
>> +++ b/drivers/net/ethernet/sun/sunhme.c
>> @@ -2569,30 +2569,33 @@ static void quattro_sbus_free_irqs(void)
>>   #ifdef CONFIG_PCI
>>   static struct quattro *quattro_pci_find(struct pci_dev *pdev)
>>   {
>> +	int i;
>>   	struct pci_dev *bdev = pdev->bus->self;
>>   	struct quattro *qp;
>>
>> -	if (!bdev) return NULL;
>> +	if (!bdev)
>> +		return ERR_PTR(-ENODEV);
>> +
>>   	for (qp = qfe_pci_list; qp != NULL; qp = qp->next) {
>>   		struct pci_dev *qpdev = qp->quattro_dev;
>>
>>   		if (qpdev == bdev)
>>   			return qp;
>>   	}
>> +
>>   	qp = kmalloc(sizeof(struct quattro), GFP_KERNEL);
>> -	if (qp != NULL) {
>> -		int i;
>> +	if (!qp)
>> +		return ERR_PTR(-ENOMEM);
>>
>> -		for (i = 0; i < 4; i++)
>> -			qp->happy_meals[i] = NULL;
>> +	for (i = 0; i < 4; i++)
>> +		qp->happy_meals[i] = NULL;
> 
> I know you are only reindenting it, but I dislike moving the variable up to
> the top of the function. Since the kernel is C99 meanwhile the variable could
> be declared just in the for loop. 

Hm, I thought this style was discouraged.

> And when touching this anyway I think we
> could get rid of the magic "4" by using ARRAY_SIZE(qp->happy_meals). Or just
> replace the whole thing with memset(qp->happy_meals, 0, sizeof(qp-
>> happy_meals)).

Yeah, that avoids the whole problem.

--Sean


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 11/13] sunhme: Combine continued messages
  2022-09-19 13:23   ` Rolf Eike Beer
@ 2022-09-19 14:14     ` Sean Anderson
  0 siblings, 0 replies; 21+ messages in thread
From: Sean Anderson @ 2022-09-19 14:14 UTC (permalink / raw)
  To: Rolf Eike Beer, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev
  Cc: linux-kernel, Zheyu Ma, Nick Bowler

On 9/19/22 09:23, Rolf Eike Beer wrote:
> Am Montag, 19. September 2022, 01:26:24 CEST schrieb Sean Anderson:
>> This driver seems to have been written under the assumption that messages
>> can be continued arbitrarily. I'm not when this changed (if ever), but such
>> ad-hoc continuations are liable to be rudely interrupted. Convert all such
>> instances to single prints. This loses a bit of timing information (such as
>> when a line was constructed piecemeal as the function executed), but it's
>> easy to add a few prints if necessary. This also adds newlines to the ends
>> of any prints without them.
> 
> I have a similar patch around, but yours catches more places.
> 
>> diff --git a/drivers/net/ethernet/sun/sunhme.c
>> b/drivers/net/ethernet/sun/sunhme.c index 98c38e213bab..9965c9c872a6 100644
>> --- a/drivers/net/ethernet/sun/sunhme.c
>> +++ b/drivers/net/ethernet/sun/sunhme.c
>> @@ -330,7 +331,6 @@ static int happy_meal_bb_read(struct happy_meal *hp,
>>   	int retval = 0;
>>   	int i;
>>
>> -	ASD("happy_meal_bb_read: reg=%d ", reg);
>>
>>   	/* Enable the MIF BitBang outputs. */
>>   	hme_write32(hp, tregs + TCVR_BBOENAB, 1);
> 
> You can remove one of the empty lines here.

OK

>> @@ -1196,15 +1182,15 @@ static void happy_meal_init_rings(struct happy_meal
>> *hp) struct hmeal_init_block *hb = hp->happy_block;
>>   	int i;
>>
>> -	HMD("happy_meal_init_rings: counters to zero, ");
>> +	HMD("counters to zero\n");
>>   	hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0;
>>
>>   	/* Free any skippy bufs left around in the rings. */
>> -	HMD("clean, ");
>> +	HMD("clean\n");
> 
> I don't think this one is actually needed, there isn't much than can happen in
> between these 2 prints.

OK

>> @@ -1282,17 +1268,11 @@ happy_meal_begin_auto_negotiation(struct happy_meal
>> *hp, * XXX so I completely skip checking for it in the BMSR for now. */
>>
>> -#ifdef AUTO_SWITCH_DEBUG
>> -		ASD("%s: Advertising [ ");
>> -		if (hp->sw_advertise & ADVERTISE_10HALF)
>> -			ASD("10H ");
>> -		if (hp->sw_advertise & ADVERTISE_10FULL)
>> -			ASD("10F ");
>> -		if (hp->sw_advertise & ADVERTISE_100HALF)
>> -			ASD("100H ");
>> -		if (hp->sw_advertise & ADVERTISE_100FULL)
>> -			ASD("100F ");
>> -#endif
>> +		ASD("Advertising [ %s%s%s%s]\n",
>> +		    hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "",
>> +		    hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "",
>> +		    hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "",
>> +		    hp->sw_advertise & ADVERTISE_100FULL ? "100F " :
> "");
>>
>>   		/* Enable Auto-Negotiation, this is usually on
> already... */
>>   		hp->sw_bmcr |= BMCR_ANENABLE;
> 
> Completely independent of this driver, but I wonder if there is no generic
> function to print these 10/100/* full/half duplex strings? There are several
> drivers doing this as a quick grep shows.

There's some functions to print just one link mode, but I think generally the
full advertising word is printed in debugs. I'm not too worried since this is
just for debug.

One of my goals is to convert this driver to phylib, but I haven't dived very
deep into it.

--Sean

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 05/13] sunhme: Regularize probe errors
  2022-09-18 23:26 ` [PATCH net-next 05/13] sunhme: Regularize probe errors Sean Anderson
@ 2022-09-20 19:36   ` Jakub Kicinski
  0 siblings, 0 replies; 21+ messages in thread
From: Jakub Kicinski @ 2022-09-20 19:36 UTC (permalink / raw)
  To: Sean Anderson
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, netdev, open list,
	Zheyu Ma, Nick Bowler, Rolf Eike Beer

On Sun, 18 Sep 2022 19:26:18 -0400 Sean Anderson wrote:
> -	err = -ENODEV;
> +	err = -EINVAL;
>  	if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
>  		printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
>  		goto err_out_clear_quattro;
>  	}

Why not move it inside the if?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find
  2022-09-18 23:26 ` [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find Sean Anderson
  2022-09-19 13:11   ` Rolf Eike Beer
@ 2022-09-20 19:36   ` Jakub Kicinski
  1 sibling, 0 replies; 21+ messages in thread
From: Jakub Kicinski @ 2022-09-20 19:36 UTC (permalink / raw)
  To: Sean Anderson
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, netdev, open list,
	Zheyu Ma, Nick Bowler, Rolf Eike Beer

On Sun, 18 Sep 2022 19:26:17 -0400 Sean Anderson wrote:
> +	int i;
>  	struct pci_dev *bdev = pdev->bus->self;
>  	struct quattro *qp;

reverse xmas tree variable ordering please

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device()
  2022-09-18 23:26 ` [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device() Sean Anderson
@ 2022-09-20 19:37   ` Jakub Kicinski
  0 siblings, 0 replies; 21+ messages in thread
From: Jakub Kicinski @ 2022-09-20 19:37 UTC (permalink / raw)
  To: Sean Anderson
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, netdev, open list,
	Zheyu Ma, Nick Bowler, Rolf Eike Beer

On Sun, 18 Sep 2022 19:26:16 -0400 Sean Anderson wrote:
> +	err = pci_enable_device(pdev);
>  
> -	if (pci_enable_device(pdev))
> +	if (err)

No empty lines between call and retval check

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-09-20 19:37 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18 23:26 [PATCH net-next 00/13] net: sunhme: Cleanups and logging improvements Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 01/13] sunhme: remove unused tx_dump_ring() Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 02/13] sunhme: Remove version Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 03/13] sunhme: forward the error code from pci_enable_device() Sean Anderson
2022-09-20 19:37   ` Jakub Kicinski
2022-09-18 23:26 ` [PATCH net-next 04/13] sunhme: Return an ERR_PTR from quattro_pci_find Sean Anderson
2022-09-19 13:11   ` Rolf Eike Beer
2022-09-19 14:08     ` Sean Anderson
2022-09-20 19:36   ` Jakub Kicinski
2022-09-18 23:26 ` [PATCH net-next 05/13] sunhme: Regularize probe errors Sean Anderson
2022-09-20 19:36   ` Jakub Kicinski
2022-09-18 23:26 ` [PATCH net-next 06/13] sunhme: switch to devres Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 07/13] sumhme: Convert FOO((...)) to FOO(...) Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 08/13] sunhme: Clean up debug infrastructure Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 09/13] sunhme: Convert printk(KERN_FOO ...) to pr_foo(...) Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 10/13] sunhme: Use (net)dev_foo wherever possible Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 11/13] sunhme: Combine continued messages Sean Anderson
2022-09-19 13:23   ` Rolf Eike Beer
2022-09-19 14:14     ` Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 12/13] sunhme: Use vdbg for spam-y prints Sean Anderson
2022-09-18 23:26 ` [PATCH net-next 13/13] sunhme: Add myself as a maintainer Sean Anderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.