mtd: mtdpart: convert printk to pr_* and define pr_fmt
PATCH v2 1/1 mtd: mtdpart: convert printk to pr_* and define pr_fmt
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"
---
Changes in v2:
- Fix alignment of continuation lines to match open parenthesis
drivers/mtd/mtdpart.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/mtd/mtdpart.c +20 -20
@@ -6,6 +6,7 @@* Copyright © 2002 Thomas Gleixner <[email protected]> * Copyright © 2000-2010 David Woodhouse <[email protected]> */ +#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,10 +101,10 @@ 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: " -"0x%012llx -> 0x%012llx\n" , partno, - (unsigned long long )cur_offset, - child->part.offset); +pr_notice ("Moving partition %d: 0x%012llx -> 0x%012llx\n" , + partno, + (unsigned long long )cur_offset, + child->part.offset); } }if (child->part.offset ==MTDPART_OFS_RETAIN ) {
@@ -114,9 +115,9 @@ 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" , - part->name, parent_size - child->part.offset, - child->part.size); +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 */ child->part.offset =0 ; child->part.size =0 ;
@@ -127,9 +128,9 @@ 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" , - child->part.offset, child->part.offset + child->part.size, - child->name); +pr_notice ("0x%012llx-0x%012llx : \"%s\"\n" , + child->part.offset, child->part.offset + child->part.size, + child->name);/* let's do some sanity checks */ if (child->part.offset >= parent_size) {
@@ -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" , - part->name); +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,8 +409,8 @@ 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" , - nbparts, parent->name); +pr_notice ("Creating %d MTD partitions on \"%s\":\n" , + nbparts, parent->name);for (i =0 ; i < nbparts; i++) { child =allocate_partition (parent, parts + i, i, cur_offset);
Signature · 1 line
2.56.1
Miquel Raynal
maintainerQuoted 8 lines · Mihai Sain
Define
pr_fmtto prefix all pr_* print statements in this file with "mtd: ". Convert legacyprintk()invocations to their modernpr_err(),pr_warn(), andpr_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.
I am sorry but it does not apply on mtd/next, can you please rebase on top?
Thanks,
Miquèl