From: unsik Kim <donari75@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-BOOT][PATCH 3/3] mflash : Improve mg_disk_read(write) sector count calculation
Date: Tue, 17 Feb 2009 16:10:29 +0900 [thread overview]
Message-ID: <499A62E5.1000705@gmail.com> (raw)
Signed-off-by: unsik Kim <donari75@gmail.com>
---
drivers/block/mg_disk.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 2eb461d..bbfeeda 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -382,12 +382,8 @@ unsigned int mg_disk_read (u32 addr, u8 *buff, u32 len)
if (cur_addr < end_addr) {
sect_num = cur_addr >> MG_SECTOR_SIZE_SHIFT;
- next_sec_addr = cur_addr + MG_SECTOR_SIZE;
-
- while (next_sec_addr <= end_addr) {
- cnt++;
- next_sec_addr += MG_SECTOR_SIZE;
- }
+ cnt = ((end_addr & MG_SECTOR_SIZE_MASK) - cur_addr) >>
+ MG_SECTOR_SIZE_SHIFT;
if (cnt)
err = mg_disk_read_sects(buff_ptr, sect_num, cnt);
@@ -524,12 +520,8 @@ unsigned int mg_disk_write(u32 addr, u8 *buff, u32 len)
if (cur_addr < end_addr) {
sect_num = cur_addr >> MG_SECTOR_SIZE_SHIFT;
- next_sec_addr = cur_addr + MG_SECTOR_SIZE;
-
- while (next_sec_addr <= end_addr) {
- cnt++;
- next_sec_addr += MG_SECTOR_SIZE;
- }
+ cnt = ((end_addr & MG_SECTOR_SIZE_MASK) - cur_addr) >>
+ MG_SECTOR_SIZE_SHIFT;
if (cnt)
err = mg_disk_write_sects(buff_ptr, sect_num, cnt);
--
1.5.6.6
reply other threads:[~2009-02-17 7:10 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=499A62E5.1000705@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 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.