* [PATCH] mtd: mtdpart: convert printk to pr_* and define pr_fmt
@ 2026-10-13 8:23 Mihai Sain
0 siblings, 0 replies; only message in thread
From: Mihai Sain @ 2026-10-13 8:23 UTC (permalink / raw)
To: miquel.raynal, richard, vigneshr; +Cc: linux-mtd, linux-kernel, Mihai Sain
Define pr_fmt to prefix all pr_* print statements in this file with
"mtd: ". Convert legacy printk() invocations to their modern pr_err(),
pr_warn(), and pr_notice() equivalents so that the prefix applies
consistently across all logs.
Where applicable, redundant "mtd: " substrings embedded within individual
print strings were removed to avoid duplicate prefixing in the final output.
before this patch:
[ 1.593577] 6 fixed-partitions partitions found on MTD device at91-nand
[ 1.600241] Creating 6 MTD partitions on "at91-nand":
[ 1.605304] 0x000000000000-0x000000040000 : "nand: at91bootstrap"
[ 1.611961] 0x000000040000-0x000000140000 : "nand: u-boot"
[ 1.617855] 0x000000140000-0x000000180000 : "nand: u-boot env"
[ 1.624128] 0x000000180000-0x000000200000 : "nand: device tree"
[ 1.630517] 0x000000200000-0x000000800000 : "nand: kernel"
[ 1.636322] 0x000000800000-0x000040000000 : "nand: rootfs"
after this patch:
[ 1.596940] mtd: 6 fixed-partitions partitions found on MTD device at91-nand
[ 1.604040] mtd: Creating 6 MTD partitions on "at91-nand":
[ 1.609480] mtd: 0x000000000000-0x000000040000 : "nand: at91bootstrap"
[ 1.616700] mtd: 0x000000040000-0x000000140000 : "nand: u-boot"
[ 1.623149] mtd: 0x000000140000-0x000000180000 : "nand: u-boot env"
[ 1.629729] mtd: 0x000000180000-0x000000200000 : "nand: device tree"
[ 1.636543] mtd: 0x000000200000-0x000000800000 : "nand: kernel"
[ 1.642889] mtd: 0x000000800000-0x000040000000 : "nand: rootfs"
Signed-off-by: Mihai Sain <mihai.sain@microchip.com>
---
drivers/mtd/mtdpart.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index ddded0dbe77e..df93f198b1b2 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -6,6 +6,7 @@
* Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de>
* Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
*/
+#define pr_fmt(fmt) "mtd: " fmt
#include <linux/module.h>
#include <linux/types.h>
@@ -57,7 +58,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
child = kzalloc_obj(*child);
name = kstrdup(part->name, GFP_KERNEL);
if (!name || !child) {
- printk(KERN_ERR"memory allocation error while creating partitions for \"%s\"\n",
+ pr_err("memory allocation error while creating partitions for \"%s\"\n",
parent->name);
kfree(name);
kfree(child);
@@ -102,7 +103,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
remainder = do_div(tmp, wr_alignment);
if (remainder) {
child->part.offset += wr_alignment - remainder;
- printk(KERN_NOTICE "Moving partition %d: "
+ pr_notice("Moving partition %d: "
"0x%012llx -> 0x%012llx\n", partno,
(unsigned long long)cur_offset,
child->part.offset);
@@ -114,7 +115,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
child->part.size = parent_size - child->part.offset -
child->part.size;
} else {
- printk(KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n",
+ pr_err("partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n",
part->name, parent_size - child->part.offset,
child->part.size);
/* register to preserve ordering */
@@ -127,7 +128,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
if (child->part.size == MTDPART_SIZ_FULL)
child->part.size = parent_size - child->part.offset;
- printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n",
+ pr_notice("0x%012llx-0x%012llx : \"%s\"\n",
child->part.offset, child->part.offset + child->part.size,
child->name);
@@ -139,13 +140,13 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
/* Initialize ->erasesize to make add_mtd_device() happy. */
child->erasesize = parent->erasesize;
- printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
+ pr_err("partition \"%s\" is out of reach -- disabled\n",
part->name);
goto out_register;
}
if (child->part.offset + child->part.size > parent->size) {
child->part.size = parent_size - child->part.offset;
- printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n",
+ pr_warn("partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n",
part->name, parent->name, child->part.size);
}
@@ -190,7 +191,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
/* FIXME: Let it be writable if it is on a boundary of
* _minor_ erase size though */
child->flags &= ~MTD_WRITEABLE;
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase/write block boundary -- force read-only\n",
+ pr_warn("partition \"%s\" doesn't start on an erase/write block boundary -- force read-only\n",
part->name);
}
@@ -198,7 +199,7 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
remainder = do_div(tmp, wr_alignment);
if ((child->flags & MTD_WRITEABLE) && remainder) {
child->flags &= ~MTD_WRITEABLE;
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase/write block -- force read-only\n",
+ pr_warn("partition \"%s\" doesn't end on an erase/write block -- force read-only\n",
part->name);
}
@@ -241,8 +242,7 @@ static int mtd_add_partition_attrs(struct mtd_info *new)
{
int ret = sysfs_create_files(&new->dev.kobj, mtd_partition_attrs);
if (ret)
- printk(KERN_WARNING
- "mtd: failed to create partition attrs, err=%d\n", ret);
+ pr_warn("failed to create partition attrs, err=%d\n", ret);
return ret;
}
@@ -409,7 +409,7 @@ int add_mtd_partitions(struct mtd_info *parent,
uint64_t cur_offset = 0;
int i, ret;
- printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n",
+ pr_notice("Creating %d MTD partitions on \"%s\":\n",
nbparts, parent->name);
for (i = 0; i < nbparts; i++) {
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-13 8:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-13 8:23 [PATCH] mtd: mtdpart: convert printk to pr_* and define pr_fmt Mihai Sain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®