public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH RFC] mmc: Clean up generic mmc driver multi-block write functions
Date: Thu, 28 Oct 2010 10:15:03 -0700	[thread overview]
Message-ID: <1288286103.2342.255.camel@quadra> (raw)

The current mmc write implementation is type ulong, but returns int values.
Some of the printf's are terminated with /n/r, one has none.

This patch fixes these issues and also removes some unnecessary local
variables.

Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org>
---

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index eb7bfb3..00fe867 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -82,12 +82,9 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
-	int blklen, err;
-
-	blklen = mmc->write_bl_len;
 
 	if ((start + blkcnt) > mmc->block_dev.lba) {
-		printf("MMC: block number 0x%lx exceeds max(0x%lx)",
+		printf("MMC: block number 0x%lx exceeds max(0x%lx)\n",
 			start + blkcnt, mmc->block_dev.lba);
 		return 0;
 	}
@@ -100,21 +97,19 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 	if (mmc->high_capacity)
 		cmd.cmdarg = start;
 	else
-		cmd.cmdarg = start * blklen;
+		cmd.cmdarg = start * mmc->write_bl_len;
 
 	cmd.resp_type = MMC_RSP_R1;
 	cmd.flags = 0;
 
 	data.src = src;
 	data.blocks = blkcnt;
-	data.blocksize = blklen;
+	data.blocksize = mmc->write_bl_len;
 	data.flags = MMC_DATA_WRITE;
 
-	err = mmc_send_cmd(mmc, &cmd, &data);
-
-	if (err) {
-		printf("mmc write failed\n\r");
-		return err;
+	if (mmc_send_cmd(mmc, &cmd, &data)) {
+		printf("mmc write failed\n");
+		return 0;
 	}
 
 	if (blkcnt > 1) {
@@ -122,10 +117,9 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 		cmd.cmdarg = 0;
 		cmd.resp_type = MMC_RSP_R1b;
 		cmd.flags = 0;
-		err = mmc_send_cmd(mmc, &cmd, NULL);
-		if (err) {
-			printf("mmc fail to send stop cmd\n\r");
-			return err;
+		if (mmc_send_cmd(mmc, &cmd, NULL)) {
+			printf("mmc fail to send stop cmd\n");
+			return 0;
 		}
 	}
 
@@ -135,18 +129,14 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 static ulong
 mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 {
-	int err;
-	struct mmc *mmc = find_mmc_device(dev_num);
 	lbaint_t cur, blocks_todo = blkcnt;
 
+	struct mmc *mmc = find_mmc_device(dev_num);
 	if (!mmc)
-		return -1;
+		return 0;
 
-	err = mmc_set_blocklen(mmc, mmc->write_bl_len);
-	if (err) {
-		printf("set write bl len failed\n\r");
-		return err;
-	}
+	if (mmc_set_blocklen(mmc, mmc->write_bl_len))
+		return 0;
 
 	do {
 		/*
@@ -155,7 +145,7 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 		 */
 		cur = (blocks_todo > 65535) ? 65535 : blocks_todo;
 		if(mmc_write_blocks(mmc, start, cur, src) != cur)
-			return -1;
+			return 0;
 		blocks_todo -= cur;
 		start += cur;
 		src += cur * mmc->write_bl_len;

                 reply	other threads:[~2010-10-28 17:15 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=1288286103.2342.255.camel@quadra \
    --to=steve@sakoman.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