Merge tag 'pci-v5.18-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / mtd / mtdcore.c
index eef87b28d6c843120434fbf41d763ca057611ada..7731796024e00a71e2614b5bd50511cfb3f53ee6 100644 (file)
@@ -336,49 +336,31 @@ static const struct device_type mtd_devtype = {
        .release        = mtd_release,
 };
 
-static int mtd_partid_debug_show(struct seq_file *s, void *p)
-{
-       struct mtd_info *mtd = s->private;
-
-       seq_printf(s, "%s\n", mtd->dbg.partid);
-
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mtd_partid_debug);
+static bool mtd_expert_analysis_mode;
 
-static int mtd_partname_debug_show(struct seq_file *s, void *p)
+#ifdef CONFIG_DEBUG_FS
+bool mtd_check_expert_analysis_mode(void)
 {
-       struct mtd_info *mtd = s->private;
+       const char *mtd_expert_analysis_warning =
+               "Bad block checks have been entirely disabled.\n"
+               "This is only reserved for post-mortem forensics and debug purposes.\n"
+               "Never enable this mode if you do not know what you are doing!\n";
 
-       seq_printf(s, "%s\n", mtd->dbg.partname);
-
-       return 0;
+       return WARN_ONCE(mtd_expert_analysis_mode, mtd_expert_analysis_warning);
 }
-
-DEFINE_SHOW_ATTRIBUTE(mtd_partname_debug);
+EXPORT_SYMBOL_GPL(mtd_check_expert_analysis_mode);
+#endif
 
 static struct dentry *dfs_dir_mtd;
 
 static void mtd_debugfs_populate(struct mtd_info *mtd)
 {
-       struct mtd_info *master = mtd_get_master(mtd);
        struct device *dev = &mtd->dev;
-       struct dentry *root;
 
        if (IS_ERR_OR_NULL(dfs_dir_mtd))
                return;
 
-       root = debugfs_create_dir(dev_name(dev), dfs_dir_mtd);
-       mtd->dbg.dfs_dir = root;
-
-       if (master->dbg.partid)
-               debugfs_create_file("partid", 0400, root, master,
-                                   &mtd_partid_debug_fops);
-
-       if (master->dbg.partname)
-               debugfs_create_file("partname", 0400, root, master,
-                                   &mtd_partname_debug_fops);
+       mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(dev), dfs_dir_mtd);
 }
 
 #ifndef CONFIG_MMU
@@ -743,8 +725,7 @@ int del_mtd_device(struct mtd_info *mtd)
                debugfs_remove_recursive(mtd->dbg.dfs_dir);
 
                /* Try to remove the NVMEM provider */
-               if (mtd->nvmem)
-                       nvmem_unregister(mtd->nvmem);
+               nvmem_unregister(mtd->nvmem);
 
                device_unregister(&mtd->dev);
 
@@ -923,8 +904,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
        return 0;
 
 err:
-       if (mtd->otp_user_nvmem)
-               nvmem_unregister(mtd->otp_user_nvmem);
+       nvmem_unregister(mtd->otp_user_nvmem);
        return err;
 }
 
@@ -1028,11 +1008,8 @@ int mtd_device_unregister(struct mtd_info *master)
                memset(&master->reboot_notifier, 0, sizeof(master->reboot_notifier));
        }
 
-       if (master->otp_user_nvmem)
-               nvmem_unregister(master->otp_user_nvmem);
-
-       if (master->otp_factory_nvmem)
-               nvmem_unregister(master->otp_factory_nvmem);
+       nvmem_unregister(master->otp_user_nvmem);
+       nvmem_unregister(master->otp_factory_nvmem);
 
        err = del_mtd_partitions(master);
        if (err)
@@ -2372,14 +2349,6 @@ static struct backing_dev_info * __init mtd_bdi_init(const char *name)
        return ret ? ERR_PTR(ret) : bdi;
 }
 
-char *mtd_expert_analysis_warning =
-       "Bad block checks have been entirely disabled.\n"
-       "This is only reserved for post-mortem forensics and debug purposes.\n"
-       "Never enable this mode if you do not know what you are doing!\n";
-EXPORT_SYMBOL_GPL(mtd_expert_analysis_warning);
-bool mtd_expert_analysis_mode;
-EXPORT_SYMBOL_GPL(mtd_expert_analysis_mode);
-
 static struct proc_dir_entry *proc_mtd;
 
 static int __init init_mtd(void)