Skip to contentSkip to conversation

intel_ips: fix error handling for debugfs_create_dir()

PATCH In review Dan Carpenter 1 participant 3 messages Jul 19, 2013 – Jul 22, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_ips: fix error handling for debugfs_create_dir()

If debugfs is not enabled then debugfs_create_dir() returns ERR_PTR(-ENODEV). Also my static checker complains that we are trying to print the error code, but it's is always just NULL.

drivers/platform/x86/intel_ips.c +2 -2
index 18dcb58..4416d92 100644
@@ -1328,7 +1328,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
 	int i;
 
 	ips->debug_root = debugfs_create_dir("ips", NULL);
-	if (!ips->debug_root) {
+	if (IS_ERR_OR_NULL(ips->debug_root)) {
 		dev_err(&ips->dev->dev,
 			"failed to create debugfs entries: %ld\n",
 			PTR_ERR(ips->debug_root));
@@ -1343,7 +1343,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
 		ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO,
 					  ips->debug_root, node,
 					  &ips_debugfs_ops);
-		if (!ent) {
+		if (IS_ERR_OR_NULL(ent)) {
 			dev_err(&ips->dev->dev,
 				"failed to create debug file: %ld\n",
 				PTR_ERR(ent));
#1 lore raw
Quoted 4 lines · Dan Carpenter

If debugfs is not enabled then debugfs_create_dir() returns ERR_PTR(-ENODEV). Also my static checker complains that we are trying to print the error code, but it's is always just NULL.

Sorry about this. This patch is wrong. Please ignore.

regards,
dan carpenter

#2 lore raw

PATCH v2 1/1 intel_ips: cleanup a couple error messages

In reply to Dan Carpenter

Printing PTR_ERR(NULL) is not useful so I have updated the error messages a little.

---
v2: completely different

drivers/platform/x86/intel_ips.c +3 -5
index 18dcb58..e5c115d 100644
@@ -1329,9 +1329,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
 
 	ips->debug_root = debugfs_create_dir("ips", NULL);
 	if (!ips->debug_root) {
-		dev_err(&ips->dev->dev,
-			"failed to create debugfs entries: %ld\n",
-			PTR_ERR(ips->debug_root));
+		dev_err(&ips->dev->dev, "failed to create debugfs entries\n");
 		return;
 	}
 
@@ -1345,8 +1343,8 @@ static void ips_debugfs_init(struct ips_driver *ips)
 					  &ips_debugfs_ops);
 		if (!ent) {
 			dev_err(&ips->dev->dev,
-				"failed to create debug file: %ld\n",
-				PTR_ERR(ent));
+				"failed to create debug file: %s\n",
+				node->name);
 			goto err_cleanup;
 		}
 	}