Skip to contentSkip to conversation

mtd: nand/onenand: Register mtd device upon device scanning

PATCH New Stefan Roese 2 participants 2 messages Apr 24, 2009 – Apr 27, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand/onenand: Register mtd device upon device scanning

With this patch the NAND and OneNAND devices are registered in the MTD subsystem and can then be referenced by the mtdcore code (e.g. get_mtd_device_nm()). This is needed for the new "ubi part" command syntax without the flash type parameter (nor|nand|onenand).

---
 drivers/mtd/nand/nand.c             |   12 ++++++++++++
 drivers/mtd/onenand/onenand_uboot.c |   10 ++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/nand/nand.c +12 -0
index 9d83794..d369115 100644
@@ -37,11 +37,13 @@ static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
 static ulong base_address[CONFIG_SYS_MAX_NAND_DEVICE] = CONFIG_SYS_NAND_BASE_LIST;
 
 static const char default_nand_name[] = "nand";
+static __attribute__((unused)) char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
 
 static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
 			   ulong base_addr)
 {
 	int maxchips = CONFIG_SYS_NAND_MAX_CHIPS;
+	int __attribute__((unused)) i = 0;
 
 	if (maxchips < 1)
 		maxchips = 1;
@@ -54,6 +56,16 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
 				mtd->name = (char *)default_nand_name;
 			else
 				mtd->name += gd->reloc_off;
+
+#ifdef CONFIG_MTD_PARTITIONS
+			/*
+			 * Add MTD device so that we can reference it later
+			 * via the mtdcore infrastructure (e.g. ubi).
+			 */
+			sprintf(dev_name[i], "nand%d", i);
+			mtd->name = dev_name[i++];
+			add_mtd_device(mtd);
+#endif
 		} else
 			mtd->name = NULL;
 	} else {
drivers/mtd/onenand/onenand_uboot.c +10 -0
index 4541b22..a95b922 100644
@@ -20,6 +20,7 @@
 
 struct mtd_info onenand_mtd;
 struct onenand_chip onenand_chip;
+static __attribute__((unused)) char dev_name[] = "onenand0";
 
 void onenand_init(void)
 {
@@ -41,4 +42,13 @@ void onenand_init(void)
 
 	puts("OneNAND: ");
 	print_size(onenand_mtd.size, "\n");
+
+#ifdef CONFIG_MTD_PARTITIONS
+	/*
+	 * Add MTD device so that we can reference it later
+	 * via the mtdcore infrastructure (e.g. ubi).
+	 */
+	onenand_mtd.name = dev_name;
+	add_mtd_device(&onenand_mtd);
+#endif
 }
Signature · 1 line
1.6.2.4
#1 lore raw

PATCH 1/1 mtd: nand/onenand: Register mtd device upon device scanning

Dear Stefan Roese,

Quoted 10 lines · In message <[email protected]> you wrote:

With this patch the NAND and OneNAND devices are registered in the MTD subsystem and can then be referenced by the mtdcore code (e.g. get_mtd_device_nm()). This is needed for the new "ubi part" command syntax without the flash type parameter (nor|nand|onenand).

---
 drivers/mtd/nand/nand.c             |   12 ++++++++++++
 drivers/mtd/onenand/onenand_uboot.c |   10 ++++++++++
 2 files changed, 22 insertions(+), 0 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
Don't tell me how hard you work.  Tell me how much you get done.
- James J. Ling