Skip to contentSkip to conversation

: common/cmd_flash.c: bug-fix

PATCH New Teh Kok How 3 participants 9 messages Feb 12, 2010 – Feb 22, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : 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) {
#1 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

Quoted 7 lines · 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

Review

Quoted 8 lines
(quoted diff) +1 -0
@@ -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 at denx.de

#2 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

In reply to Teh Kok How

- 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

--- 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) {
#3 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

Review

Quoted 18 lines · 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

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

(quoted diff) +0 -0
@@ -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 at denx.de

#4 lore raw

PATCH 1/1 : common/cmd_flash.c: Fix mtdparts usage in "erase" and "protect"

In reply to Teh Kok How

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.

--- 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) {
#5 lore raw

PATCH 1/1 : common/cmd_flash.c: Fix mtdparts usage in "erase" and "protect"

Dear "Teh Kok How",

Quoted 19 lines · In message <[email protected]> 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.

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

(quoted diff) +1 -0
@@ -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

Review line 335

Quoted 4 lines
(quoted diff) +1 -0
@@ -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?

Review line 364

Quoted 8 lines
(quoted diff) +0 -1
        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

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
Until you walk a mile in another man's moccasins, you  can't  imagine
the smell.
#6 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

In reply to Teh Kok How

Dear "Teh Kok How",

Quoted 14 lines · In message <[email protected]> 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

(quoted diff) +1 -0
@@ -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

Review line 335

Quoted 4 lines
(quoted diff) +1 -0
@@ -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

Signature · 4 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
Why is an average signature file longer than an average Perl script??
#7 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

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 at denx.de]
Sent: Friday, February 12, 2010 11:28 PM
To: Teh Kok How
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH]: common/cmd_flash.c: bug-fix

Dear "Teh Kok How",

Quoted 14 lines · In message <[email protected]> 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

(quoted diff) +1 -0
@@ -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

Review line 335

Quoted 4 lines
(quoted diff) +1 -0
@@ -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

Signature · 4 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
Why is an average signature file longer than an average Perl script??
#8 lore raw

PATCH 1/1 : common/cmd_flash.c: bug-fix

Dear "Teh Kok How",

please do not top-post / full quote.

Quoted 4 lines · In message <[email protected]> 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

Signature · 4 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
It is much easier to suggest solutions when you know nothing