mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] ARM: i.MX5: internal NAND update: Use variable for pre_image_size
Date: Thu, 24 Jul 2014 08:48:10 +0200	[thread overview]
Message-ID: <1406184493-29225-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1406184493-29225-1-git-send-email-s.hauer@pengutronix.de>

We have the hardcoded value 0x8000 for the space needed for FCB and
DBBT in several places. Use a variable instead and initialize it
correctly with 12 * meminfo.writesize (which is in fact 0x6000 for
2k pagesize).

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 125415e..ae981e8 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -178,6 +178,7 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler *
 	uint32_t *ptr, *num_bb, *bb;
 	uint64_t offset;
 	int block = 0, len, now, blocksize;
+	int pre_image_size;
 
 	ret = stat(data->devicefile, &s);
 	if (ret)
@@ -193,6 +194,8 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler *
 	if (ret)
 		goto out;
 
+	pre_image_size = 12 * meminfo.writesize;
+
 	blocksize = meminfo.erasesize;
 
 	ptr = image + 0x4;
@@ -218,7 +221,7 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler *
 	bb = ptr + 1;
 	offset = 0;
 
-	size_need = data->len + 0x8000;
+	size_need = data->len + pre_image_size;
 
 	/*
 	 * Collect bad blocks and construct DBBT
@@ -261,18 +264,18 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler *
 	}
 
 	debug("total image size: 0x%08zx. Space needed including bad blocks: 0x%08zx\n",
-			data->len + 0x8000,
-			data->len + 0x8000 + *num_bb * blocksize);
+			data->len + pre_image_size,
+			data->len + pre_image_size + *num_bb * blocksize);
 
-	if (data->len + 0x8000 + *num_bb * blocksize > imx_handler->device_size) {
+	if (data->len + pre_image_size + *num_bb * blocksize > imx_handler->device_size) {
 		printf("needed space (0x%08zx) exceeds partition space (0x%08zx)\n",
-				data->len + 0x8000 + *num_bb * blocksize,
+				data->len + pre_image_size + *num_bb * blocksize,
 				imx_handler->device_size);
 		ret = -ENOSPC;
 		goto out;
 	}
 
-	len = data->len + 0x8000;
+	len = data->len + pre_image_size;
 	offset = 0;
 
 	/*
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-07-24  6:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24  6:48 [PATCH] i.MX5 internal NAND update fixes/cleanup Sascha Hauer
2014-07-24  6:48 ` Sascha Hauer [this message]
2014-07-24  6:48 ` [PATCH 2/4] ARM: i.MX5: internal NAND update: Fix firmware start page for internal nand boot Sascha Hauer
2014-07-24  6:48 ` [PATCH 3/4] ARM: i.MX5: internal NAND update: Use variables for some constants Sascha Hauer
2014-07-24  6:48 ` [PATCH 4/4] ARM: i.MX5: internal NAND update: simplify code Sascha Hauer

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=1406184493-29225-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox