From: Dan Carpenter <dan.carpenter@oracle.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>
Subject: [patch v2] mtd: tiny debugfs related fixes
Date: Mon, 22 Jul 2013 20:43:40 +0000 [thread overview]
Message-ID: <20130722204340.GC22020@elgon.mountain> (raw)
In-Reply-To: <20130719054938.GC9729@elgon.mountain>
debugfs_create_dir() can't return an error pointer because we tested for
IS_ENABLED(CONFIG_DEBUG_FS) earlier so we don't need to test for that.
Also the way debugfs is designed, callers should not normally care about
error pointer returns.
The current code is a little buggy because it return success if
debugfs_create_dir() fails instead of -ENODEV which was intended.
I have also changed the error message slightly.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: completely different
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 63cb1d7..d3c99a6 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -235,12 +235,9 @@ int ubi_debugfs_init(void)
return 0;
dfs_rootdir = debugfs_create_dir("ubi", NULL);
- if (IS_ERR_OR_NULL(dfs_rootdir)) {
- int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir);
-
- ubi_err("cannot create \"ubi\" debugfs directory, error %d\n",
- err);
- return err;
+ if (!dfs_rootdir) {
+ ubi_err("cannot create \"ubi\" debugfs directory.\n");
+ return -ENODEV;
}
return 0;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index cb38f3d..3971465 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -523,24 +523,20 @@ static int nandsim_debugfs_create(struct nandsim *dev)
{
struct nandsim_debug_info *dbg = &dev->dbg;
struct dentry *dent;
- int err;
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return 0;
dent = debugfs_create_dir("nandsim", NULL);
- if (IS_ERR_OR_NULL(dent)) {
- int err = dent ? -ENODEV : PTR_ERR(dent);
-
- NS_ERR("cannot create \"nandsim\" debugfs directory, err %d\n",
- err);
- return err;
+ if (!dent) {
+ NS_ERR("cannot create \"nandsim\" debugfs directory.");
+ return -ENODEV;
}
dbg->dfs_root = dent;
dent = debugfs_create_file("wear_report", S_IRUSR,
dbg->dfs_root, dev, &dfs_fops);
- if (IS_ERR_OR_NULL(dent))
+ if (!dent)
goto out_remove;
dbg->dfs_wear_report = dent;
@@ -548,8 +544,7 @@ static int nandsim_debugfs_create(struct nandsim *dev)
out_remove:
debugfs_remove_recursive(dbg->dfs_root);
- err = dent ? PTR_ERR(dent) : -ENODEV;
- return err;
+ return -ENODEV;
}
/**
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>
Subject: [patch v2] mtd: tiny debugfs related fixes
Date: Mon, 22 Jul 2013 23:43:40 +0300 [thread overview]
Message-ID: <20130722204340.GC22020@elgon.mountain> (raw)
In-Reply-To: <20130719054938.GC9729@elgon.mountain>
debugfs_create_dir() can't return an error pointer because we tested for
IS_ENABLED(CONFIG_DEBUG_FS) earlier so we don't need to test for that.
Also the way debugfs is designed, callers should not normally care about
error pointer returns.
The current code is a little buggy because it return success if
debugfs_create_dir() fails instead of -ENODEV which was intended.
I have also changed the error message slightly.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: completely different
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 63cb1d7..d3c99a6 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -235,12 +235,9 @@ int ubi_debugfs_init(void)
return 0;
dfs_rootdir = debugfs_create_dir("ubi", NULL);
- if (IS_ERR_OR_NULL(dfs_rootdir)) {
- int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir);
-
- ubi_err("cannot create \"ubi\" debugfs directory, error %d\n",
- err);
- return err;
+ if (!dfs_rootdir) {
+ ubi_err("cannot create \"ubi\" debugfs directory.\n");
+ return -ENODEV;
}
return 0;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index cb38f3d..3971465 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -523,24 +523,20 @@ static int nandsim_debugfs_create(struct nandsim *dev)
{
struct nandsim_debug_info *dbg = &dev->dbg;
struct dentry *dent;
- int err;
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return 0;
dent = debugfs_create_dir("nandsim", NULL);
- if (IS_ERR_OR_NULL(dent)) {
- int err = dent ? -ENODEV : PTR_ERR(dent);
-
- NS_ERR("cannot create \"nandsim\" debugfs directory, err %d\n",
- err);
- return err;
+ if (!dent) {
+ NS_ERR("cannot create \"nandsim\" debugfs directory.");
+ return -ENODEV;
}
dbg->dfs_root = dent;
dent = debugfs_create_file("wear_report", S_IRUSR,
dbg->dfs_root, dev, &dfs_fops);
- if (IS_ERR_OR_NULL(dent))
+ if (!dent)
goto out_remove;
dbg->dfs_wear_report = dent;
@@ -548,8 +544,7 @@ static int nandsim_debugfs_create(struct nandsim *dev)
out_remove:
debugfs_remove_recursive(dbg->dfs_root);
- err = dent ? PTR_ERR(dent) : -ENODEV;
- return err;
+ return -ENODEV;
}
/**
next prev parent reply other threads:[~2013-07-22 20:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 5:49 [patch] mtd: use correct error codes in debugfs_create() Dan Carpenter
2013-07-19 5:49 ` Dan Carpenter
2013-07-22 5:56 ` Dan Carpenter
2013-07-22 5:56 ` Dan Carpenter
2013-07-22 7:51 ` walter harms
2013-07-22 7:51 ` walter harms
2013-07-22 12:47 ` Dan Carpenter
2013-07-22 12:47 ` Dan Carpenter
2013-07-22 20:43 ` Dan Carpenter [this message]
2013-07-22 20:43 ` [patch v2] mtd: tiny debugfs related fixes Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130722204340.GC22020@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.