From patchwork Thu Oct 28 17:15:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Sakoman X-Patchwork-Id: 71954 Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id E91F6152451 for ; Thu, 28 Oct 2010 19:16:10 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id CD4BC3364F8D for ; Thu, 28 Oct 2010 19:16:10 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Thu, 28 Oct 2010 19:16:10 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Thu, 28 Oct 2010 19:15:30 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Thu, 28 Oct 2010 19:15:30 +0200 Received: from scanner-2.m-online.net (scanner-2.mail.m-online.net [192.168.8.166]) by mail.m-online.net (Postfix) with ESMTP id 1CD321C002ED; Thu, 28 Oct 2010 19:15:30 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id D77F046C0C8; Thu, 28 Oct 2010 19:15:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 212C7280EC; Thu, 28 Oct 2010 19:15:22 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JUdfF0luINNz; Thu, 28 Oct 2010 19:15:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 23F19280F5; Thu, 28 Oct 2010 19:15:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1729F280E6 for ; Thu, 28 Oct 2010 19:15:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9tMiiUKUMq9T for ; Thu, 28 Oct 2010 19:15:11 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-gx0-f172.google.com (mail-gx0-f172.google.com [209.85.161.172]) by theia.denx.de (Postfix) with ESMTP id 05938280E0 for ; Thu, 28 Oct 2010 19:15:09 +0200 (CEST) Received: by gxk7 with SMTP id 7so1446549gxk.3 for ; Thu, 28 Oct 2010 10:15:08 -0700 (PDT) Received: by 10.150.147.3 with SMTP id u3mr4761056ybd.234.1288286108469; Thu, 28 Oct 2010 10:15:08 -0700 (PDT) Received: from [192.168.0.210] (static-74-41-60-154.dsl1.pco.ca.frontiernet.net [74.41.60.154]) by mx.google.com with ESMTPS id q18sm6019103ybk.3.2010.10.28.10.15.05 (version=SSLv3 cipher=RC4-MD5); Thu, 28 Oct 2010 10:15:07 -0700 (PDT) From: Steve Sakoman To: Lei Wen , "u-boot@lists.denx.de" Date: Thu, 28 Oct 2010 10:15:03 -0700 Message-ID: <1288286103.2342.255.camel@quadra> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Cc: Andy Fleming , John Rigby Subject: [U-Boot] [PATCH RFC] mmc: Clean up generic mmc driver multi-block write functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net 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 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;