From patchwork Sat Apr 16 21:54:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: matt.waddel@linaro.org X-Patchwork-Id: 1052 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:48:38 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs93663qai; Sat, 16 Apr 2011 14:54:55 -0700 (PDT) Received: by 10.236.176.170 with SMTP id b30mr312631yhm.261.1302990895069; Sat, 16 Apr 2011 14:54:55 -0700 (PDT) Received: from mail-gw0-f50.google.com (mail-gw0-f50.google.com [74.125.83.50]) by mx.google.com with ESMTPS id f13si8927681ybi.1.2011.04.16.14.54.53 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Apr 2011 14:54:54 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of matt.waddel@linaro.org) client-ip=74.125.83.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of matt.waddel@linaro.org) smtp.mail=matt.waddel@linaro.org Received: by gwj16 with SMTP id 16so3838500gwj.37 for ; Sat, 16 Apr 2011 14:54:53 -0700 (PDT) Received: by 10.151.18.3 with SMTP id v3mr3640761ybi.169.1302990893625; Sat, 16 Apr 2011 14:54:53 -0700 (PDT) Received: from localhost.localdomain (c-98-202-116-201.hsd1.ut.comcast.net [98.202.116.201]) by mx.google.com with ESMTPS id x37sm3905694ana.34.2011.04.16.14.54.52 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Apr 2011 14:54:53 -0700 (PDT) From: matt.waddel@linaro.org To: u-boot@lists.denx.de Cc: patches@linaro.org, Matt Waddel Subject: [PATCH V4 1/3] MMC: Max blocks value adjustable Date: Sat, 16 Apr 2011 15:54:06 -0600 Message-Id: <1302990848-4225-2-git-send-email-matt.waddel@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1302990848-4225-1-git-send-email-matt.waddel@linaro.org> References: <1299129759-30678-3-git-send-email-matt.waddel@linaro.org> <1302990848-4225-1-git-send-email-matt.waddel@linaro.org> From: Matt Waddel The maximum blocks value was hardcoded to 65535 due to a 16 bit register length. The value can change for different platforms. This patch makes the default the current value of 65535, but it is configurable for other platforms. Signed-off-by: Matt Waddel --- drivers/mmc/mmc.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 6805b33..d69eaa1 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -33,6 +33,11 @@ #include #include +/* Set block count limit because of 16 bit register limit on some hardware*/ +#ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT +#define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535 +#endif + static struct list_head mmc_devices; static int cur_dev_num = -1; @@ -139,11 +144,8 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) return 0; do { - /* - * The 65535 constraint comes from some hardware has - * only 16 bit width block number counter - */ - cur = (blocks_todo > 65535) ? 65535 : blocks_todo; + cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ? + CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo; if(mmc_write_blocks(mmc, start, cur, src) != cur) return 0; blocks_todo -= cur; @@ -215,11 +217,8 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) return 0; do { - /* - * The 65535 constraint comes from some hardware has - * only 16 bit width block number counter - */ - cur = (blocks_todo > 65535) ? 65535 : blocks_todo; + cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ? + CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo; if(mmc_read_blocks(mmc, dst, start, cur) != cur) return 0; blocks_todo -= cur;