Re: [U-Boot] [PATCH 2/4] cmd_mtdparts: use 64 bits for flash size, partition size offset

2013-10-15 Thread York Sun
On 09/04/2013 07:16 AM, Paul Burton wrote:
 This matches the 64 bit size in struct mtd_info and allows the mtdparts
 command to function correctly with a flash = 4GiB. Format specifiers
 for size  offset are given the ll length, matching its use in
 drivers/mtd in absence of something like inttypes.h/PRIx64.
 
 Signed-off-by: Paul Burton paul.bur...@imgtec.com
 ---
  common/cmd_mtdparts.c   | 54 
 -
  include/jffs2/load_kernel.h |  6 ++---
  2 files changed, 32 insertions(+), 28 deletions(-)

I need some help. This patch makes compiling warning for the following
targets

mgcoge kmsupx5 suvd3 mgcoge3ne kmopti2 tuge1 kmvect1 kmcoge5ne pdm360ng
kmeter1 tuxx1

cramfs.c: In function 'cramfs_read_super':
cramfs.c:56:18: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c:61:19: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c: In function 'cramfs_list_inode':
cramfs.c:211:31: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c: In function 'cramfs_ls':
cramfs.c:281:11: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c:294:11: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c: In function 'cramfs_check':
cramfs.c:339:7: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
cramfs.c:342:8: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]

Can you fix them?

York


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/4] cmd_mtdparts: use 64 bits for flash size, partition size offset

2013-09-04 Thread Paul Burton
This matches the 64 bit size in struct mtd_info and allows the mtdparts
command to function correctly with a flash = 4GiB. Format specifiers
for size  offset are given the ll length, matching its use in
drivers/mtd in absence of something like inttypes.h/PRIx64.

Signed-off-by: Paul Burton paul.bur...@imgtec.com
---
 common/cmd_mtdparts.c   | 54 -
 include/jffs2/load_kernel.h |  6 ++---
 2 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 3023479..453ed57 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -93,13 +93,13 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* special size referring to all the remaining space in a partition */
-#define SIZE_REMAINING 0x
+#define SIZE_REMAINING (~0llu)
 
 /* special offset value, it is used when not provided by user
  *
  * this value is used temporarily during parsing, later such offests
  * are recalculated */
-#define OFFSET_NOT_SPECIFIED   0x
+#define OFFSET_NOT_SPECIFIED   (~0llu)
 
 /* minimum partition size */
 #define MIN_PART_SIZE  4096
@@ -160,9 +160,9 @@ static int device_del(struct mtd_device *dev);
  * @param retptr output pointer to next char after parse completes (output)
  * @return resulting unsigned int
  */
-static unsigned long memsize_parse (const char *const ptr, const char **retptr)
+static u64 memsize_parse (const char *const ptr, const char **retptr)
 {
-   unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0);
+   u64 ret = simple_strtoull(ptr, (char **)retptr, 0);
 
switch (**retptr) {
case 'G':
@@ -193,20 +193,20 @@ static unsigned long memsize_parse (const char *const 
ptr, const char **retptr)
  * @param buf output buffer
  * @param size size to be converted to string
  */
-static void memsize_format(char *buf, u32 size)
+static void memsize_format(char *buf, u64 size)
 {
 #define SIZE_GB ((u32)1024*1024*1024)
 #define SIZE_MB ((u32)1024*1024)
 #define SIZE_KB ((u32)1024)
 
if ((size % SIZE_GB) == 0)
-   sprintf(buf, %ug, size/SIZE_GB);
+   sprintf(buf, %llug, size/SIZE_GB);
else if ((size % SIZE_MB) == 0)
-   sprintf(buf, %um, size/SIZE_MB);
+   sprintf(buf, %llum, size/SIZE_MB);
else if (size % SIZE_KB == 0)
-   sprintf(buf, %uk, size/SIZE_KB);
+   sprintf(buf, %lluk, size/SIZE_KB);
else
-   sprintf(buf, %u, size);
+   sprintf(buf, %llu, size);
 }
 
 /**
@@ -310,6 +310,7 @@ static int part_validate_eraseblock(struct mtdids *id, 
struct part_info *part)
struct mtd_info *mtd = NULL;
int i, j;
ulong start;
+   u64 offset, size;
 
if (get_mtd_info(id-type, id-num, mtd))
return 1;
@@ -321,14 +322,16 @@ static int part_validate_eraseblock(struct mtdids *id, 
struct part_info *part)
 * Only one eraseregion (NAND, OneNAND or uniform NOR),
 * checking for alignment is easy here
 */
-   if ((unsigned long)part-offset % mtd-erasesize) {
+   offset = part-offset;
+   if (do_div(offset, mtd-erasesize)) {
printf(%s%d: partition (%s) start offset
   alignment incorrect\n,
   MTD_DEV_TYPE(id-type), id-num, part-name);
return 1;
}
 
-   if (part-size % mtd-erasesize) {
+   size = part-size;
+   if (do_div(size, mtd-erasesize)) {
printf(%s%d: partition (%s) size alignment 
incorrect\n,
   MTD_DEV_TYPE(id-type), id-num, part-name);
return 1;
@@ -396,7 +399,7 @@ static int part_validate(struct mtdids *id, struct 
part_info *part)
part-size = id-size - part-offset;
 
if (part-offset  id-size) {
-   printf(%s: offset %08x beyond flash size %08x\n,
+   printf(%s: offset %08llx beyond flash size %08llx\n,
id-mtd_id, part-offset, id-size);
return 1;
}
@@ -579,8 +582,8 @@ static int part_add(struct mtd_device *dev, struct 
part_info *part)
 static int part_parse(const char *const partdef, const char **ret, struct 
part_info **retpart)
 {
struct part_info *part;
-   unsigned long size;
-   unsigned long offset;
+   u64 size;
+   u64 offset;
const char *name;
int name_len;
unsigned int mask_flags;
@@ -599,7 +602,7 @@ static int part_parse(const char *const partdef, const char 
**ret, struct part_i
} else {
size = memsize_parse(p, p);
if (size  MIN_PART_SIZE) {
-   printf(partition size too small (%lx)\n, size);
+   printf(partition size too small (%llx)\n,