Skip to contentSkip to conversation

Staging: comedi: drivers: fl512: change printk(KERN_INFO ... for the prefered pr_info(...

PATCH In review Bruce Humphrey 4 participants 8 messages Sep 11, 2012

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

PATCH 1/1 Staging: comedi: drivers: fl512: change printk(KERN_INFO ... for the prefered pr_info(...

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

---
 drivers/staging/comedi/drivers/fl512.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/comedi/drivers/fl512.c +5 -5
index d1da809..258a7b4 100644
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	struct comedi_subdevice *s;
 
 	iobase = it->options[0];
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);
 	if (!request_region(iobase, FL512_SIZE, "fl512")) {
-		printk(KERN_WARNING " I/O port conflict\n");
+		pr_warn(" I/O port conflict\n");
 		return -EIO;
 	}
 	dev->iobase = iobase;
@@ -129,7 +129,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		return -ENOMEM;
 
 #if DEBUG
-	printk(KERN_DEBUG "malloc ok\n");
+	pr_debug("malloc ok\n");
 #endif
 
 	ret = comedi_alloc_subdevices(dev, 2);
@@ -153,7 +153,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->range_table = &range_fl512;
 	/* function to call when read AD */
 	s->insn_read = fl512_ai_insn;
-	printk(KERN_INFO "comedi: fl512: subdevice 0 initialized\n");
+	pr_info("comedi: fl512: subdevice 0 initialized\n");
 
 	/* Analog output */
 	s = dev->subdevices + 1;
@@ -171,7 +171,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->insn_write = fl512_ao_insn;
 	/* function to call when reading DA */
 	s->insn_read = fl512_ao_insn_readback;
-	printk(KERN_INFO "comedi: fl512: subdevice 1 initialized\n");
+	pr_info("comedi: fl512: subdevice 1 initialized\n");
 
 	return 1;
 }
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 12 lines · Bruce Humphrey

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

---
 drivers/staging/comedi/drivers/fl512.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/comedi/drivers/fl512.c +0 -0
index d1da809..258a7b4 100644

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 121

Quoted 5 lines
drivers/staging/comedi/drivers/fl512.c +1 -1
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	struct comedi_subdevice *s;
 
 	iobase = it->options[0];
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);

Why can't you use dev_info() here, and in other places? You should use the dev_* functions instead of pr_* wherever possible.

thanks,

greg k-h

maintainer
#2 lore raw
Quoted 2 lines · Greg KH
Quoted 1 line · Bruce Humphrey

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

[]

Quoted 5 lines

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 118

Quoted 2 lines
drivers/staging/comedi/drivers/fl512.c +1 -1
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);

Why can't you use dev_info() here, and in other places? You should use the dev_* functions instead of pr_* wherever possible.

Checkpatch instigates these conversions.

Perhaps something like:

---
 scripts/checkpatch.pl |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +4 -2
index ca05ba2..e1f4390 100755
@@ -421,7 +421,7 @@ sub top_of_kernel_tree {
 		}
 	}
 	return 1;
-    }
+}
 
 sub parse_email {
 	my ($formatted_email) = @_;
@@ -2390,8 +2390,10 @@ sub process {
 			my $orig = $1;
 			my $level = lc($orig);
 			$level = "warn" if ($level eq "warning");
+			my $level2 = $level;
+			$level2 = "dbg" if ($level eq "debug");
 			WARN("PREFER_PR_LEVEL",
-			     "Prefer pr_$level(... to printk(KERN_$1, ...\n" . $herecurr);
+			     "Prefer netdev_$level2(netdev, ... then dev_$level2(dev, ... then pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
 		}
 
 		if ($line =~ /\bpr_warning\s*\(/) {
maintainer
#3 lore raw
Quoted 8 lines · Joe Perches
Quoted 2 lines · Greg KH
Quoted 1 line · Bruce Humphrey

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

[]

Quoted 7 lines
Quoted 5 lines

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 118

Quoted 2 lines
drivers/staging/comedi/drivers/fl512.c +1 -1
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);

Why can't you use dev_info() here, and in other places? You should use the dev_* functions instead of pr_* wherever possible.

Checkpatch instigates these conversions.

I know.

Quoted 1 line

Perhaps something like:

That looks like a good start, until someone tries to use netdev_* in a random non-network driver :)

greg k-h

maintainer
#4 lore raw
Quoted 15 lines · Greg KH
Quoted 14 lines · Joe Perches
Quoted 2 lines · Greg KH
Quoted 1 line · Bruce Humphrey

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0

[]

Quoted 1 line

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

Quoted 1 line
drivers/staging/comedi/drivers/fl512.c +0 -0
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)

[]

Quoted 5 lines

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 118

Quoted 2 lines
drivers/staging/comedi/drivers/fl512.c +1 -1
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);

Why can't you use dev_info() here, and in other places? You should use the dev_* functions instead of pr_* wherever possible.

Quoted 8 lines
Quoted 1 line

Checkpatch instigates these conversions.

I know.

Quoted 1 line

Perhaps something like:

That looks like a good start, until someone tries to use netdev_* in a random non-network driver :)

Hence the "netdev_<level>(netdev, ...) then dev_<level>(dev, ..., etc...

You can only make people read not understand.

maintainer
#6 lore raw

PATCH 1/1 checkpatch: Update suggested printk conversions

In reply to Greg KH

Direct conversion of printk(KERN_<LEVEL>... to pr_<level> isn't the preferred conversion when a struct net_device or struct device is available.

Hint that using netdev_<level> or dev_<level> is preferred to using pr_<level>. Add netdev_dbg and dev_dbg variants too.

Miscellaneous whitespace neatening of a misplaced close brace.

---
 scripts/checkpatch.pl |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +4 -2
index ca05ba2..e1f4390 100755
@@ -421,7 +421,7 @@ sub top_of_kernel_tree {
 		}
 	}
 	return 1;
-    }
+}
 
 sub parse_email {
 	my ($formatted_email) = @_;
@@ -2390,8 +2390,10 @@ sub process {
 			my $orig = $1;
 			my $level = lc($orig);
 			$level = "warn" if ($level eq "warning");
+			my $level2 = $level;
+			$level2 = "dbg" if ($level eq "debug");
 			WARN("PREFER_PR_LEVEL",
-			     "Prefer pr_$level(... to printk(KERN_$1, ...\n" . $herecurr);
+			     "Prefer netdev_$level2(netdev, ... then dev_$level2(dev, ... then pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
 		}
 
 		if ($line =~ /\bpr_warning\s*\(/) {
#7 lore raw
In reply to Bruce Humphrey
Quoted 12 lines · Bruce Humphrey

Change 5 instances of printk(KERN_INFO, KERN_WARN and KERN_ERROR for the prefered pr_info, pr_warn and pr_error

---
 drivers/staging/comedi/drivers/fl512.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/comedi/drivers/fl512.c +0 -0
index d1da809..258a7b4 100644

drivers/staging/comedi/drivers/fl512.c static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 124

Quoted 9 lines
drivers/staging/comedi/drivers/fl512.c +2 -2
@@ -118,9 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	struct comedi_subdevice *s;
 
 	iobase = it->options[0];
-	printk(KERN_INFO "comedi:%d fl512: 0x%04lx", dev->minor, iobase);
+	pr_info("comedi:%d fl512: 0x%04lx", dev->minor, iobase);
 	if (!request_region(iobase, FL512_SIZE, "fl512")) {
-		printk(KERN_WARNING " I/O port conflict\n");
+		pr_warn(" I/O port conflict\n");
 		return -EIO;

These weren't right at all in the original code. Doing small white space cleanups is pointless when the print statements are wrong. (Line continuations. Also printing bogus nonsense. Look Hartley's patches for examples on how to fix these properly).

regards,
dan carpenter