public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: unsik Kim <donari75@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-BOOT][PATCH 2/3] Change CONFIG_MG_DISK_RES unit to KB
Date: Fri, 13 Feb 2009 20:06:03 +0900	[thread overview]
Message-ID: <4995541B.9080502@gmail.com> (raw)

Byte is too small unit for CONFIG_MG_DISK_RES and also needs
sector size alignment.

Signed-off-by: unsik Kim <donari75@gmail.com>
---
 doc/README.mflash       |   10 +++++-----
 drivers/block/mg_disk.c |   10 +++-------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/doc/README.mflash b/doc/README.mflash
index fb74b90..d0d0f7b 100644
--- a/doc/README.mflash
+++ b/doc/README.mflash
@@ -30,13 +30,13 @@ sector) and size of 0x400 (1024 byte)
 
 * Reserved size config (optional)
 If you want to use some reserved area for bootloader, environment variable or
-whatever, use CONFIG_MG_DISK_RES. The value should be multiple of
-MG_SECTOR_SIZE (512Byte). Mflash's block operation method use this value as
-start offset. So any u-boot's partition table parser and file system command
-work consistently. You can access this area by using mflash command.
+whatever, use CONFIG_MG_DISK_RES. The unit is KB. Mflash's block operation
+method use this value as start offset. So any u-boot's partition table parser
+and file system command work consistently. You can access this area by using
+mflash command.
 
 Following example sets 10MB of reserved area.
-#define CONFIG_MG_DISK_RES	10485760
+#define CONFIG_MG_DISK_RES	10240
 
 2-2. Porting mg_get_drv_data function
 Mflash is active device and need some gpio control for proper operation.
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 4454fca..e1b1a68 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -34,11 +34,7 @@
 #define CONFIG_MG_DISK_RES	0
 #endif
 
-#if (CONFIG_MG_DISK_RES % MG_SECTOR_SIZE != 0)
-#error "CONFIG_MG_DISK_RES should be MG_SECTOR_SIZE algined"
-#endif
-
-#define MG_DISK_RES ((CONFIG_MG_DISK_RES) / MG_SECTOR_SIZE)
+#define MG_RES_SEC ((CONFIG_MG_DISK_RES) << 1)
 
 #define MG_BASE	(host.drv_data->base)
 
@@ -344,7 +340,7 @@ unsigned int mg_disk_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
 unsigned long mg_block_read (int dev, unsigned long start,
 		lbaint_t blkcnt, void *buffer)
 {
-	start += MG_DISK_RES;
+	start += MG_RES_SEC;
 	if (! mg_disk_read_sects(buffer, start, blkcnt))
 		return blkcnt;
 	else
@@ -482,7 +478,7 @@ unsigned int mg_disk_write_sects(void *buff, u32 sect_num, u32 sect_cnt)
 unsigned long mg_block_write (int dev, unsigned long start,
 		lbaint_t blkcnt, const void *buffer)
 {
-	start += MG_DISK_RES;
+	start += MG_RES_SEC;
 	if (!mg_disk_write_sects((void *)buffer, start, blkcnt))
 		return blkcnt;
 	else
-- 
1.5.6.6

             reply	other threads:[~2009-02-13 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 11:06 unsik Kim [this message]
2009-02-14 11:52 ` [U-Boot] [U-BOOT][PATCH 2/3] Change CONFIG_MG_DISK_RES unit to KB Jean-Christophe PLAGNIOL-VILLARD
2009-02-17  7:10   ` [U-Boot] [PATCH " unsik Kim

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=4995541B.9080502@gmail.com \
    --to=donari75@gmail.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