Skip to contentSkip to conversation

update nand.h to support address more than 0x80000000

PATCH New adrian wen 3 participants 5 messages Jun 2, 2009 – Jul 27, 2009

lore
Share & tools
lore

adrian wen

author
#0 lore raw

PATCH 1/1 update nand.h to support address more than 0x80000000

Hi all,

I found a bug in nand.h which prevent UBOOT to supprt large NAND chip.

The bug description as below:
In the original implementation, we use a wrapper function in nand.h to facilitate nand_base function usage in other files, like cmd_nand.c, nand_util.c etc.

However, the wrapper in nand.h is using off_t which is long type. If we pass a address like 0x80000000, which is allowed by nand_base.c, the wrapper would recognize it as a negative num. So we would get a huge num when this parameter get into nand_base.c

Fix it by replacing off_t to loff_t type.

---
 include/nand.h |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
include/nand.h +0 -1
index 230aa62..293d481 100644
@@ -36,28 +36,28 @@ typedef struct mtd_info nand_info_t;
 extern int nand_curr_device;
 extern nand_info_t nand_info[];
 
-static inline int nand_read(nand_info_t *info, off_t ofs, size_t *len,

u_char *buf)
+static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)

 {
        return info->read(info, ofs, *len, (size_t *)len, buf);

}

-static inline int nand_write(nand_info_t *info, off_t ofs, size_t *len, u_char *buf)
+static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)

 {
        return info->write(info, ofs, *len, (size_t *)len, buf);

}

-static inline int nand_write_oob(nand_info_t *info, off_t ofs, +static inline int nand_write_oob(nand_info_t *info, loff_t ofs,
struct mtd_oob_ops *ops)

 {
        return info->write_oob(info, ofs, ops);

}

-static inline int nand_block_isbad(nand_info_t *info, off_t ofs) +static inline int nand_block_isbad(nand_info_t *info, loff_t ofs)

 {
        return info->block_isbad(info, ofs);

}

-static inline int nand_erase(nand_info_t *info, off_t off, size_t size) +static inline int nand_erase(nand_info_t *info, loff_t off, size_t size)
{

#1 lore raw

PATCH 1/1 update nand.h to support address more than 0x80000000

Quoted 9 lines · adrian wen

Hi all,

I found a bug in nand.h which prevent UBOOT to supprt large NAND chip.

The bug description as below:
In the original implementation, we use a wrapper function in nand.h to facilitate nand_base function usage in other files, like cmd_nand.c, nand_util.c etc.

Quoted 8 lines

However, the wrapper in nand.h is using off_t which is long type. If we pass a address like 0x80000000, which is allowed by nand_base.c, the wrapper would recognize it as a negative num. So we would get a huge num when this parameter get into nand_base.c

Fix it by replacing off_t to loff_t type.

A substantially similar patch was posted here:
http://lists.denx.de/pipermail/u-boot/2009-May/052847.html

I'm fine with this change, but it should also handle large erases.

-Scott

author
#2 lore raw

PATCH 1/1 update nand.h to support address more than 0x80000000

2009/6/3 Scott Wood <[email protected]>

Quoted 18 lines · adrian wen
Quoted 16 lines

Hi all,

I found a bug in nand.h which prevent UBOOT to supprt large NAND chip.

The bug description as below:
In the original implementation, we use a wrapper function in nand.h to facilitate nand_base function usage in other files, like cmd_nand.c, nand_util.c etc.

However, the wrapper in nand.h is using off_t which is long type. If we pass a address like 0x80000000, which is allowed by nand_base.c, the wrapper would recognize it as a negative num. So we would get a huge num when this parameter get into nand_base.c

Fix it by replacing off_t to loff_t type.

Quoted 8 lines
Quoted 1 line

A substantially similar patch was posted here:
http://lists.denx.de/pipermail/u-boot/2009-May/052847.html

I'm fine with this change, but it should also handle large erases.

-Scott

I don't quitly catch the meaning. Do you mean that uboot erases begin with large address or large length?

This patch only solve the wrapper bug.
For the nand_block_isbad as a example, this function defined in nand.h as:
static inline int nand_block_isbad(nand_info_t *info, off_t ofs)

{
        return info->block_isbad(info, ofs);
}

However, in nand_base.c, we define this function as:
static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)

Also, in nand_util.c, it use a lot of nand_block_markbad, which is the one _defined_ in nand.h. So the problem comes that when we pass a address greater than 0x80000000, the off_t type would recognize it as a negative number, while loff_t recognize it valid.

When this _0x80000000_ pass to the nand_block_markbad in nand_base.c, it would be recognized as 0xffffffff80000000, which is caused by the wrapper in nand.h.

-Adrian

#3 lore raw

PATCH 1/1 update nand.h to support address more than 0x80000000

In reply to Scott Wood

Dear Scott Wood,

Quoted 15 lines · In message <[email protected]> you wrote:
Quoted 14 lines · adrian wen

Hi all,

I found a bug in nand.h which prevent UBOOT to supprt large NAND chip.

The bug description as below:
In the original implementation, we use a wrapper function in nand.h to facilitate nand_base function usage in other files, like cmd_nand.c, nand_util.c etc.

However, the wrapper in nand.h is using off_t which is long type. If we pass a address like 0x80000000, which is allowed by nand_base.c, the wrapper would recognize it as a negative num. So we would get a huge num when this parameter get into nand_base.c

Quoted 8 lines
Quoted 3 lines

Fix it by replacing off_t to loff_t type.

A substantially similar patch was posted here:
http://lists.denx.de/pipermail/u-boot/2009-May/052847.html

I'm fine with this change, but it should also handle large erases.

What happened out of this? I see a question asked by Adrian, but I cannot find a reply from you?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"May the forces of evil become confused on the way to your house."
- George Carlin
#4 lore raw

PATCH 1/1 update nand.h to support address more than 0x80000000

Quoted 22 lines · Wolfgang Denk

Dear Scott Wood,

Quoted 19 lines · In message <[email protected]> you wrote:
Quoted 17 lines · adrian wen

Hi all,

I found a bug in nand.h which prevent UBOOT to supprt large NAND chip.

The bug description as below:
In the original implementation, we use a wrapper function in nand.h to facilitate nand_base function usage in other files, like cmd_nand.c, nand_util.c etc.

However, the wrapper in nand.h is using off_t which is long type. If we pass a address like 0x80000000, which is allowed by nand_base.c, the wrapper would recognize it as a negative num. So we would get a huge num when this parameter get into nand_base.c

Fix it by replacing off_t to loff_t type.

Quoted 7 lines
Quoted 4 lines

A substantially similar patch was posted here:
http://lists.denx.de/pipermail/u-boot/2009-May/052847.html

I'm fine with this change, but it should also handle large erases.

What happened out of this? I see a question asked by Adrian, but I cannot find a reply from you?

The previous patch (linked above) was applied. Large erase is still to be done.

-Scott