Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
Subsystems (2)
PATCH 1/1 Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
Sometimes, board module needs to know some information about the NAND chip e.g. page size to continue it's initialization. This short patch give board module a chance to continue its initialization after the NAND chip is scaned.
best regards,
drivers/mtd/nand/nand.c +4 -0
@@ -41,6 +41,10 @@ static const char default_nand_name[] = "nand";extern int board_nand_init (struct nand_chip *nand); +int __board_nand_init_tail (struct nand_chip *nand) {return 0 ; } +int inline board_nand_init_tail (struct nand_chip *) __attribute__ + ((weak,alias ("__board_nand_init_tail" ))); +static void nand_init_chip (struct mtd_info *mtd,struct nand_chip *nand,ulong base_addr) {
@@ -48,7 +52,7 @@ static void nand_init_chip(struct mtd_info *mtd,
struct nand_chip *nand,
nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr; if (board_nand_init(nand) == 0) {
- if (nand_scan(mtd, 1) == 0) {
+ if ((nand_scan(mtd, 1) == 0) && (board_nand_init_tail(nand) == 0)) {
if (!mtd->name)
mtd->name = (char *)default_nand_name;
} else
PATCH 1/1 Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
drivers/mtd/nand/nand.c
Quoted 9 lines · Hong Xu
Sometimes, board module needs to know some information about the NAND chip e.g. page size to continue it's initialization. This short patch give board module a chance to continue its initialization after the NAND chip is scaned.
best regards,
drivers/mtd/nand/nand.c +0
-0
* You need a "Signed-off-by" line
* Typo s/scaned/scanned/ (both in the subject and the comment)
* The "best regards," line should be deleted from the comment.
Thanks,
gvb
PATCH 1/1 Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
In reply to Hong Xudrivers/mtd/nand/nand.c static const char default_nand_name[] = "nand"; · line 47
Quoted 13 lines · In message <[email protected]> you…
drivers/mtd/nand/nand.c +4
-0@@ -41,6 +41,10 @@ static const char default_nand_name[] = "nand";extern int board_nand_init (struct nand_chip *nand); +int __board_nand_init_tail (struct nand_chip *nand) {return 0 ; } +int inline board_nand_init_tail (struct nand_chip *) __attribute__ + ((weak,alias ("__board_nand_init_tail" ))); +
I don't like the "_tail" name. Maybe board_nand_init2() or so would be better?
Quoted 12 lines
drivers/mtd/nand/nand.c +1
-1static void nand_init_chip (struct mtd_info *mtd,struct nand_chip *nand,ulong base_addr) {@@ -48,7 +52,7 @@ static void nand_init_chip(struct mtd_info *mtd,struct nand_chip *nand, nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;if (board_nand_init (nand) ==0 ) { -if (nand_scan (mtd,1 ) ==0 ) { +if ((nand_scan (mtd,1 ) ==0 ) && (board_nand_init_tail (nand) ==0 )) {if (!mtd->name) mtd->name = (char *)default_nand_name;
Quoted 1 line
} else
The logic is becoming pretty intricate. Maybe you can rewrite this to be more readable?
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 The rule on staying alive as a program manager is to give 'em a num- ber or give 'em a date, but never give 'em both at once.
PATCH 1/1 Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
In reply to Hong Xudrivers/mtd/nand/nand.c static const char default_nand_name[] = "nand"; · line 46
Quoted 3 lines · Hong Xu
drivers/mtd/nand/nand.c +3
-0+int __board_nand_init_tail (struct nand_chip *nand) {return 0 ; } +int inline board_nand_init_tail (struct nand_chip *) __attribute__ + ((weak,alias ("__board_nand_init_tail" )));
A globally visible inline weak alias. How does that work?
Haavard
PATCH 1/1 Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
In reply to Hong XuQuoted 4 lines · Hong Xu
Sometimes, board module needs to know some information about the NAND chip e.g. page size to continue it's initialization. This short patch give board module a chance to continue its initialization after the NAND chip is scaned.
[snip]
Review
Quoted 7 lines
(quoted diff) +1
-1nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr; if (board_nand_init(nand) == 0) { - if (nand_scan(mtd, 1) == 0) { + if ((nand_scan(mtd, 1) == 0) && (board_nand_init_tail(nand) == 0)) { if (!mtd->name) mtd->name = (char *)default_nand_name; } else
This doesn't give the board driver a chance to run before the bad block scan, though. The MTD code itself does (nand_scan_ident and nand_scan_tail, around which nand_scan is a wrapper), but the u-boot glue code doesn't currently let board drivers take advantage of that.
I'd like to transition away from having a centralized nand_init(), and instead have the board drivers call nand_scan*() themselves.
-Scott