aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorƁukasz Majewski2012-12-05 02:06:37 -0600
committerTom Rini2012-12-07 09:47:52 -0600
commit32fc16d7e7a81816ce247b7cd70c94f3210a228b (patch)
tree78b4f9231a15b7b441d0978d348e06b15199ade3 /fs
parent3fdf7596dff87a79e2b41d07479c608d91d06cb3 (diff)
downloadu-boot-32fc16d7e7a81816ce247b7cd70c94f3210a228b.tar.gz
u-boot-32fc16d7e7a81816ce247b7cd70c94f3210a228b.tar.xz
u-boot-32fc16d7e7a81816ce247b7cd70c94f3210a228b.zip
fs:ext4:write: Add lldiv and do_div to perform 64-32 bits division
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 <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4fs.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 06536baf62..80b3b90907 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -40,6 +40,7 @@
40#include <linux/stat.h> 40#include <linux/stat.h>
41#include <linux/time.h> 41#include <linux/time.h>
42#include <asm/byteorder.h> 42#include <asm/byteorder.h>
43#include <div64.h>
43#include "ext4_common.h" 44#include "ext4_common.h"
44 45
45int ext4fs_symlinknest; 46int ext4fs_symlinknest;
@@ -1051,8 +1052,8 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
1051 } 1052 }
1052 /* calucalate how many blocks required */ 1053 /* calucalate how many blocks required */
1053 bytes_reqd_for_file = sizebytes; 1054 bytes_reqd_for_file = sizebytes;
1054 blks_reqd_for_file = bytes_reqd_for_file / fs->blksz; 1055 blks_reqd_for_file = lldiv(bytes_reqd_for_file, fs->blksz);
1055 if (bytes_reqd_for_file % fs->blksz != 0) { 1056 if (do_div(bytes_reqd_for_file, fs->blksz) != 0) {
1056 blks_reqd_for_file++; 1057 blks_reqd_for_file++;
1057 debug("total bytes for a file %u\n", blks_reqd_for_file); 1058 debug("total bytes for a file %u\n", blks_reqd_for_file);
1058 } 1059 }