Skip to contentSkip to conversation

ppc4xx: ocm: fix errnous "failed to create file" errors

PATCH New Christian Lamparter 1 participant 1 message Nov 4, 2018 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ppc4xx: ocm: fix errnous "failed to create file" errors

Previously, the kernel would complain:

| debugfs ppc4xx ocm: failed to create file

But the "info" file was still created and working. This is because debugfs_create_file() returns a pointer to a struct *dentry on success or -ENODEV when debugfs isn't available. This patch fixes both the debugfs_create_dir() and debugfs_create_file() check, so this will work as expected.

---
 arch/powerpc/platforms/4xx/ocm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
arch/powerpc/platforms/4xx/ocm.c +8 -3
index 69d9f60d9fe5..4590b4d82969 100644
@@ -289,23 +289,28 @@ static const struct file_operations ocm_debugfs_fops = {
 	.release = single_release,
 };
 
+#ifdef CONFIG_DEBUG_FS
 static int ocm_debugfs_init(void)
 {
 	struct dentry *junk;
 
-	junk = debugfs_create_dir("ppc4xx_ocm", 0);
-	if (!junk) {
+	junk = debugfs_create_dir("ppc4xx_ocm", NULL);
+	if (IS_ERR_OR_NULL(junk)) {
 		printk(KERN_ALERT "debugfs ppc4xx ocm: failed to create dir\n");
 		return -1;
 	}
 
-	if (debugfs_create_file("info", 0644, junk, NULL, &ocm_debugfs_fops)) {
+	if (IS_ERR_OR_NULL(debugfs_create_file("info", 0644, junk, NULL,
+					       &ocm_debugfs_fops))) {
 		printk(KERN_ALERT "debugfs ppc4xx ocm: failed to create file\n");
 		return -1;
 	}
 
 	return 0;
 }
+#else
+static int ocm_debugfs_init(void) { return 0; }
+#endif
 
 void *ppc4xx_ocm_alloc(phys_addr_t *phys, int size, int align,
 			int flags, const char *owner)
Signature · 1 line
2.19.1