Skip to contentSkip to conversation

HID: hidraw: replace printk() with corresponding pr_xx() variant

PATCH Superseded Rishi Gupta 3 participants 6 messages Aug 22, 2019 – Oct 1, 2019 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hidraw: replace printk() with corresponding pr_xx() variant

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
 drivers/hid/hidraw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hidraw.c +3 -3
index 006bd6f..67b652b 100644
@@ -197,14 +197,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	if (count > HID_MAX_BUFFER_SIZE) {
-		printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
+		pr_warn("hidraw: pid %d passed too large report\n",
 				task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (count < 2) {
-		printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
+		pr_warn("hidraw: pid %d passed too short report\n",
 				task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
@@ -597,7 +597,7 @@ int __init hidraw_init(void)
 	if (result < 0)
 		goto error_class;
 
-	printk(KERN_INFO "hidraw: raw HID events driver (C) Jiri Kosina\n");
+	pr_info("hidraw: raw HID events driver (C) Jiri Kosina\n");
 out:
 	return result;
 
Signature · 1 line
2.7.4
#1 lore raw

Hi Rishi,

Quoted 13 lines · Rishi Gupta

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
 drivers/hid/hidraw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hidraw.c +0 -0
index 006bd6f..67b652b 100644

drivers/hid/hidraw.c static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t · line 201

Quoted 6 lines
drivers/hid/hidraw.c +1 -1
@@ -197,14 +197,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	if (count > HID_MAX_BUFFER_SIZE) {
-		printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
+		pr_warn("hidraw: pid %d passed too large report\n",
 				task_pid_nr(current));

If you are doing this, you should also look into pr_fmt() so that we do not need to manually add "hidraw: " prefix to the messages.

Quoted 22 lines
drivers/hid/hidraw.c +2 -2
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (count < 2) {
-		printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
+		pr_warn("hidraw: pid %d passed too short report\n",
 				task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
@@ -597,7 +597,7 @@ int __init hidraw_init(void)
 	if (result < 0)
 		goto error_class;
 
-	printk(KERN_INFO "hidraw: raw HID events driver (C) Jiri Kosina\n");
+	pr_info("hidraw: raw HID events driver (C) Jiri Kosina\n");
 out:
 	return result;
 
Signature · 1 line
2.7.4

Thanks.

Signature · 1 line
Dmitry
#2 lore raw

PATCH v2 1/1 HID: hidraw: replace printk() with corresponding pr_xx() variant

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
Changes in v2:
- Removed manually adding prefix "hidraw:".

 drivers/hid/hidraw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hidraw.c +3 -3
index 006bd6f..2d082f3 100644
@@ -197,14 +197,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	if (count > HID_MAX_BUFFER_SIZE) {
-		printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
+		pr_warn("pid %d passed too large report\n",
 				task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (count < 2) {
-		printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
+		pr_warn("pid %d passed too short report\n",
 				task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
@@ -597,7 +597,7 @@ int __init hidraw_init(void)
 	if (result < 0)
 		goto error_class;
 
-	printk(KERN_INFO "hidraw: raw HID events driver (C) Jiri Kosina\n");
+	pr_info("raw HID events driver (C) Jiri Kosina\n");
 out:
 	return result;
 
Signature · 1 line
2.7.4
#3 lore raw

Hi Rishi,

Quoted 16 lines · Rishi Gupta

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
Changes in v2:
- Removed manually adding prefix "hidraw:".

 drivers/hid/hidraw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hidraw.c +0 -0
index 006bd6f..2d082f3 100644

drivers/hid/hidraw.c static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t · line 201

Quoted 6 lines
drivers/hid/hidraw.c +1 -1
@@ -197,14 +197,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	if (count > HID_MAX_BUFFER_SIZE) {
-		printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
+		pr_warn("pid %d passed too large report\n",
 				task_pid_nr(current));

It looks like here and in the instance below you actually have a hid device, so you can use hid_warn() instead of pr_warn(), similarly to hidraw_send_report().

The change to pr_info() in hidraw_init() is good.

Thanks.

Signature · 1 line
Dmitry
#4 lore raw

PATCH v3 1/1 HID: hidraw: replace printk() with corresponding pr_xx() variant

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
Changes in v3:
* Use hid_warn() subsystem specific variant instead of pr_warn()

 drivers/hid/hidraw.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hid/hidraw.c +5 -5
index 006bd6f..a42f4b5 100644
@@ -197,15 +197,15 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	if (count > HID_MAX_BUFFER_SIZE) {
-		printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
-				task_pid_nr(current));
+		hid_warn(dev, "pid %d passed too large report\n",
+			task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (count < 2) {
-		printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
-				task_pid_nr(current));
+		hid_warn(dev, "pid %d passed too short report\n",
+			task_pid_nr(current));
 		ret = -EINVAL;
 		goto out;
 	}
@@ -597,7 +597,7 @@ int __init hidraw_init(void)
 	if (result < 0)
 		goto error_class;
 
-	printk(KERN_INFO "hidraw: raw HID events driver (C) Jiri Kosina\n");
+	pr_info("raw HID events driver (C) Jiri Kosina\n");
 out:
 	return result;
 
Signature · 1 line
2.7.4
maintainer Applied
#5 lore raw
Quoted 7 lines · Rishi Gupta

This commit replaces direct invocations of printk with their appropriate pr_info/warn() variant.

---
Changes in v3:
* Use hid_warn() subsystem specific variant instead of pr_warn()

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs