common: usd do_div to divide 64bit value
authorChanho Park <chanho61.park@samsung.com>
Fri, 3 Jul 2015 04:48:51 +0000 (13:48 +0900)
committerChanho Park <chanho61.park@samsung.com>
Fri, 24 Jul 2015 07:30:14 +0000 (16:30 +0900)
When we use the recent gcc compiler with armhf, it causes build errors
related with VFP registers. Thus, we should use do_div in case of 64bits
divisions.

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
common/cmd_mmc.c
common/cmd_mmc_fdisk.c
common/decompress_ext4.c

index 888e3c9795bf137a811f70209bcd6800822eb960..dad6de8422edd12f4f67bb15fa700e0f55ed7b45 100644 (file)
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <mmc.h>
+#include <div64.h>
 
 static int curr_device = -1;
 #ifndef CONFIG_GENERIC_MMC
@@ -324,10 +325,12 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        } else if (strcmp(argv[2], "user") == 0) {
                                part = 1;
                                /* Read User partition size. */
-                               count = mmc->capacity / mmc->read_bl_len;
+                               count = do_div(mmc->capacity,
+                                               mmc->read_bl_len);
                        } else {
                                part = 1;
-                               count = mmc->capacity / mmc->read_bl_len;
+                               count = do_div(mmc->capacity,
+                                               mmc->read_bl_len);
                                printf("Default erase user partition\n");
                        }
 
index a37a817b5b2b713d960cf6da772eef39bfdde27f..58701e4fa4f01708949158b4535e4e712f53cf33 100644 (file)
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <command.h>
 #include <mmc.h>
+#include <div64.h>
 
 #define                BLOCK_SIZE                      512
 #define                BLOCK_END                       0xFFFFFFFF
@@ -64,9 +65,10 @@ typedef struct
 int calc_unit(unsigned long long length, SDInfo sdInfo)
 {
        if (sdInfo.addr_mode == CHS_MODE)
-               return ( (length / BLOCK_SIZE / sdInfo.unit + 1 ) * sdInfo.unit);
+               return ( (do_div(length, (BLOCK_SIZE / sdInfo.unit)) + 1 )
+                               * sdInfo.unit);
        else
-               return ( (length / BLOCK_SIZE) );
+               return ( (do_div(length, BLOCK_SIZE)) );
 }
 
 /////////////////////////////////////////////////////////////////
@@ -313,7 +315,7 @@ int get_mmc_block_count(char *device_name)
                return -1;
        }
 
-       block_count = mmc->capacity / mmc->read_bl_len;
+       block_count = do_div(mmc->capacity, mmc->read_bl_len);
 
 //     printf("block_count = %d\n", block_count);
        return block_count;
index 12c75aa49199911dd6f37e35ba496ac523f96781..9c1fa183bb8643c15ff07241a29699b404a76a20 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/errno.h>
 #include <decompress_ext4.h>
 #include <mmc.h>
+#include <div64.h>
 
 #define SECTOR_BITS            9       /* 512B */
 
@@ -57,8 +58,9 @@ int check_compress_ext4(char *img_base, unsigned long long parti_size) {
 
        if ((parti_size/file_header->block_size)  < file_header->total_blocks) {
                printf("Invalid Volume Size! Image is bigger than partition size!\n");
-               printf("partion size %lld , image size %d \n",
-                       (parti_size/file_header->block_size), file_header->total_blocks);
+               printf("partion size %ld , image size %d \n",
+                       (do_div(parti_size, file_header->block_size)),
+                       file_header->total_blocks);
                while(1);
        }