From: Rohit <h.rohit@samsung.com>
To: linux-mtd@lists.infradead.org
Cc: 'David Woodhouse' <dwmw2@infradead.org>
Subject: [RFC] [PATCH 1/2] [MTDPARTS] Support erase regions with odd numbered blocks
Date: Tue, 11 Nov 2008 11:01:24 +0530 [thread overview]
Message-ID: <491918AC.4090502@samsung.com> (raw)
Hi,
Currently add_one_partition in mtdpart.c does not handle erase regions
with odd number of blocks well. Some scenarios are :
1. Region 0 has 3 blocks of 256KB. Region 1 has 512KB blocks.
Partiton starting at offset 256KB and size 1MB turns read only.
2. Region 0 has 3 blocks of 256KB. Region 1 has 512KB blocks.
All partitions created on region 2 turn read only.
Every partition start offset should be multiple of partition erase size.
It is this condition which causes valid partitions to turn read-only.
The following patch is an attempt to allow such regions.
Is such a change to MTD core correct / acceptable?
Any suggestions are much appreciated.
Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com>
---
mtdpart.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 3728913..5cdc345 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -320,6 +320,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
u_int32_t cur_offset)
{
struct mtd_part *slave;
+ unsigned offset_checked = 0;
/* allocate the partition structure */
slave = kzalloc(sizeof(*slave), GFP_KERNEL);
@@ -436,6 +437,20 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
/* The loop searched for the region _behind_ the first one */
i--;
+ if (slave->mtd.flags & MTD_WRITEABLE) {
+ /* A region starts on boundary of it's erase size.
+ * Partition offset within region must align
+ * on region's erase size
+ */
+ if ((slave->offset - regions[i].offset) % regions[i].erasesize) {
+ slave->mtd.flags &= ~MTD_WRITEABLE;
+ printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an "
+ "erase block boundary -- force read-only\n", part->name);
+ } else
+ /* Skip offset check below */
+ offset_checked = 1;
+ }
+
/* Pick biggest erasesize */
for (; i < max && regions[i].offset < end; i++) {
if (slave->mtd.erasesize < regions[i].erasesize) {
@@ -448,7 +463,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
slave->mtd.erasesize = master->erasesize;
}
- if ((slave->mtd.flags & MTD_WRITEABLE) &&
+ if (!offset_checked && (slave->mtd.flags & MTD_WRITEABLE) &&
(slave->offset % slave->mtd.erasesize)) {
/* Doesn't start on a boundary of major erase size */
/* FIXME: Let it be writable if it is on a boundary of
---
reply other threads:[~2008-11-11 5:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=491918AC.4090502@samsung.com \
--to=h.rohit@samsung.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.