Skip to contentSkip to conversation

Move the definition of pr_err() into kernel.h

PATCH In review Emil Medve 3 participants 4 messages Sep 11, 2007

Subsystems (3)
lore
Share & tools
lore

Emil Medve

author
#0 lore raw

PATCH v2 1/1 Move the definition of pr_err() into kernel.h

Other pr_*() macros are already defined in kernel.h, but pr_err() was defined multiple times in several other places

---

I'm writing a driver and I've been using the pr_*() macros from kernel.h and I was surprised not to find there pr_err() but defined multiple times (in four different files). I didn't want to define it yet one more time so I did this cleanup

This patch is against Linus' tree v2.6.23-rc6 (0d4cbb5e7f60b2f1a4d8b7f6ea4cc264262c7a01)

linux-2.6> scripts/checkpatch.pl 0001-Move-the-definition-of-pr_err-into-kernel.h.patch Your patch has no obvious style problems and is ready for submission.

 drivers/i2c/chips/menelaus.c     |   10 ++++------
 drivers/net/spider_net.h         |    3 ---
 drivers/video/omap/lcd_h3.c      |    6 ++----
 drivers/video/omap/lcd_inn1610.c |    6 ++----
 include/linux/kernel.h           |    2 ++
 5 files changed, 10 insertions(+), 17 deletions(-)
drivers/i2c/chips/menelaus.c +4 -6
index d9c92c5..66436ba 100644
@@ -49,8 +49,6 @@
 
 #define DRIVER_NAME			"menelaus"
 
-#define pr_err(fmt, arg...)	printk(KERN_ERR DRIVER_NAME ": ", ## arg);
-
 #define MENELAUS_I2C_ADDRESS		0x72
 
 #define MENELAUS_REV			0x01
@@ -155,7 +153,7 @@ static int menelaus_write_reg(int reg, u8 value)
 	int val = i2c_smbus_write_byte_data(the_menelaus->client, reg, value);
 
 	if (val < 0) {
-		pr_err("write error");
+		pr_err(DRIVER_NAME ": write error");
 		return val;
 	}
 
@@ -167,7 +165,7 @@ static int menelaus_read_reg(int reg)
 	int val = i2c_smbus_read_byte_data(the_menelaus->client, reg);
 
 	if (val < 0)
-		pr_err("read error");
+		pr_err(DRIVER_NAME ": read error");
 
 	return val;
 }
@@ -1177,7 +1175,7 @@ static int menelaus_probe(struct i2c_client *client)
 	/* If a true probe check the device */
 	rev = menelaus_read_reg(MENELAUS_REV);
 	if (rev < 0) {
-		pr_err("device not found");
+		pr_err(DRIVER_NAME ": device not found");
 		err = -ENODEV;
 		goto fail1;
 	}
@@ -1258,7 +1256,7 @@ static int __init menelaus_init(void)
 
 	res = i2c_add_driver(&menelaus_i2c_driver);
 	if (res < 0) {
-		pr_err("driver registration failed\n");
+		pr_err(DRIVER_NAME ": driver registration failed\n");
 		return res;
 	}
 
drivers/net/spider_net.h +0 -3
index dbbdb8c..c67b11d 100644
@@ -493,7 +493,4 @@ struct spider_net_card {
 	struct spider_net_descr darray[0];
 };
 
-#define pr_err(fmt,arg...) \
-	printk(KERN_ERR fmt ,##arg)
-
 #endif
drivers/video/omap/lcd_h3.c +2 -4
index 51807b4..c604d93 100644
@@ -28,8 +28,6 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
-
 static int h3_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
 {
 	return 0;
@@ -48,7 +46,7 @@ static int h3_panel_enable(struct lcd_panel *panel)
 	if (!r)
 		r = tps65010_set_gpio_out_value(GPIO2, HIGH);
 	if (r)
-		pr_err("Unable to turn on LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn on LCD panel\n");
 
 	return r;
 }
@@ -62,7 +60,7 @@ static void h3_panel_disable(struct lcd_panel *panel)
 	if (!r)
 		tps65010_set_gpio_out_value(GPIO2, LOW);
 	if (r)
-		pr_err("Unable to turn off LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn off LCD panel\n");
 }
 
 static unsigned long h3_panel_get_caps(struct lcd_panel *panel)
drivers/video/omap/lcd_inn1610.c +2 -4
index 95604ca..5ef119c 100644
@@ -27,20 +27,18 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
-
 static int innovator1610_panel_init(struct lcd_panel *panel,
 				    struct omapfb_device *fbdev)
 {
 	int r = 0;
 
 	if (omap_request_gpio(14)) {
-		pr_err("can't request GPIO 14\n");
+		pr_err(MODULE_NAME ": can't request GPIO 14\n");
 		r = -1;
 		goto exit;
 	}
 	if (omap_request_gpio(15)) {
-		pr_err("can't request GPIO 15\n");
+		pr_err(MODULE_NAME ": can't request GPIO 15\n");
 		omap_free_gpio(14);
 		r = -1;
 		goto exit;
include/linux/kernel.h +2 -0
index f592df7..c51936a 100644
@@ -242,6 +242,8 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
 
 #define pr_info(fmt,arg...) \
 	printk(KERN_INFO fmt,##arg)
+#define pr_err(fmt, arg...) \
+	printk(KERN_ERR fmt, ##arg)
 
 /*
  *      Display an IP address in readable format.
Signature · 1 line
1.5.3.GIT
#1 lore raw
Quoted 11 lines

Other pr_*() macros are already defined in kernel.h, but pr_err() was defined multiple times in several other places

---

I'm writing a driver and I've been using the pr_*() macros from kernel.h and I was surprised not to find there pr_err() but defined multiple times (in four different files). I didn't want to define it yet one more time so I did this cleanup

Quoted 6 lines

This patch is against Linus' tree v2.6.23-rc6
(0d4cbb5e7f60b2f1a4d8b7f6ea4cc264262c7a01)

linux-2.6> scripts/checkpatch.pl 0001-Move-the-definition-of-pr_err-into-kernel.h.patch Your patch has no obvious style problems and is ready for submission.

Almost. :-)

Quoted 13 lines
 drivers/i2c/chips/menelaus.c     |   10 ++++------
 drivers/net/spider_net.h         |    3 ---
 drivers/video/omap/lcd_h3.c      |    6 ++----
 drivers/video/omap/lcd_inn1610.c |    6 ++----
 include/linux/kernel.h           |    2 ++
 5 files changed, 10 insertions(+), 17 deletions(-)
(quoted diff) +0 -0

b/drivers/i2c/chips/menelaus.c index d9c92c5..66436ba 100644

drivers/i2c/chips/menelaus.c line 54

Quoted 6 lines
drivers/i2c/chips/menelaus.c +0 -2
@@ -49,8 +49,6 @@
 
 #define DRIVER_NAME			"menelaus"
 
-#define pr_err(fmt, arg...)	printk(KERN_ERR DRIVER_NAME ": 
 ", ## arg);
-

Unnecessary whitespace removal.

Quoted 46 lines
drivers/i2c/chips/menelaus.c +0 -0
 #define MENELAUS_I2C_ADDRESS		0x72
 

#define MENELAUS_REV 0x01

drivers/i2c/chips/menelaus.c +3 -3
@@ -155,7 +153,7 @@ static int menelaus_write_reg(int reg, u8 value)
 	int val = 
 i2c_smbus_write_byte_data(the_menelaus->client, reg, value);
 
 	if (val < 0) {
-		pr_err("write error");
+		pr_err(DRIVER_NAME ": write error");
 		return val;
 	}
@@ -167,7 +165,7 @@ static int menelaus_read_reg(int reg)
 	int val = i2c_smbus_read_byte_data(the_menelaus->client, reg);
 
 	if (val < 0)
-		pr_err("read error");
+		pr_err(DRIVER_NAME ": read error");
 
 	return val;
 }
@@ -1177,7 +1175,7 @@ static int menelaus_probe(struct 
 i2c_client *client)
 	/* If a true probe check the device */
 	rev = menelaus_read_reg(MENELAUS_REV);
 	if (rev < 0) {
-		pr_err("device not found");
+		pr_err(DRIVER_NAME ": device not found");
 		err = -ENODEV;
 		goto fail1;
drivers/i2c/chips/menelaus.c +1 -1
 	}
@@ -1258,7 +1256,7 @@ static int __init menelaus_init(void)
 
 	res = i2c_add_driver(&menelaus_i2c_driver);
 	if (res < 0) {
-		pr_err("driver registration failed\n");
+		pr_err(DRIVER_NAME ": driver registration failed\n");
 		return res;
 	}
 
(quoted diff) +0 -0

b/drivers/net/spider_net.h index dbbdb8c..c67b11d 100644

drivers/net/spider_net.h struct spider_net_card { · line 498

Quoted 6 lines
drivers/net/spider_net.h +0 -3
@@ -493,7 +493,4 @@ struct spider_net_card {
 	struct spider_net_descr darray[0];
 };
 
-#define pr_err(fmt,arg...) \
-	printk(KERN_ERR fmt ,##arg)
-

Unnecessary whitespace removal.

drivers/video/omap/lcd_h3.c line 33

Quoted 12 lines
drivers/net/spider_net.h +0 -0
 #endif
(quoted diff) +0 -0

b/drivers/video/omap/lcd_h3.c index 51807b4..c604d93 100644

drivers/video/omap/lcd_h3.c +0 -2
@@ -28,8 +28,6 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": 
 " fmt, ## args)
-

Unnecessary whitespace removal.

Quoted 28 lines
drivers/video/omap/lcd_h3.c +0 -0
 static int h3_panel_init(struct lcd_panel *panel, struct 
 omapfb_device *fbdev)  {
drivers/video/omap/lcd_h3.c +2 -2
 	return 0;
@@ -48,7 +46,7 @@ static int h3_panel_enable(struct lcd_panel *panel)
 	if (!r)
 		r = tps65010_set_gpio_out_value(GPIO2, HIGH);
 	if (r)
-		pr_err("Unable to turn on LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn on LCD panel\n");
 
 	return r;
 }
@@ -62,7 +60,7 @@ static void h3_panel_disable(struct 
 lcd_panel *panel)
 	if (!r)
 		tps65010_set_gpio_out_value(GPIO2, LOW);
 	if (r)
-		pr_err("Unable to turn off LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn off LCD panel\n");
 }
 

static unsigned long h3_panel_get_caps(struct lcd_panel
*panel) diff --git a/drivers/video/omap/lcd_inn1610.c b/drivers/video/omap/lcd_inn1610.c
index 95604ca..5ef119c 100644

drivers/video/omap/lcd_inn1610.c line 32

Quoted 6 lines
drivers/video/omap/lcd_inn1610.c +0 -2
@@ -27,20 +27,18 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": 
 " fmt, ## args)
-

Unnecessary whitespace removal.

Quoted 32 lines
drivers/video/omap/lcd_inn1610.c +2 -2
 static int innovator1610_panel_init(struct lcd_panel *panel,
 				    struct omapfb_device *fbdev)
 {
 	int r = 0;
 
 	if (omap_request_gpio(14)) {
-		pr_err("can't request GPIO 14\n");
+		pr_err(MODULE_NAME ": can't request GPIO 14\n");
 		r = -1;
 		goto exit;
 	}
 	if (omap_request_gpio(15)) {
-		pr_err("can't request GPIO 15\n");
+		pr_err(MODULE_NAME ": can't request GPIO 15\n");
 		omap_free_gpio(14);
 		r = -1;
drivers/video/omap/lcd_inn1610.c +0 -0
 		goto exit;
include/linux/kernel.h +0 -0
index f592df7..c51936a 100644
@@ -242,6 +242,8 @@ static inline int __attribute__ ((format 

(printf, 1, 2))) pr_debug(const char *

#define pr_info(fmt,arg...) \

include/linux/kernel.h +2 -1
 	printk(KERN_INFO fmt,##arg)
+#define pr_err(fmt, arg...) \
+	printk(KERN_ERR fmt, ##arg)
 
 /*
  *      Display an IP address in readable format.
--
Quoted 1 line

1.5.3.GIT

Cheers,

-PJ Waskiewicz
Intel Corp.
[email protected]

#2 lore raw
Quoted 43 lines

-----Original Message-----
From: Waskiewicz Jr, Peter P [mailto:[email protected]]
Sent: Tuesday, September 11, 2007 2:48 PM
To: Medve Emilian-EMMEDVE1; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v2] Move the definition of pr_err() into kernel.h

Quoted 11 lines

Other pr_*() macros are already defined in kernel.h, but pr_err() was defined multiple times in several other places

---

I'm writing a driver and I've been using the pr_*() macros from kernel.h and I was surprised not to find there pr_err() but defined multiple times (in four different files). I didn't want to define it yet one more time so I did this cleanup

Quoted 6 lines

This patch is against Linus' tree v2.6.23-rc6
(0d4cbb5e7f60b2f1a4d8b7f6ea4cc264262c7a01)

linux-2.6> scripts/checkpatch.pl 0001-Move-the-definition-of-pr_err-into-kernel.h.patch Your patch has no obvious style problems and is ready for

submission.

Almost. :-)

Quoted 14 lines
 drivers/i2c/chips/menelaus.c     |   10 ++++------
 drivers/net/spider_net.h         |    3 ---
 drivers/video/omap/lcd_h3.c      |    6 ++----
 drivers/video/omap/lcd_inn1610.c |    6 ++----
 include/linux/kernel.h           |    2 ++
 5 files changed, 10 insertions(+), 17 deletions(-)
(quoted diff) +0 -0

b/drivers/i2c/chips/menelaus.c index d9c92c5..66436ba 100644

drivers/i2c/chips/menelaus.c +0 -0
@@ -49,8 +49,6 @@
 
Quoted 7 lines

drivers/i2c/chips/menelaus.c line 53

Quoted 5 lines
drivers/i2c/chips/menelaus.c +0 -2
 #define DRIVER_NAME			"menelaus"
 
-#define pr_err(fmt, arg...)	printk(KERN_ERR DRIVER_NAME ": 
 ", ## arg);
-

Unnecessary whitespace removal.

You mean the empty line after the macro definition? If I leave it then there will be two empty lines in the final file: the one you don't want me to remove and the one before the macro definition.

Quoted 145 lines
Quoted 47 lines
drivers/i2c/chips/menelaus.c +0 -0
 #define MENELAUS_I2C_ADDRESS		0x72
 

#define MENELAUS_REV 0x01

drivers/i2c/chips/menelaus.c +3 -3
@@ -155,7 +153,7 @@ static int menelaus_write_reg(int reg, u8 value)
 	int val = 
 i2c_smbus_write_byte_data(the_menelaus->client, reg, value);
 
 	if (val < 0) {
-		pr_err("write error");
+		pr_err(DRIVER_NAME ": write error");
 		return val;
 	}
@@ -167,7 +165,7 @@ static int menelaus_read_reg(int reg)
 	int val = i2c_smbus_read_byte_data(the_menelaus->client, reg);
 
 	if (val < 0)
-		pr_err("read error");
+		pr_err(DRIVER_NAME ": read error");
 
 	return val;
 }
@@ -1177,7 +1175,7 @@ static int menelaus_probe(struct 
 i2c_client *client)
 	/* If a true probe check the device */
 	rev = menelaus_read_reg(MENELAUS_REV);
 	if (rev < 0) {
-		pr_err("device not found");
+		pr_err(DRIVER_NAME ": device not found");
 		err = -ENODEV;
 		goto fail1;
drivers/i2c/chips/menelaus.c +1 -1
 	}
@@ -1258,7 +1256,7 @@ static int __init menelaus_init(void)
 
 	res = i2c_add_driver(&menelaus_i2c_driver);
 	if (res < 0) {
-		pr_err("driver registration failed\n");
+		pr_err(DRIVER_NAME ": driver registration failed\n");
 		return res;
 	}
 
(quoted diff) +0 -0

b/drivers/net/spider_net.h index dbbdb8c..c67b11d 100644

drivers/net/spider_net.h struct spider_net_card { · line 498

Quoted 6 lines
drivers/net/spider_net.h +0 -3
@@ -493,7 +493,4 @@ struct spider_net_card {
 	struct spider_net_descr darray[0];
 };
 
-#define pr_err(fmt,arg...) \
-	printk(KERN_ERR fmt ,##arg)
-

Unnecessary whitespace removal.

drivers/video/omap/lcd_h3.c line 33

Quoted 12 lines
drivers/net/spider_net.h +0 -0
 #endif
(quoted diff) +0 -0

b/drivers/video/omap/lcd_h3.c index 51807b4..c604d93 100644

drivers/video/omap/lcd_h3.c +0 -2
@@ -28,8 +28,6 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": 
 " fmt, ## args)
-

Unnecessary whitespace removal.

drivers/video/omap/lcd_h3.c static int h3_panel_enable(struct

Quoted 4 lines
drivers/video/omap/lcd_h3.c +0 -0
 static int h3_panel_init(struct lcd_panel *panel, struct 
 omapfb_device *fbdev)  {
drivers/video/omap/lcd_h3.c +0 -0
 	return 0;
@@ -48,7 +46,7 @@ static int h3_panel_enable(struct 

lcd_panel *panel)

Quoted 24 lines
drivers/video/omap/lcd_h3.c +2 -2
 	if (!r)
 		r = tps65010_set_gpio_out_value(GPIO2, HIGH);
 	if (r)
-		pr_err("Unable to turn on LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn on LCD panel\n");
 
 	return r;
 }
@@ -62,7 +60,7 @@ static void h3_panel_disable(struct 
 lcd_panel *panel)
 	if (!r)
 		tps65010_set_gpio_out_value(GPIO2, LOW);
 	if (r)
-		pr_err("Unable to turn off LCD panel\n");
+		pr_err(MODULE_NAME ": Unable to turn off LCD panel\n");
 }
 

static unsigned long h3_panel_get_caps(struct lcd_panel
*panel) diff --git a/drivers/video/omap/lcd_inn1610.c b/drivers/video/omap/lcd_inn1610.c
index 95604ca..5ef119c 100644

drivers/video/omap/lcd_inn1610.c line 32

Quoted 6 lines
drivers/video/omap/lcd_inn1610.c +0 -2
@@ -27,20 +27,18 @@
 
 #define MODULE_NAME	"omapfb-lcd_h3"
 
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": 
 " fmt, ## args)
-

Unnecessary whitespace removal.

Quoted 32 lines
drivers/video/omap/lcd_inn1610.c +2 -2
 static int innovator1610_panel_init(struct lcd_panel *panel,
 				    struct omapfb_device *fbdev)
 {
 	int r = 0;
 
 	if (omap_request_gpio(14)) {
-		pr_err("can't request GPIO 14\n");
+		pr_err(MODULE_NAME ": can't request GPIO 14\n");
 		r = -1;
 		goto exit;
 	}
 	if (omap_request_gpio(15)) {
-		pr_err("can't request GPIO 15\n");
+		pr_err(MODULE_NAME ": can't request GPIO 15\n");
 		omap_free_gpio(14);
 		r = -1;
drivers/video/omap/lcd_inn1610.c +0 -0
 		goto exit;
include/linux/kernel.h +0 -0
index f592df7..c51936a 100644
@@ -242,6 +242,8 @@ static inline int __attribute__ ((format 

(printf, 1, 2))) pr_debug(const char *

#define pr_info(fmt,arg...) \

include/linux/kernel.h +2 -1
 	printk(KERN_INFO fmt,##arg)
+#define pr_err(fmt, arg...) \
+	printk(KERN_ERR fmt, ##arg)
 
 /*
  *      Display an IP address in readable format.
--
Quoted 1 line

1.5.3.GIT

Cheers,

Quoted 3 lines

-PJ Waskiewicz
Intel Corp.
[email protected]

Thanks,
Emil.

#3 lore raw
In reply to Waskiewicz Jr, Peter P

Hi,

On 9/11/07, Waskiewicz Jr, Peter P <[email protected]> wrote:
<snip>

Quoted 5 lines
Quoted 3 lines

-#define pr_err(fmt, arg...) printk(KERN_ERR DRIVER_NAME ":
", ## arg);
-

Unnecessary whitespace removal.

Actually... I prefer removing the extra blank-line... it's easier to read and keeps on blank-line only to separate other defines/code-portion

Same to all the others

<snip><snip><snip><snip><snip>

Signature · 4 lines
Best Regards,

Felipe Balbi
[email protected]