Skip to contentSkip to conversation

drivers: net: Follow the indentation coding standard on printks

PATCH In review Carlos Bilbao 3 participants 8 messages Jul 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: net: Follow the indentation coding standard on printks

Fix indentation of printks that start at the beginning of the line. Change this for the right number of space characters, or tabs if the file uses them.

---
 drivers/net/ethernet/dec/tulip/de4x5.c | 2 +-
 drivers/net/sb1000.c                   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
index b125d7faefdf..155cfe8800cd 100644
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
 
     default:
 	lp->tcount++;
-printk("Huh?: media:%02x\n", lp->media);
+	printk("Huh?: media:%02x\n", lp->media);
 	lp->media = INIT;
 	break;
     }
drivers/net/sb1000.c +2 -2
index e88af978f63c..54a7c7613434 100644
@@ -760,7 +760,7 @@ sb1000_rx(struct net_device *dev)
 
 	insw(ioaddr, (unsigned short*) st, 1);
 #ifdef XXXDEBUG
-printk("cm0: received: %02x %02x\n", st[0], st[1]);
+	printk("cm0: received: %02x %02x\n", st[0], st[1]);
 #endif /* XXXDEBUG */
 	lp->rx_frames++;
 
@@ -805,7 +805,7 @@ printk("cm0: received: %02x %02x\n", st[0], st[1]);
 		/* get data length */
 		insw(ioaddr, buffer, NewDatagramHeaderSize / 2);
 #ifdef XXXDEBUG
-printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
+		printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
 #endif /* XXXDEBUG */
 		if (buffer[0] != NewDatagramHeaderSkip) {
 			if (sb1000_debug > 1)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Carlos Bilbao

Fix indentation of printks that start at the beginning of the line. Change this for the right number of space characters, or tabs if the file uses them.

The tulip and sb1000 code are from the 1990's. Likely this doesn't need touching, but if you really want to:

drivers/net/ethernet/dec/tulip/de4x5.c

Quoted 1 line
drivers/net/ethernet/dec/tulip/de4x5.c +0 -0

[]

drivers/net/ethernet/dec/tulip/de4x5.c dc2114x_autoconf(struct net_device *dev) · line 3172

Quoted 7 lines
drivers/net/ethernet/dec/tulip/de4x5.c +0 -0
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)

     default:
  lp->tcount++;

drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
-printk("Huh?: media:%02x\n", lp->media);
+	printk("Huh?: media:%02x\n", lp->media);

There should be a KERN_<LEVEL> here like KERN_WARNING/KERN_NOTICE

drivers/net/sb1000.c

Quoted 1 line
drivers/net/sb1000.c +0 -0

[]

Quoted 8 lines
drivers/net/sb1000.c +0 -0
@@ -760,7 +760,7 @@ sb1000_rx(struct net_device *dev)

  insw(ioaddr, (unsigned short*) st, 1);
 #ifdef XXXDEBUG

drivers/net/sb1000.c +1 -1
-printk("cm0: received: %02x %02x\n", st[0], st[1]);
+	printk("cm0: received: %02x %02x\n", st[0], st[1]);

 #endif /* XXXDEBUG */

XXXDEBUG isn't defined anywhere so these could just be deleted.

Quoted 9 lines
drivers/net/sb1000.c +1 -1
@@ -805,7 +805,7 @@ printk("cm0: received: %02x %02x\n", st[0], st[1]);
  		/* get data length */
  		insw(ioaddr, buffer, NewDatagramHeaderSize / 2);
  #ifdef XXXDEBUG
-printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
+		printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
  #endif /* XXXDEBUG */
  		if (buffer[0] != NewDatagramHeaderSkip) {
  			if (sb1000_debug > 1)
#2 lore raw

PATCH v2 1/1 drivers: net: Follow the indentation coding standard on printks

Fix indentation of printks that start at the beginning of the line. Change this for the right number of space characters, or tabs if the file uses them.

---
Changelog:
v2 - Remove the printks inside XXXDEBUG
---

drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
index b125d7faefdf..0d8ddfdd5c09 100644
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
 
     default:
 	lp->tcount++;
-printk("Huh?: media:%02x\n", lp->media);
+	printk(KERN_NOTICE "Huh?: media:%02x\n", lp->media);
 	lp->media = INIT;
 	break;
     }
drivers/net/ethernet/dec/tulip/de4x5.c.rej new file +11 -0
new file mode 100644
index 000000000000..949b9902b0bc
@@ -0,0 +1,11 @@
+--- drivers/net/ethernet/dec/tulip/de4x5.c
++++ drivers/net/ethernet/dec/tulip/de4x5.c
+@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
+ 
+     default:
+        lp->tcount++;
+-printk("Huh?: media:%02x\n", lp->media);
++       printk("Huh?: media:%02x\n", lp->media);
+        lp->media = INIT;
+        break;
+     }
drivers/net/sb1000.c +0 -6
index e88af978f63c..a7a6bd7ef015 100644
@@ -759,9 +759,6 @@ sb1000_rx(struct net_device *dev)
 	ioaddr = dev->base_addr;
 
 	insw(ioaddr, (unsigned short*) st, 1);
-#ifdef XXXDEBUG
-printk("cm0: received: %02x %02x\n", st[0], st[1]);
-#endif /* XXXDEBUG */
 	lp->rx_frames++;
 
 	/* decide if it is a good or bad frame */
@@ -804,9 +801,6 @@ printk("cm0: received: %02x %02x\n", st[0], st[1]);
 	if (st[0] & 0x40) {
 		/* get data length */
 		insw(ioaddr, buffer, NewDatagramHeaderSize / 2);
-#ifdef XXXDEBUG
-printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
-#endif /* XXXDEBUG */
 		if (buffer[0] != NewDatagramHeaderSkip) {
 			if (sb1000_debug > 1)
 				printk(KERN_WARNING "%s: new datagram header skip error: "
Signature · 1 line
2.25.1
#3 lore raw
Quoted 2 lines · Carlos Bilbao

Fix indentation of printks that start at the beginning of the line. Change this for the right number of space characters, or tabs if the file uses them.

You are touching 2 different drivers and this should really be 2 separate patches.

drivers/net/ethernet/dec/tulip/de4x5.c.rej

Quoted 1 line
drivers/net/ethernet/dec/tulip/de4x5.c.rej +0 -0

[]

drivers/net/ethernet/dec/tulip/de4x5.c.rej line 11

Quoted 13 lines

+++ b/drivers/net/ethernet/dec/tulip/de4x5.c.rej

drivers/net/ethernet/dec/tulip/de4x5.c.rej +11 -0
@@ -0,0 +1,11 @@
+--- drivers/net/ethernet/dec/tulip/de4x5.c
++++ drivers/net/ethernet/dec/tulip/de4x5.c
+@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
+ 
+     default:
+        lp->tcount++;
+-printk("Huh?: media:%02x\n", lp->media);
++       printk("Huh?: media:%02x\n", lp->media);
+        lp->media = INIT;
+        break;
+     }

This is an interdiff that should not be part of this change.

#4 lore raw

Hello Joe,

I apologize for the mess, I will send two different patches for the drivers now.

thanks,
Carlos.

#5 lore raw

PATCH v2 1/1 drivers: ethernet: tulip: Fix indentation of printk

In reply to Joe Perches

Fix indentation of printk that starts at the beginning of the line and does not have a KERN_<LEVEL>.

---
 drivers/net/ethernet/dec/tulip/de4x5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
index b125d7faefdf..0d8ddfdd5c09 100644
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
 
     default:
 	lp->tcount++;
-printk("Huh?: media:%02x\n", lp->media);
+	printk(KERN_NOTICE "Huh?: media:%02x\n", lp->media);
 	lp->media = INIT;
 	break;
     }
Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH net-next v2] drivers: ethernet: tulip: Fix indentation of printk

Quoted 13 lines · Carlos Bilbao

Fix indentation of printk that starts at the beginning of the line and does not have a KERN_<LEVEL>.

---
 drivers/net/ethernet/dec/tulip/de4x5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/de4x5.c +0 -0
index b125d7faefdf..0d8ddfdd5c09 100644

drivers/net/ethernet/dec/tulip/de4x5.c dc2114x_autoconf(struct net_device *dev) · line 3175

Quoted 8 lines
drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
 
     default:
 	lp->tcount++;
-printk("Huh?: media:%02x\n", lp->media);
+	printk(KERN_NOTICE "Huh?: media:%02x\n", lp->media);
 	lp->media = INIT;
 	break;
     }

Since this is a network driver, and you have a net_device structure, the best practice is to use

netdev_notice(dev, "Huh?: media:%02x\n", lp->media);

You could go through this driver and change all printk() to netdev_dbg(), netdev_err(), netdev_info etc. The advantage of these calls is that they make it clear which network interface is outputting the message.

Other subsystems have similar calls. If there are not subsystem specific print functions, but you have a struct device, it is best to use dev_err(), dev_dbg(), dev_info() etc. These functions will make it clear which device is printing the message.

Andrew

#7 lore raw

PATCH v2 1/1 drivers: net: Remove undefined XXXDEBUG on driver sb1000

In reply to Joe Perches

XXXDEBUG isn't defined anywhere so these can be deleted from this file.

---
 drivers/net/sb1000.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/sb1000.c +0 -6
index e88af978f63c..a7a6bd7ef015 100644
@@ -759,9 +759,6 @@ sb1000_rx(struct net_device *dev)
 	ioaddr = dev->base_addr;
 
 	insw(ioaddr, (unsigned short*) st, 1);
-#ifdef XXXDEBUG
-printk("cm0: received: %02x %02x\n", st[0], st[1]);
-#endif /* XXXDEBUG */
 	lp->rx_frames++;
 
 	/* decide if it is a good or bad frame */
@@ -804,9 +801,6 @@ printk("cm0: received: %02x %02x\n", st[0], st[1]);
 	if (st[0] & 0x40) {
 		/* get data length */
 		insw(ioaddr, buffer, NewDatagramHeaderSize / 2);
-#ifdef XXXDEBUG
-printk("cm0: IP identification: %02x%02x  fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
-#endif /* XXXDEBUG */
 		if (buffer[0] != NewDatagramHeaderSkip) {
 			if (sb1000_debug > 1)
 				printk(KERN_WARNING "%s: new datagram header skip error: "
Signature · 1 line
2.25.1