linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mtd: mtdoops: use pr_ functions, add and direct call mtdoops_erase function when panic
@ 2022-10-07  6:50 Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions Ray Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ray Zhang @ 2022-10-07  6:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Ray Zhang

In mtdoops driver, to comply with latest kernel code requirement, change
printk() to counterpart pr_ functions. Add mtdoops_erase function; When
panic function invokes mtdoops, if needed, call mtdoops_erase function
immediately.

Ray Zhang (3):
  mtd: mtdoops: change printk() to counterpart pr_ functions
  mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter
    to after it
  mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function
    immediately

 drivers/mtd/mtdoops.c | 107 +++++++++++++++++++++++-------------------
 1 file changed, 60 insertions(+), 47 deletions(-)

-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions
  2022-10-07  6:50 [PATCH v2 0/3] mtd: mtdoops: use pr_ functions, add and direct call mtdoops_erase function when panic Ray Zhang
@ 2022-10-07  6:50 ` Ray Zhang
  2022-10-07  7:09   ` Joe Perches
  2022-10-07  6:50 ` [PATCH v2 2/3] mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 3/3] mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately Ray Zhang
  2 siblings, 1 reply; 7+ messages in thread
From: Ray Zhang @ 2022-10-07  6:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Ray Zhang

To comply with latest kernel code requirement, change printk() to
counterpart pr_ functions in mtdoops driver:
- change printk(INFO) to pr_info()
- change printk(DEBUG) to pr_debug()
- change printk(WARNING) to pr_warn()
- change printk(ERR) to pr_err()

Signed-off-by: Ray Zhang <sgzhang@google.com>
---
 drivers/mtd/mtdoops.c | 50 +++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 3d4a2ffb5b01..84b21be347f6 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -93,9 +93,9 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
 
 	ret = mtd_erase(mtd, &erase);
 	if (ret) {
-		printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
-		       (unsigned long long)erase.addr,
-		       (unsigned long long)erase.len, mtddev);
+		pr_warn("mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
+			(unsigned long long)erase.addr,
+			(unsigned long long)erase.len, mtddev);
 		return ret;
 	}
 
@@ -120,8 +120,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
 		return;
 	}
 
-	printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
-	       cxt->nextpage, cxt->nextcount);
+	pr_debug("mtdoops: ready %d, %d (no erase)\n",
+		 cxt->nextpage, cxt->nextcount);
 }
 
 /* Scheduled work - when we can't proceed without erasing a block */
@@ -145,20 +145,20 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
 
 	while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) {
 badblock:
-		printk(KERN_WARNING "mtdoops: bad block at %08lx\n",
-		       cxt->nextpage * record_size);
+		pr_warn("mtdoops: bad block at %08lx\n",
+			cxt->nextpage * record_size);
 		i++;
 		cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size);
 		if (cxt->nextpage >= cxt->oops_pages)
 			cxt->nextpage = 0;
 		if (i == cxt->oops_pages / (mtd->erasesize / record_size)) {
-			printk(KERN_ERR "mtdoops: all blocks bad!\n");
+			pr_err("mtdoops: all blocks bad!\n");
 			return;
 		}
 	}
 
 	if (ret < 0) {
-		printk(KERN_ERR "mtdoops: mtd_block_isbad failed, aborting\n");
+		pr_err("mtdoops: mtd_block_isbad failed, aborting\n");
 		return;
 	}
 
@@ -166,15 +166,15 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
 		ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size);
 
 	if (ret >= 0) {
-		printk(KERN_DEBUG "mtdoops: ready %d, %d\n",
-		       cxt->nextpage, cxt->nextcount);
+		pr_debug("mtdoops: ready %d, %d\n",
+			 cxt->nextpage, cxt->nextcount);
 		return;
 	}
 
 	if (ret == -EIO) {
 		ret = mtd_block_markbad(mtd, cxt->nextpage * record_size);
 		if (ret < 0 && ret != -EOPNOTSUPP) {
-			printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n");
+			pr_err("mtdoops: block_markbad failed, aborting\n");
 			return;
 		}
 	}
@@ -201,7 +201,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 		ret = mtd_panic_write(mtd, cxt->nextpage * record_size,
 				      record_size, &retlen, cxt->oops_buf);
 		if (ret == -EOPNOTSUPP) {
-			printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
+			pr_err("mtdoops: Cannot write from panic without panic_write\n");
 			goto out;
 		}
 	} else
@@ -209,7 +209,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 				record_size, &retlen, cxt->oops_buf);
 
 	if (retlen != record_size || ret < 0)
-		printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n",
+		pr_err("mtdoops: write failure at %ld (%td of %ld written), error %d\n",
 		       cxt->nextpage * record_size, retlen, record_size, ret);
 	mark_page_used(cxt, cxt->nextpage);
 	memset(cxt->oops_buf, 0xff, record_size);
@@ -244,7 +244,7 @@ static void find_next_position(struct mtdoops_context *cxt)
 			       &retlen, (u_char *)&hdr);
 		if (retlen != sizeof(hdr) ||
 				(ret < 0 && !mtd_is_bitflip(ret))) {
-			printk(KERN_ERR "mtdoops: read failure at %ld (%zu of %zu read), err %d\n",
+			pr_err("mtdoops: read failure at %ld (%zu of %zu read), err %d\n",
 			       page * record_size, retlen, sizeof(hdr), ret);
 			continue;
 		}
@@ -324,17 +324,17 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 		return;
 
 	if (mtd->size < mtd->erasesize * 2) {
-		printk(KERN_ERR "mtdoops: MTD partition %d not big enough for mtdoops\n",
+		pr_err("mtdoops: MTD partition %d not big enough for mtdoops\n",
 		       mtd->index);
 		return;
 	}
 	if (mtd->erasesize < record_size) {
-		printk(KERN_ERR "mtdoops: eraseblock size of MTD partition %d too small\n",
+		pr_err("mtdoops: eraseblock size of MTD partition %d too small\n",
 		       mtd->index);
 		return;
 	}
 	if (mtd->size > MTDOOPS_MAX_MTD_SIZE) {
-		printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n",
+		pr_err("mtdoops: mtd%d is too large (limit is %d MiB)\n",
 		       mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024);
 		return;
 	}
@@ -345,7 +345,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 				   DIV_ROUND_UP(mtdoops_pages,
 						BITS_PER_LONG)));
 	if (!cxt->oops_page_used) {
-		printk(KERN_ERR "mtdoops: could not allocate page array\n");
+		pr_err("mtdoops: could not allocate page array\n");
 		return;
 	}
 
@@ -353,7 +353,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 	cxt->dump.dump = mtdoops_do_dump;
 	err = kmsg_dump_register(&cxt->dump);
 	if (err) {
-		printk(KERN_ERR "mtdoops: registering kmsg dumper failed, error %d\n", err);
+		pr_err("mtdoops: registering kmsg dumper failed, error %d\n", err);
 		vfree(cxt->oops_page_used);
 		cxt->oops_page_used = NULL;
 		return;
@@ -362,7 +362,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 	cxt->mtd = mtd;
 	cxt->oops_pages = (int)mtd->size / record_size;
 	find_next_position(cxt);
-	printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index);
+	pr_info("mtdoops: Attached to MTD device %d\n", mtd->index);
 }
 
 static void mtdoops_notify_remove(struct mtd_info *mtd)
@@ -373,7 +373,7 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
 		return;
 
 	if (kmsg_dump_unregister(&cxt->dump) < 0)
-		printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n");
+		pr_warn("mtdoops: could not unregister kmsg_dumper\n");
 
 	cxt->mtd = NULL;
 	flush_work(&cxt->work_erase);
@@ -393,15 +393,15 @@ static int __init mtdoops_init(void)
 	char *endp;
 
 	if (strlen(mtddev) == 0) {
-		printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n");
+		pr_err("mtdoops: mtd device (mtddev=name/number) must be supplied\n");
 		return -EINVAL;
 	}
 	if ((record_size & 4095) != 0) {
-		printk(KERN_ERR "mtdoops: record_size must be a multiple of 4096\n");
+		pr_err("mtdoops: record_size must be a multiple of 4096\n");
 		return -EINVAL;
 	}
 	if (record_size < 4096) {
-		printk(KERN_ERR "mtdoops: record_size must be over 4096 bytes\n");
+		pr_err("mtdoops: record_size must be over 4096 bytes\n");
 		return -EINVAL;
 	}
 
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it
  2022-10-07  6:50 [PATCH v2 0/3] mtd: mtdoops: use pr_ functions, add and direct call mtdoops_erase function when panic Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions Ray Zhang
@ 2022-10-07  6:50 ` Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 3/3] mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately Ray Zhang
  2 siblings, 0 replies; 7+ messages in thread
From: Ray Zhang @ 2022-10-07  6:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Ray Zhang

Preparing for next patch with minimal code difference, add mtdoops_erase
function and move mtdoops_inc_counter to after it, with no functional
change.

Signed-off-by: Ray Zhang <sgzhang@google.com>
---
 drivers/mtd/mtdoops.c | 49 ++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 84b21be347f6..eca48dff9b53 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -106,29 +106,8 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
 	return 0;
 }
 
-static void mtdoops_inc_counter(struct mtdoops_context *cxt)
-{
-	cxt->nextpage++;
-	if (cxt->nextpage >= cxt->oops_pages)
-		cxt->nextpage = 0;
-	cxt->nextcount++;
-	if (cxt->nextcount == 0xffffffff)
-		cxt->nextcount = 0;
-
-	if (page_is_used(cxt, cxt->nextpage)) {
-		schedule_work(&cxt->work_erase);
-		return;
-	}
-
-	pr_debug("mtdoops: ready %d, %d (no erase)\n",
-		 cxt->nextpage, cxt->nextcount);
-}
-
-/* Scheduled work - when we can't proceed without erasing a block */
-static void mtdoops_workfunc_erase(struct work_struct *work)
+static void mtdoops_erase(struct mtdoops_context *cxt)
 {
-	struct mtdoops_context *cxt =
-			container_of(work, struct mtdoops_context, work_erase);
 	struct mtd_info *mtd = cxt->mtd;
 	int i = 0, j, ret, mod;
 
@@ -181,6 +160,32 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
 	goto badblock;
 }
 
+/* Scheduled work - when we can't proceed without erasing a block */
+static void mtdoops_workfunc_erase(struct work_struct *work)
+{
+	struct mtdoops_context *cxt =
+			container_of(work, struct mtdoops_context, work_erase);
+	mtdoops_erase(cxt);
+}
+
+static void mtdoops_inc_counter(struct mtdoops_context *cxt)
+{
+	cxt->nextpage++;
+	if (cxt->nextpage >= cxt->oops_pages)
+		cxt->nextpage = 0;
+	cxt->nextcount++;
+	if (cxt->nextcount == 0xffffffff)
+		cxt->nextcount = 0;
+
+	if (page_is_used(cxt, cxt->nextpage)) {
+		schedule_work(&cxt->work_erase);
+		return;
+	}
+
+	pr_debug("mtdoops: ready %d, %d (no erase)\n",
+		 cxt->nextpage, cxt->nextcount);
+}
+
 static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 {
 	struct mtd_info *mtd = cxt->mtd;
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately
  2022-10-07  6:50 [PATCH v2 0/3] mtd: mtdoops: use pr_ functions, add and direct call mtdoops_erase function when panic Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions Ray Zhang
  2022-10-07  6:50 ` [PATCH v2 2/3] mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it Ray Zhang
@ 2022-10-07  6:50 ` Ray Zhang
  2 siblings, 0 replies; 7+ messages in thread
From: Ray Zhang @ 2022-10-07  6:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Ray Zhang

The panic function disables the local interrupts, preemption, and all
other processors. When the invoked mtdoops needs to erase a used page,
calling schedule_work() to do it will not work. Instead, just call
mtdoops_erase function immediately.

Tested:
~# echo c > /proc/sysrq-trigger
[  171.654759] sysrq: Trigger a crash
[  171.658325] Kernel panic - not syncing: sysrq triggered crash
......
[  172.406423] mtdoops: not ready 34, 35 (erase immediately)
[  172.432285] mtdoops: ready 34, 35
[  172.435633] Rebooting in 10 seconds..

Signed-off-by: Ray Zhang <sgzhang@google.com>
---
 drivers/mtd/mtdoops.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index eca48dff9b53..eccb7dea892f 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -168,7 +168,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
 	mtdoops_erase(cxt);
 }
 
-static void mtdoops_inc_counter(struct mtdoops_context *cxt)
+static void mtdoops_inc_counter(struct mtdoops_context *cxt, int panic)
 {
 	cxt->nextpage++;
 	if (cxt->nextpage >= cxt->oops_pages)
@@ -178,12 +178,20 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
 		cxt->nextcount = 0;
 
 	if (page_is_used(cxt, cxt->nextpage)) {
-		schedule_work(&cxt->work_erase);
-		return;
+		pr_debug("mtdoops: not ready %d, %d (erase %s)\n",
+			 cxt->nextpage, cxt->nextcount,
+			 panic ? "immediately" : "scheduled");
+		if (panic) {
+			/* In case of panic, erase immediately */
+			mtdoops_erase(cxt);
+		} else {
+			/* Otherwise, schedule work to erase it "nicely" */
+			schedule_work(&cxt->work_erase);
+		}
+	} else {
+		pr_debug("mtdoops: ready %d, %d (no erase)\n",
+			 cxt->nextpage, cxt->nextcount);
 	}
-
-	pr_debug("mtdoops: ready %d, %d (no erase)\n",
-		 cxt->nextpage, cxt->nextcount);
 }
 
 static void mtdoops_write(struct mtdoops_context *cxt, int panic)
@@ -219,7 +227,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 	mark_page_used(cxt, cxt->nextpage);
 	memset(cxt->oops_buf, 0xff, record_size);
 
-	mtdoops_inc_counter(cxt);
+	mtdoops_inc_counter(cxt, panic);
 out:
 	clear_bit(0, &cxt->oops_buf_busy);
 }
@@ -284,7 +292,7 @@ static void find_next_position(struct mtdoops_context *cxt)
 		cxt->nextcount = maxcount;
 	}
 
-	mtdoops_inc_counter(cxt);
+	mtdoops_inc_counter(cxt, 0);
 }
 
 static void mtdoops_do_dump(struct kmsg_dumper *dumper,
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions
  2022-10-07  6:50 ` [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions Ray Zhang
@ 2022-10-07  7:09   ` Joe Perches
  2022-10-07  7:52     ` Miquel Raynal
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2022-10-07  7:09 UTC (permalink / raw)
  To: Ray Zhang, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel

On Fri, 2022-10-07 at 06:50 +0000, Ray Zhang wrote:
> To comply with latest kernel code requirement, change printk() to
> counterpart pr_ functions in mtdoops driver:
> - change printk(INFO) to pr_info()
> - change printk(DEBUG) to pr_debug()

There is a different behavior with printk(KERN_DEBUG to pr_debug(
as pr_debug is a no-op unless dynamic debugging is enabled or
DEBUG is defined.

And even with dynamic_debug, the output is default disabled unless
DEBUG is defined.

As is, printk(KERN_DEBUG is emitted unless the console level is low.

> diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
[]
> @@ -120,8 +120,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
>  		return;
>  	}
>  
> -	printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
> -	       cxt->nextpage, cxt->nextcount);
> +	pr_debug("mtdoops: ready %d, %d (no erase)\n",
> +		 cxt->nextpage, cxt->nextcount);
>  }

etc...


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions
  2022-10-07  7:09   ` Joe Perches
@ 2022-10-07  7:52     ` Miquel Raynal
  2022-10-07 15:43       ` Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Miquel Raynal @ 2022-10-07  7:52 UTC (permalink / raw)
  To: Joe Perches
  Cc: Ray Zhang, Richard Weinberger, Vignesh Raghavendra, linux-mtd,
	linux-kernel

Hi Joe, Ray,

joe@perches.com wrote on Fri, 07 Oct 2022 00:09:26 -0700:

> On Fri, 2022-10-07 at 06:50 +0000, Ray Zhang wrote:
> > To comply with latest kernel code requirement, change printk() to
> > counterpart pr_ functions in mtdoops driver:
> > - change printk(INFO) to pr_info()
> > - change printk(DEBUG) to pr_debug()  
> 
> There is a different behavior with printk(KERN_DEBUG to pr_debug(
> as pr_debug is a no-op unless dynamic debugging is enabled or
> DEBUG is defined.

I didn't know about this difference. I was expecting printk(KERN_DEBUG)
to behave the same as pr_debug/dev_dbg.

> And even with dynamic_debug, the output is default disabled unless
> DEBUG is defined.
> 
> As is, printk(KERN_DEBUG is emitted unless the console level is low.
> 
> > diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c  
> []
> > @@ -120,8 +120,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
> >  		return;
> >  	}
> >  
> > -	printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
> > -	       cxt->nextpage, cxt->nextcount);
> > +	pr_debug("mtdoops: ready %d, %d (no erase)\n",
> > +		 cxt->nextpage, cxt->nextcount);

But honestly in this driver I feel fine changing the printk(KERN_DEBUG)
into pr_debug().

Ray, maybe you can adapt your commit log to mention the difference?

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions
  2022-10-07  7:52     ` Miquel Raynal
@ 2022-10-07 15:43       ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2022-10-07 15:43 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Ray Zhang, Richard Weinberger, Vignesh Raghavendra, linux-mtd,
	linux-kernel

On Fri, 2022-10-07 at 09:52 +0200, Miquel Raynal wrote:
> Hi Joe, Ray,
> 
> joe@perches.com wrote on Fri, 07 Oct 2022 00:09:26 -0700:
> 
> > On Fri, 2022-10-07 at 06:50 +0000, Ray Zhang wrote:
> > > To comply with latest kernel code requirement, change printk() to
> > > counterpart pr_ functions in mtdoops driver:
> > > - change printk(INFO) to pr_info()
> > > - change printk(DEBUG) to pr_debug()  
> > 
> > There is a different behavior with printk(KERN_DEBUG to pr_debug(
> > as pr_debug is a no-op unless dynamic debugging is enabled or
> > DEBUG is defined.
> 
> I didn't know about this difference. I was expecting printk(KERN_DEBUG)
> to behave the same as pr_debug/dev_dbg.

No worries.  Most people do not know this trivia.

I just wanted to inform in case it matters here.
Likely it does not matter.

> But honestly in this driver I feel fine changing the printk(KERN_DEBUG)
> into pr_debug().

Your choice...

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-07 15:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07  6:50 [PATCH v2 0/3] mtd: mtdoops: use pr_ functions, add and direct call mtdoops_erase function when panic Ray Zhang
2022-10-07  6:50 ` [PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions Ray Zhang
2022-10-07  7:09   ` Joe Perches
2022-10-07  7:52     ` Miquel Raynal
2022-10-07 15:43       ` Joe Perches
2022-10-07  6:50 ` [PATCH v2 2/3] mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it Ray Zhang
2022-10-07  6:50 ` [PATCH v2 3/3] mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately Ray Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).