[PATCH] char: mem: fix typo and use pr_err() for logging

Minu Jin posted 1 patch 1 month ago
drivers/char/mem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] char: mem: fix typo and use pr_err() for logging
Posted by Minu Jin 1 month ago
Fix a typo in the comment of read_mem(): funcion -> function

Replace a raw printk() call in chr_dev_init() with pr_err().
The original call lacked a log level, which is discouraged.

Using pr_err() ensures the error is properly categorized and
follows modern logging practices.

Signed-off-by: Minu Jin <s9430939@naver.com>
---
 drivers/char/mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 52039fae1594..4c6bb10d1508 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -76,7 +76,7 @@ static inline bool should_stop_iteration(void)
 }
 
 /*
- * This funcion reads the *physical* memory. The f_pos points directly to the
+ * This function reads the *physical* memory. The f_pos points directly to the
  * memory location.
  */
 static ssize_t read_mem(struct file *file, char __user *buf,
@@ -765,7 +765,7 @@ static int __init chr_dev_init(void)
 	int minor;
 
 	if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
-		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
+		pr_err("unable to get major %d for memory devs\n", MEM_MAJOR);
 
 	retval = class_register(&mem_class);
 	if (retval)
-- 
2.43.0
Re: [PATCH] char: mem: fix typo and use pr_err() for logging
Posted by Greg KH 3 weeks, 1 day ago
On Fri, Jan 02, 2026 at 03:27:59PM +0900, Minu Jin wrote:
> Fix a typo in the comment of read_mem(): funcion -> function
> 
> Replace a raw printk() call in chr_dev_init() with pr_err().
> The original call lacked a log level, which is discouraged.
> 
> Using pr_err() ensures the error is properly categorized and
> follows modern logging practices.

This is two different things, it should be 2 different patches (yes, I'm
being pedantic, sorry, that's because:)

>  	if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
> -		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
> +		pr_err("unable to get major %d for memory devs\n", MEM_MAJOR);

This change doesn't really do anything different, so it's not needed.
Let's leave it alone as it's been this way for decades.

thanks,

greg k-h