UBI/cfi-mtd: Fix mtd name for multiple chips
PATCH 1/1 UBI/cfi-mtd: Fix mtd name for multiple chips
From: Andreas Huber <[email protected]>
On platforms with multiple NOR chips, currently only the first one can be selected using the "ubi part" command. This patch fixes this problem by using different names for the NOR "mtd devices".
It also changes the name of the NOR MTD device from "cfi-mtd" to "norX" (X indexing the device numer) to better match the mtdparts defaults.
--- common/cmd_ubi.c | 26 +++++++++++++++++++++----- drivers/mtd/cfi_mtd.c | 4 +++- include/flash.h | 2 -- 3 files changed, 24 insertions(+), 8 deletions(-)
common/cmd_ubi.c +21 -5
@@ -404,9 +404,6 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev)u8 pnum;int err; -if (mtdparts_init () !=0 ) -return 1 ; -if (find_dev_and_part (ubidev, &dev, &pnum, &part) !=0 )return 1 ;
@@ -445,6 +442,11 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])return 1 ; } +if (mtdparts_init () !=0 ) { +printf ("Error initializing mtdparts!\n" ); +return 1 ; + } +if (strcmp (argv[1 ],"part" ) ==0 ) {/* Print current partition */ if (argc ==2 ) {
@@ -475,7 +477,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) }/* -* Check for nand|onenand selection +* Check for nor|nand|onenand selection */ #if defined(CONFIG_CMD_NAND )if (strcmp (argv[2 ],"nand" ) ==0 ) {
@@ -486,9 +488,23 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])#endif #if defined(CONFIG_FLASH_CFI_MTD )if (strcmp (argv[2 ],"nor" ) ==0 ) { +char mtd_dev[16 ]; +struct mtd_device *dev; +struct part_info *part; +u8 pnum; + +/* +* Search the mtd device number where this partition +* is located +*/ +if (find_dev_and_part (argv[3 ], &dev, &pnum, &part)) { +printf ("Partition %s not found!\n" , argv[3 ]); +return 1 ; + } +sprintf (mtd_dev,"nor%d" , dev->id->num); + ubi_dev.mtd_info =get_mtd_device_nm (mtd_dev);strcpy (ubi_dev.dev_name,"NOR" ); ubi_dev.type =DEV_TYPE_NOR ; - ubi_dev.mtd_info =get_mtd_device_nm (CFI_MTD_DEV_NAME ); }#endif #if defined(CONFIG_CMD_ONENAND )
drivers/mtd/cfi_mtd.c +3 -1
@@ -32,6 +32,7 @@extern flash_info_t flash_info[];static struct mtd_info cfi_mtd_info[CONFIG_SYS_MAX_FLASH_BANKS ]; +static char cfi_mtd_names[CONFIG_SYS_MAX_FLASH_BANKS ][16 ];static int cfi_mtd_erase (struct mtd_info *mtd,struct erase_info *instr) {
@@ -170,7 +171,8 @@ int cfi_mtd_init(void)if (error)continue ; - mtd->name =CFI_MTD_DEV_NAME ; +sprintf (cfi_mtd_names[i],"nor%d" , i); + mtd->name = cfi_mtd_names[i]; mtd->type =MTD_NORFLASH ; mtd->flags =MTD_CAP_NORFLASH ; mtd->size = fi->size;
include/flash.h +0 -2
@@ -87,8 +87,6 @@ typedef unsigned long flash_sect_t;/* convert between bit value and numeric value */ #define CFI_FLASH_SHIFT_WIDTH 3 -/* cfi-mtd device name */ -#define CFI_MTD_DEV_NAME "cfi-mtd"/* Prototypes */ extern unsigned long flash_init (void );
Signature · 1 line
1.6.2.1
Wolfgang Denk
AppliedPATCH 1/1 UBI/cfi-mtd: Fix mtd name for multiple chips
Dear Stefan Roese,
Quoted 10 lines · In message <[email protected]> you wrote:
From: Andreas Huber <[email protected]>
On platforms with multiple NOR chips, currently only the first one can be selected using the "ubi part" command. This patch fixes this problem by using different names for the NOR "mtd devices".
It also changes the name of the NOR MTD device from "cfi-mtd" to "norX" (X indexing the device numer) to better match the mtdparts defaults.
Quoted 7 lines
Signed-off-by Stefan Roese <[email protected]>Signed-off-by Andreas Huber <[email protected]>--- common/cmd_ubi.c | 26 +++++++++++++++++++++----- drivers/mtd/cfi_mtd.c | 4 +++- include/flash.h | 2 -- 3 files changed, 24 insertions(+), 8 deletions(-)
Applied, thanks.
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 "Life is a garment we continuously alter, but which never seems to fit." - David McCord