From patchwork Mon Nov 26 16:13:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 201716 X-Patchwork-Delegate: trini@ti.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 151232C007C for ; Tue, 27 Nov 2012 03:14:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35FDA4A180; Mon, 26 Nov 2012 17:14:09 +0100 (CET) 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 hcalrCFUKBE1; Mon, 26 Nov 2012 17:14:09 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5DE6E4A174; Mon, 26 Nov 2012 17:13:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7FBC4A0AA for ; Mon, 26 Nov 2012 17:13:41 +0100 (CET) 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 F2w30PI1ME+H for ; Mon, 26 Nov 2012 17:13:39 +0100 (CET) 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 mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by theia.denx.de (Postfix) with ESMTP id 3876D4A048 for ; Mon, 26 Nov 2012 17:13:36 +0100 (CET) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ME300KPRRQ1MB30@mailout1.samsung.com> for u-boot@lists.denx.de; Tue, 27 Nov 2012 01:13:32 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-24-50b3952b3d1d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D1.0A.01231.B2593B05; Tue, 27 Nov 2012 01:13:31 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ME3006XERQ80PA0@mmp1.samsung.com> for u-boot@lists.denx.de; Tue, 27 Nov 2012 01:13:31 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Mon, 26 Nov 2012 17:13:14 +0100 Message-id: <1353946397-26429-2-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1353946397-26429-1-git-send-email-l.majewski@samsung.com> References: <1353946397-26429-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAV2dqZsDDP4wWbzd28nuwOhx9s4O xgDGKC6blNSczLLUIn27BK6M/7vnsBTs4qmYcHI3UwPjKq4uRk4OCQETif3vZ7BD2GISF+6t Z+ti5OIQEljEKPGnYQc7hLOYSeJ35302kCo2AT2Jz3efMoHYIgISEr/6rzKCFDELTGWSWDTx HwtIQlggUuL+tMdgY1kEVCXWv5jICGLzCrhJPJ64jA1inbzE0/t9YDangLtE76YFYPVCQDUf v2xknMDIu4CRYRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGsNefSe1gXNlgcYhRgINRiYe3 8MSmACHWxLLiytxDjBIczEoivN8bNwcI8aYkVlalFuXHF5XmpBYfYpTmYFES5232SAkQEkhP LEnNTk0tSC2CyTJxcEo1MGZlBS2cm755/edyD3m9o9d1o70SV2asFmZnn5eot8oz1t056aC9 0YuTtp6PmqPCn+YHmF22beFc9dvRhnHaKfG30+wtRS4mrmaZ0ajdvDHeO/nB9VlTU57tXHr3 yMkX296UTawqLLpyLfv+pFCDqcFCk9hknqqEfbZ9az9l72mFN99eL/pyeZMSS3FGoqEWc1Fx IgC4kCik9gEAAA== Cc: "pintu.k@samsung.com" , Kyungmin Park , IQBAL SHAREEF , Tom Rini Subject: [U-Boot] [PATCH 1/4] fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division 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 The ext4write code has been using direct calls to 64-32 division (/ and %). Officially supported u-boot toolchains (eldk-5.[12].x) generate calls to __aeabi_uldivmod(), which is niether defined in the toolchain libs nor u-boot source tree. Due to that, when the ext4write command has been executed, "undefined instruction" execption was generated (since the __aeabi_uldivmod() is not provided). To fix this error, lldiv() for division and do_div() for modulo have been used. Those two functions are recommended for performing 64-32 bit number division in u-boot. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park --- fs/ext4/ext4fs.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 06536ba..80b3b90 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "ext4_common.h" int ext4fs_symlinknest; @@ -1051,8 +1052,8 @@ int ext4fs_write(const char *fname, unsigned char *buffer, } /* calucalate how many blocks required */ bytes_reqd_for_file = sizebytes; - blks_reqd_for_file = bytes_reqd_for_file / fs->blksz; - if (bytes_reqd_for_file % fs->blksz != 0) { + blks_reqd_for_file = lldiv(bytes_reqd_for_file, fs->blksz); + if (do_div(bytes_reqd_for_file, fs->blksz) != 0) { blks_reqd_for_file++; debug("total bytes for a file %u\n", blks_reqd_for_file); }