linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: print out the partition's read-only flag
@ 2014-04-30  3:53 Huang Shijie
  2014-04-30  3:53 ` [PATCH 2/2] mtd: show the partition's flags in the the /proc/mtd Huang Shijie
  2014-05-20  8:53 ` [PATCH 1/2] mtd: print out the partition's read-only flag Brian Norris
  0 siblings, 2 replies; 3+ messages in thread
From: Huang Shijie @ 2014-04-30  3:53 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd

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(-)

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;
-- 
1.7.2.rc3

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

* [PATCH 2/2] mtd: show the partition's flags in the the /proc/mtd
  2014-04-30  3:53 [PATCH 1/2] mtd: print out the partition's read-only flag Huang Shijie
@ 2014-04-30  3:53 ` Huang Shijie
  2014-05-20  8:53 ` [PATCH 1/2] mtd: print out the partition's read-only flag Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Huang Shijie @ 2014-04-30  3:53 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd

This patch adds the flags information when we use the "cat /proc/mtd".

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

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 9cdc154..c62ee70 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1132,12 +1132,12 @@ static int mtd_proc_show(struct seq_file *m, void *v)
 {
 	struct mtd_info *mtd;
 
-	seq_puts(m, "dev:    size   erasesize  name\n");
+	seq_puts(m, "dev:    size   erasesize   flags   name\n");
 	mutex_lock(&mtd_table_mutex);
 	mtd_for_each_device(mtd) {
-		seq_printf(m, "mtd%d: %8.8llx %8.8x \"%s\"\n",
+		seq_printf(m, "mtd%d: %8.8llx %8.8x  %8.8x \"%s\"\n",
 			   mtd->index, (unsigned long long)mtd->size,
-			   mtd->erasesize, mtd->name);
+			   mtd->erasesize, mtd->flags, mtd->name);
 	}
 	mutex_unlock(&mtd_table_mutex);
 	return 0;
-- 
1.7.2.rc3

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

* Re: [PATCH 1/2] mtd: print out the partition's read-only flag
  2014-04-30  3:53 [PATCH 1/2] mtd: print out the partition's read-only flag Huang Shijie
  2014-04-30  3:53 ` [PATCH 2/2] mtd: show the partition's flags in the the /proc/mtd Huang Shijie
@ 2014-05-20  8:53 ` Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Norris @ 2014-05-20  8:53 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-mtd, dwmw2

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

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

end of thread, other threads:[~2014-05-20  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30  3:53 [PATCH 1/2] mtd: print out the partition's read-only flag Huang Shijie
2014-04-30  3:53 ` [PATCH 2/2] mtd: show the partition's flags in the the /proc/mtd Huang Shijie
2014-05-20  8:53 ` [PATCH 1/2] mtd: print out the partition's read-only flag Brian Norris

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).