Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memory: emif: Add ifdef CONFIG_DEBUG_FS guard for emif_debugfs_[init|exit]

Add ifdef CONFIG_DEBUG_FS guard for emif_debugfs_[init|exit], and adds stub
functions for the case CONFIG_DEBUG_FS is not set.

When CONFIG_DEBUG_FS is enabled, debugfs_create_dir and debugfs_create_file
return NULL on failure, fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Axel Lin and committed by
Greg Kroah-Hartman
e5445ee6 1980a347

+17 -6
+17 -6
drivers/memory/emif.c
··· 75 75 static u32 t_ck; /* DDR clock period in ps */ 76 76 static LIST_HEAD(device_list); 77 77 78 + #ifdef CONFIG_DEBUG_FS 78 79 static void do_emif_regdump_show(struct seq_file *s, struct emif_data *emif, 79 80 struct emif_regs *regs) 80 81 { ··· 167 166 int ret; 168 167 169 168 dentry = debugfs_create_dir(dev_name(emif->dev), NULL); 170 - if (IS_ERR(dentry)) { 171 - ret = PTR_ERR(dentry); 169 + if (!dentry) { 170 + ret = -ENOMEM; 172 171 goto err0; 173 172 } 174 173 emif->debugfs_root = dentry; 175 174 176 175 dentry = debugfs_create_file("regcache_dump", S_IRUGO, 177 176 emif->debugfs_root, emif, &emif_regdump_fops); 178 - if (IS_ERR(dentry)) { 179 - ret = PTR_ERR(dentry); 177 + if (!dentry) { 178 + ret = -ENOMEM; 180 179 goto err1; 181 180 } 182 181 183 182 dentry = debugfs_create_file("mr4", S_IRUGO, 184 183 emif->debugfs_root, emif, &emif_mr4_fops); 185 - if (IS_ERR(dentry)) { 186 - ret = PTR_ERR(dentry); 184 + if (!dentry) { 185 + ret = -ENOMEM; 187 186 goto err1; 188 187 } 189 188 ··· 199 198 debugfs_remove_recursive(emif->debugfs_root); 200 199 emif->debugfs_root = NULL; 201 200 } 201 + #else 202 + static inline int __init_or_module emif_debugfs_init(struct emif_data *emif) 203 + { 204 + return 0; 205 + } 206 + 207 + static inline void __exit emif_debugfs_exit(struct emif_data *emif) 208 + { 209 + } 210 + #endif 202 211 203 212 /* 204 213 * Calculate the period of DDR clock from frequency value