]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: Add some fallbacks for add/del_mtd_device
authorSean Anderson <seanga2@gmail.com>
Sat, 4 Nov 2023 20:37:48 +0000 (16:37 -0400)
committerTom Rini <trini@konsulko.com>
Thu, 16 Nov 2023 17:43:49 +0000 (12:43 -0500)
This allows using these functions without ifdefs. OneNAND depends on MTD,
so this ifdef was redundant in the first place.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
drivers/mtd/nand/raw/nand.c
drivers/mtd/onenand/onenand_uboot.c
include/linux/mtd/mtd.h

index 4da4143879084fc35102985f54fc191a3faea5e2..3abd82068fb1638239f0406787ce1a66dfcf85bc 100644 (file)
@@ -60,13 +60,11 @@ int nand_register(int devnum, struct mtd_info *mtd)
        sprintf(dev_name[devnum], "nand%d", devnum);
        mtd->name = dev_name[devnum];
 
-#ifdef CONFIG_MTD
        /*
         * Add MTD device so that we can reference it later
         * via the mtdcore infrastructure (e.g. ubi).
         */
        add_mtd_device(mtd);
-#endif
 
        total_nand_size += mtd->size / 1024;
 
index 04791df69bb0e76980b3e767c43c55e40e2d7045..ecacabefadcfa7ac0498079c7893dc230ac719a4 100644 (file)
@@ -44,14 +44,12 @@ void onenand_init(void)
                        puts("Flex-");
                puts("OneNAND: ");
 
-#ifdef CONFIG_MTD
                /*
                 * 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
        }
        print_size(onenand_chip.chipsize, "\n");
 }
index 09f52698877c39b007f02398b18ec531b99009d5..7a66c7af749d7067942dd01c0b257258d79a042d 100644 (file)
@@ -552,8 +552,20 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
 
 #ifdef __UBOOT__
 /* drivers/mtd/mtdcore.h */
+#if CONFIG_IS_ENABLED(MTD)
 int add_mtd_device(struct mtd_info *mtd);
 int del_mtd_device(struct mtd_info *mtd);
+#else
+static inline int add_mtd_device(struct mtd_info *mtd)
+{
+       return -ENOSYS;
+}
+
+static inline int del_mtd_device(struct mtd_info *mtd)
+{
+       return -ENOSYS;
+}
+#endif
 
 #ifdef CONFIG_MTD_PARTITIONS
 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);