From: Rohit Hagargundgi <h.rohit@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/4] JFFS2 commands support for Flex-OneNAND
Date: Sun, 08 Mar 2009 12:10:27 +0530 [thread overview]
Message-ID: <200903081210.27949.h.rohit@samsung.com> (raw)
In-Reply-To: <4941235E.6040105@samsung.com>
On Thursday 11 December 2008 19:57:42 Rohit Hagargundgi wrote:
> Add sanity check for the partitions.
> Some special cases handled by the check are:
> - A partition can span across erase regions.
> - A region can have odd number of blocks.
Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com>
---
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index 7866c80..7a8c07b 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -433,19 +433,72 @@ static int part_validate_onenand(struct mtdids *id, struct part_info *part)
#if defined(CONFIG_CMD_ONENAND)
/* info for OneNAND chips */
struct mtd_info *mtd;
+ int erasesize = 0;
mtd = &onenand_mtd;
- part->sector_size = mtd->erasesize;
+ if (mtd->numeraseregions > 1) {
+ int i, rgn, max = mtd->numeraseregions;
+ unsigned end = part->offset + part->size;
+ struct mtd_erase_region_info *regions = mtd->eraseregions;
+ unsigned portion_start, portion_end, region_end;
+
+ /* Find the first erase regions which is part of this
+ * partition.
+ */
+ i = flexonenand_region(mtd, part->offset);
+
+ /* Partition offset within region must align
+ * on region's erase size
+ */
+ if ((part->offset - regions[i].offset) % regions[i].erasesize) {
+ printf("%s%d: partition (%s) doesn't start on an erase"
+ " block boundary\n", MTD_DEV_TYPE(id->type),
+ id->num, part->name);
+ return 1;
+ }
- if ((unsigned long)(part->offset) % mtd->erasesize) {
- printf("%s%d: partition (%s) start offset"
- "alignment incorrect\n",
- MTD_DEV_TYPE(id->type), id->num, part->name);
- return 1;
+ erasesize = regions[i].erasesize;
+
+ /* A partition spanning across multiple erase regions has
+ * erase size equal to greatest erase size among the regions.
+ */
+ rgn = i;
+ for (; i < max && regions[i].offset < end; i++)
+ if (erasesize < regions[i].erasesize)
+ erasesize = regions[i].erasesize;
+
+ /* If partition spans many erase regions,
+ * the partition portion present in each region
+ * should be multiple of biggest erase size
+ */
+ for (i = rgn; i < max && regions[i].offset < end; i++) {
+ portion_start = max(regions[i].offset, part->offset);
+ region_end = regions[i].offset +
+ regions[i].erasesize * regions[i].numblocks;
+ portion_end = min(end, region_end);
+
+ if ((portion_end - portion_start) % erasesize) {
+ printf("%s%d: partition (%s) is not erase block"
+ " aligned within erase region\n",
+ MTD_DEV_TYPE(id->type), id->num, part->name);
+ return 1;
+ }
+ }
+ } else {
+ /* Single erase size */
+ erasesize = mtd->erasesize;
+ if ((unsigned long)(part->offset) % erasesize) {
+ printf("%s%d: partition (%s) start offset"
+ "alignment incorrect\n",
+ MTD_DEV_TYPE(id->type), id->num, part->name);
+ return 1;
+ }
}
- if (part->size % mtd->erasesize) {
+ part->sector_size = erasesize;
+
+ if (part->size % erasesize) {
printf("%s%d: partition (%s) size alignment incorrect\n",
MTD_DEV_TYPE(id->type), id->num, part->name);
return 1;
prev parent reply other threads:[~2009-03-08 6:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 14:27 [U-Boot] [PATCH v2 3/4] JFFS2 commands support for Flex-OneNAND Rohit Hagargundgi
2009-03-08 6:40 ` Rohit Hagargundgi [this message]
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=200903081210.27949.h.rohit@samsung.com \
--to=h.rohit@samsung.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox