]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: nand/onenand: Register mtd device upon device scanning
authorStefan Roese <sr@denx.de>
Fri, 24 Apr 2009 13:59:35 +0000 (15:59 +0200)
committerWolfgang Denk <wd@denx.de>
Mon, 27 Apr 2009 23:15:38 +0000 (01:15 +0200)
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).

Signed-off-by: Stefan Roese <sr@denx.de>
drivers/mtd/nand/nand.c
drivers/mtd/onenand/onenand_uboot.c

index 9d8379497431ba19eeb626c1174b7d40384ed177..d3691151f0513eb3c613d43dc29bbcf1ad4a7ab4 100644 (file)
@@ -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 {
index 4541b221772b35d140eae003fd821077b6116807..a95b922a8f4d8d99e43c6a38f08ee587a635a548 100644 (file)
@@ -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
 }