diff mbox

[1/2] mtd: print out the partition's read-only flag

Message ID 1398830010-3628-1-git-send-email-b32955@freescale.com
State Rejected
Headers show

Commit Message

Huang Shijie April 30, 2014, 3:53 a.m. UTC
We may set a partition to be read only with DT property or kernel cmdline,
such as the kernel cmdline:
  mtdparts=50000000.nor:2m(boot)ro,2m(dtb),5m(kernel),-(test)

This patch prints out the partition's read-only flag in the boot precedure,
which makes us more clear about the read-only partition.

Before this patch, the partitions show like this:
	0x000000000000-0x000000200000 : "boot"
	0x000000200000-0x000000400000 : "dtb"
	0x000000400000-0x000000900000 : "kernel"
	0x000000900000-0x000002000000 : "test"

After this patch, the partitions show like this:

	0x000000000000-0x000000200000 : "boot"	 (Read-Only)
	0x000000200000-0x000000400000 : "dtb"
	0x000000400000-0x000000900000 : "kernel"
	0x000000900000-0x000002000000 : "test"

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/mtdpart.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Comments

Brian Norris May 20, 2014, 8:53 a.m. UTC | #1
On Wed, Apr 30, 2014 at 11:53:29AM +0800, Huang Shijie wrote:
> We may set a partition to be read only with DT property or kernel cmdline,
> such as the kernel cmdline:
>   mtdparts=50000000.nor:2m(boot)ro,2m(dtb),5m(kernel),-(test)
> 
> This patch prints out the partition's read-only flag in the boot precedure,
> which makes us more clear about the read-only partition.
> 
> Before this patch, the partitions show like this:
> 	0x000000000000-0x000000200000 : "boot"
> 	0x000000200000-0x000000400000 : "dtb"
> 	0x000000400000-0x000000900000 : "kernel"
> 	0x000000900000-0x000002000000 : "test"
> 
> After this patch, the partitions show like this:
> 
> 	0x000000000000-0x000000200000 : "boot"	 (Read-Only)
> 	0x000000200000-0x000000400000 : "dtb"
> 	0x000000400000-0x000000900000 : "kernel"
> 	0x000000900000-0x000002000000 : "test"
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>

Nak to both. /proc/mtd shouldn't really be changing formats like this.

Brian
diff mbox

Patch

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 84f5866..f660658 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -458,9 +458,6 @@  static struct mtd_part *allocate_partition(struct mtd_info *master,
 	if (slave->mtd.size == MTDPART_SIZ_FULL)
 		slave->mtd.size = master->size - slave->offset;
 
-	printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset,
-		(unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name);
-
 	/* let's do some sanity checks */
 	if (slave->offset >= master->size) {
 		/* let's register it anyway to preserve ordering */
@@ -517,6 +514,12 @@  static struct mtd_part *allocate_partition(struct mtd_info *master,
 			part->name);
 	}
 
+	printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\t%s\n",
+		(unsigned long long)slave->offset,
+		(unsigned long long)(slave->offset + slave->mtd.size),
+		slave->mtd.name,
+		slave->mtd.flags & MTD_WRITEABLE ? "" : " (Read-Only)");
+
 	slave->mtd.ecclayout = master->ecclayout;
 	slave->mtd.ecc_step_size = master->ecc_step_size;
 	slave->mtd.ecc_strength = master->ecc_strength;