[U-Boot] [PATCH]: common/cmd_flash.c: bug-fix

Teh Kok How khteh at smartbridges.com
Fri Feb 12 10:16:36 CET 2010


- What exactly are you trying to fix? Please add a small description
  on what's broken and how your patch fixes it.
=> Fixes wrong argument to mtd_id_parse that affects u-boot command `erase`
and `protect` <part-id>. This fix passes the correct part-id to the commands
so that `erase rootfs` and `protect rootfs` work.

- Patch adds empty line after each line
- Patch is line wrapped
=> Hope it's better this time as I am sure I use "Plain Text" in my email
body.
- Signed-off-by line missing

Signed-off-by: Kok How, Teh <k_h_teh at yahoo.com>
--- u-boot-2009.11.1.orig/common/cmd_flash.c    2010-01-25
16:35:12.000000000 +0800
+++ u-boot-2009.11.1.new/common/cmd_flash.c     2010-02-12
16:18:10.565540182 +0800
@@ -43,6 +43,7 @@

 #ifndef CONFIG_SYS_NO_FLASH
 extern flash_info_t flash_info[];      /* info for FLASH chips */
+extern struct mtd_device *current_mtd_dev;

 /*
  * The user interface starts numbering for Flash banks with 1
@@ -331,6 +332,7 @@
        u8 dev_type, dev_num, pnum;
 #endif
        int rcode = 0;
+       char mtd_dev[10];

        if (argc < 2) {
                cmd_usage(cmdtp);
@@ -359,7 +361,8 @@

 #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        /* erase <part-id> - erase partition */
-       if ((argc == 2) && (mtd_id_parse(argv[1], NULL, &dev_type, &dev_num)
== 0)) {
+        sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(current_mtd_dev->id->type),
current_mtd_dev->id->num);
+       if ((argc == 2) && (mtd_id_parse(mtd_dev, NULL, &dev_type, &dev_num)
== 0)) {
                mtdparts_init();
                if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) {
                        if (dev->id->type == MTD_DEV_TYPE_NOR) {
@@ -481,6 +484,7 @@
 #endif
        int p;
        int rcode = 0;
+       char mtd_dev[10];

        if (argc < 3) {
                cmd_usage(cmdtp);
@@ -567,7 +571,8 @@

 #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        /* protect on/off <part-id> */
-       if ((argc == 3) && (mtd_id_parse(argv[2], NULL, &dev_type, &dev_num)
== 0)) {
+        sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(current_mtd_dev->id->type),
current_mtd_dev->id->num);
+       if ((argc == 3) && (mtd_id_parse(mtd_dev, NULL, &dev_type, &dev_num)
== 0)) {
                mtdparts_init();
                if (find_dev_and_part(argv[2], &dev, &pnum, &part) == 0) {
                        if (dev->id->type == MTD_DEV_TYPE_NOR) {




More information about the U-Boot mailing list