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

--- 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) {

On Friday 12 February 2010 09:31:17 Teh Kok How wrote:
--- 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;
Sorry, but your patch has several problems:
- What exactly are you trying to fix? Please add a small description on what's broken and how your patch fixes it. - Patch adds empty line after each line - Patch is line wrapped - Signed-off-by line missing
Please see here for more details on creating and sending patches:
http://www.denx.de/wiki/view/U-Boot/Patches
Thanks.
Cheers, Stefan
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

- 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@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) {

On Friday 12 February 2010 10:16:36 Teh Kok How wrote:
- 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@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 @@
Thanks. But your patch is still line wrapped. Please take a look a this page on how to send patches:
http://kerneltrap.org/Linux/Email_Clients_and_Patches
And please remove my comments from the commit text. It should look like this:
" 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. "
And please add a small description to the email subject. Something like:
cmd_flash: Fix mtdparts usage in "erase" and "protect"
Thanks.
Cheers, Stefan
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

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.
Signed-off-by: Kok How, Teh k_h_teh@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) {

Dear "Teh Kok How",
In message 9BAE6A5E771E47C99977F5057F7B300A@smartbridges.com you wrote:
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.
Signed-off-by: Kok How, Teh k_h_teh@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];
I already asked: wher eis this magic constant coming from?
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)) {
This is still line wrapped.
Please read http://kerneltrap.org/Linux/Email_Clients_and_Patches and fix your mailer configuration before reposting.
Also, consider using git-format-patch to create the patch, and using git-send-email to send it.
Best regards,
Wolfgang Denk

Dear "Teh Kok How",
In message 89D4E2CB6B654B3FB0DA6A0CE6650515@smartbridges.com you wrote:
--- 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];
Where is this magic constant 10 coming from?
Best regards,
Wolfgang Denk

Hi Wolfgang; Sorry, been away for 1 week. The constant 10 is the size of an array that is arbitrarily chosen so that it is big enough to hold the current mtd device identifier such as nor0, nor1, nor2, nand0, nand1, nand2, etc.
Regards, KH
-----Original Message----- From: Wolfgang Denk [mailto:wd@denx.de] Sent: Friday, February 12, 2010 11:28 PM To: Teh Kok How Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH]: common/cmd_flash.c: bug-fix
Dear "Teh Kok How",
In message 89D4E2CB6B654B3FB0DA6A0CE6650515@smartbridges.com you wrote:
--- 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];
Where is this magic constant 10 coming from?
Best regards,
Wolfgang Denk

Dear "Teh Kok How",
please do not top-post / full quote.
In message 8F43DBAAFE554067877FD8568CAB4FDC@smartbridges.com you wrote:
Sorry, been away for 1 week. The constant 10 is the size of an array that is arbitrarily chosen so that it is big enough to hold the current mtd device identifier such as nor0, nor1, nor2, nand0, nand1, nand2, etc.
Such random limitations have never been a good idea. This should be fixed.
Best regards,
Wolfgang Denk
participants (3)
-
Stefan Roese
-
Teh Kok How
-
Wolfgang Denk