From patchwork Wed Oct 16 13:21:13 2013
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Przemyslaw Marczak
X-Patchwork-Id: 283943
X-Patchwork-Delegate: marek.vasut@gmail.com
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Received: from theia.denx.de (theia.denx.de [85.214.87.163])
by ozlabs.org (Postfix) with ESMTP id AC1BD2C0143
for ;
Thu, 17 Oct 2013 00:22:19 +1100 (EST)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 463674A0D9;
Wed, 16 Oct 2013 15:22:07 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at theia.denx.de
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 TGWgNuUNC1jm; Wed, 16 Oct 2013 15:22:07 +0200 (CEST)
Received: from theia.denx.de (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 493204A0B7;
Wed, 16 Oct 2013 15:21:53 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 061CB4A018
for ; Wed, 16 Oct 2013 15:21:41 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at theia.denx.de
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 CQXgRAtdPBn1 for ;
Wed, 16 Oct 2013 15:21:33 +0200 (CEST)
X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5
BL_NJABL=SKIP(-1.5) (only DNSBL check requested)
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12]) by theia.denx.de (Postfix) with ESMTP id 68C494A066
for ; Wed, 16 Oct 2013 15:21:33 +0200 (CEST)
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout2.w1.samsung.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit
(built Nov
17 2011)) with ESMTP id <0MUR000CQJRPSF90@mailout2.w1.samsung.com>
for u-boot@lists.denx.de; Wed, 16 Oct 2013 14:21:26 +0100 (BST)
X-AuditID: cbfec7f5-b7ef66d00000795a-8c-525e92d5f0b3
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 0B.0C.31066.5D29E525;
Wed, 16 Oct 2013 14:21:25 +0100 (BST)
Received: from AMDC1186.digital.local ([106.116.147.185])
by eusync3.samsung.com
(Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit
(built Aug
10 2011)) with ESMTPA id <0MUR00AYTJRMLP60@eusync3.samsung.com>; Wed,
16 Oct 2013 14:21:25 +0100 (BST)
From: Przemyslaw Marczak
To: u-boot@lists.denx.de
Date: Wed, 16 Oct 2013 15:21:13 +0200
Message-id: <1381929675-26165-4-git-send-email-p.marczak@samsung.com>
X-Mailer: git-send-email 1.7.9.5
In-reply-to: <1381929675-26165-1-git-send-email-p.marczak@samsung.com>
References: <1381929675-26165-1-git-send-email-p.marczak@samsung.com>
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrLJMWRmVeSWpSXmKPExsVy+t/xq7pXJ8UFGVw7bmPx5uFmRos3bY2M
Fjsu32CxeLu3k92BxWPerBMsHmfv7GD06NuyijGAOYrLJiU1J7MstUjfLoEr49Ps7SwF17gq
fj1ewNbA+Jiji5GTQ0LAROL00qdMELaYxIV769m6GLk4hASWMkp8ajnPBOH0MUmcOXaQBaSK
TcBAYs+lM8wgtoiAhMSv/quMIDazQKrEpderWUFsYQFPibVPHoLVsAioSpz7dosdxOYVcJV4
fecpUJwDaJuCxJxJNiBhTgE3iVdXIVqFgErafnxin8DIu4CRYRWjaGppckFxUnqukV5xYm5x
aV66XnJ+7iZGSJB83cG49JjVIUYBDkYlHl6F2NggIdbEsuLK3EOMEhzMSiK8EcFxQUK8KYmV
ValF+fFFpTmpxYcYmTg4pRoY1378LHEvw+TNqssc2WKnO5Q4ZqbFP961+rX3R49bN9T7BF3u
cTzpFvvevz//vMS0vNhmPk52S49oW/0k25CdzsInK7s3NGjaOnVVXG+3/nS6XPt7VIR0C7NP
MLftAt6MJTYTYlsnJQXY9zlqHE5frjPdpSn+mPGbrTzsTDtvb70++VLbjQlKLMUZiYZazEXF
iQCMabjI8AEAAA==
Cc: Marek Vasut , Przemyslaw Marczak
Subject: [U-Boot] [PATCH 3/4] usb: ums: fix bug in partition capacity
computation.
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: U-Boot discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Sender: u-boot-bounces@lists.denx.de
Errors-To: u-boot-bounces@lists.denx.de
Before this change ums disk capacity was miscalculated because
of integer overflow.
Signed-off-by: Przemyslaw Marczak
Cc: Marek Vasut
---
board/samsung/common/ums.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index 1f28590..6c4e6c4 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -37,11 +37,19 @@ static int ums_write_sector(struct ums *ums_dev,
static void ums_get_capacity(struct ums *ums_dev, long long int *capacity)
{
- long long int tmp_capacity;
+ int64_t mmc_capacity = (int64_t)ums_dev->mmc->capacity;
+ int64_t ums_capacity = (int64_t)ums_dev->part_size * SECTOR_SIZE;
+ int64_t ums_offset = (int64_t)ums_dev->offset * SECTOR_SIZE;
- tmp_capacity = (long long int)((ums_dev->offset + ums_dev->part_size)
- * SECTOR_SIZE);
- *capacity = ums_dev->mmc->capacity - tmp_capacity;
+ if (ums_capacity && ((ums_capacity + ums_offset) < mmc_capacity))
+ *capacity = ums_capacity;
+ else
+ *capacity = mmc_capacity - ums_offset;
+
+ printf("UMS: partition capacity: %#llx blocks\n"
+ "UMS: partition start block: %#x\n",
+ *capacity / SECTOR_SIZE,
+ ums_dev->offset);
}
static struct ums ums_dev = {