From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] mci: remove unnecessary loops
Date: Fri, 11 Nov 2011 12:38:14 +0100 [thread overview]
Message-ID: <1321011494-4274-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1321011494-4274-1-git-send-email-s.hauer@pengutronix.de>
We used to loop around the sectors in mci_sd_write/mci_sd_read.
Now that we have multi block read and write this is not necessary
anymore.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mci/mci-core.c | 51 +++++++++++++++++++----------------------------
1 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 58f7f6d..651bcbf 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -988,21 +988,17 @@ static int mci_sd_write(struct device_d *disk_dev, uint64_t sector_start,
return -EINVAL;
}
- while (sector_count) {
- /* size of the block number field in the MMC/SD command is 32 bit only */
- if (sector_start > MAX_BUFFER_NUMBER) {
- pr_debug("Cannot handle block number %llu. Too large!\n",
- sector_start);
- return -EINVAL;
- }
- rc = mci_block_write(mci_dev, buffer, sector_start);
- if (rc != 0) {
- pr_debug("Writing block %u failed with %d\n", (unsigned)sector_start, rc);
- return rc;
- }
- sector_count--;
- buffer += mci->write_bl_len;
- sector_start++;
+ /* size of the block number field in the MMC/SD command is 32 bit only */
+ if (sector_start > MAX_BUFFER_NUMBER) {
+ pr_debug("Cannot handle block number %llu. Too large!\n",
+ sector_start);
+ return -EINVAL;
+ }
+
+ rc = mci_block_write(mci_dev, buffer, sector_start, sector_count);
+ if (rc != 0) {
+ pr_debug("Writing block %u failed with %d\n", (unsigned)sector_start, rc);
+ return rc;
}
return 0;
@@ -1036,21 +1032,16 @@ static int mci_sd_read(struct device_d *disk_dev, uint64_t sector_start,
return -EINVAL;
}
- while (sector_count) {
- int now = min(sector_count, 32U);
- if (sector_start > MAX_BUFFER_NUMBER) {
- pr_err("Cannot handle block number %u. Too large!\n",
- (unsigned)sector_start);
- return -EINVAL;
- }
- rc = mci_read_block(mci_dev, buffer, (unsigned)sector_start, now);
- if (rc != 0) {
- pr_debug("Reading block %u failed with %d\n", (unsigned)sector_start, rc);
- return rc;
- }
- sector_count -= now;
- buffer += mci->read_bl_len * now;
- sector_start += now;
+ if (sector_start > MAX_BUFFER_NUMBER) {
+ pr_err("Cannot handle block number %u. Too large!\n",
+ (unsigned)sector_start);
+ return -EINVAL;
+ }
+
+ rc = mci_read_block(mci_dev, buffer, (unsigned)sector_start, sector_count);
+ if (rc != 0) {
+ pr_debug("Reading block %u failed with %d\n", (unsigned)sector_start, rc);
+ return rc;
}
return 0;
--
1.7.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2011-11-11 11:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 11:38 [PATCH] mci multiblock write Sascha Hauer
2011-11-11 11:38 ` [PATCH 1/2] mci: implement multi block write Sascha Hauer
2011-11-11 11:47 ` Belisko Marek
2011-11-11 11:59 ` Sascha Hauer
2011-11-11 11:38 ` Sascha Hauer [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=1321011494-4274-3-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