Commit 912ebd99 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Borislav Petkov

EDAC: Do not check return value of debugfs_create() functions

When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.

 [ bp: Make edac_debugfs_init() return void too, while at it. ]
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: https://lkml.kernel.org/r/20190122152151.16139-17-gregkh@linuxfoundation.org
parent 794a48ce
...@@ -41,14 +41,9 @@ static const struct file_operations debug_fake_inject_fops = { ...@@ -41,14 +41,9 @@ static const struct file_operations debug_fake_inject_fops = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
}; };
int __init edac_debugfs_init(void) void __init edac_debugfs_init(void)
{ {
edac_debugfs = debugfs_create_dir("edac", NULL); edac_debugfs = debugfs_create_dir("edac", NULL);
if (IS_ERR(edac_debugfs)) {
edac_debugfs = NULL;
return -ENOMEM;
}
return 0;
} }
void edac_debugfs_exit(void) void edac_debugfs_exit(void)
...@@ -56,50 +51,31 @@ void edac_debugfs_exit(void) ...@@ -56,50 +51,31 @@ void edac_debugfs_exit(void)
debugfs_remove_recursive(edac_debugfs); debugfs_remove_recursive(edac_debugfs);
} }
int edac_create_debugfs_nodes(struct mem_ctl_info *mci) void edac_create_debugfs_nodes(struct mem_ctl_info *mci)
{ {
struct dentry *d, *parent; struct dentry *parent;
char name[80]; char name[80];
int i; int i;
if (!edac_debugfs) parent = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
return -ENODEV;
d = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
if (!d)
return -ENOMEM;
parent = d;
for (i = 0; i < mci->n_layers; i++) { for (i = 0; i < mci->n_layers; i++) {
sprintf(name, "fake_inject_%s", sprintf(name, "fake_inject_%s",
edac_layer_name[mci->layers[i].type]); edac_layer_name[mci->layers[i].type]);
d = debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent, debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent,
&mci->fake_inject_layer[i]); &mci->fake_inject_layer[i]);
if (!d)
goto nomem;
} }
d = debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent, debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent,
&mci->fake_inject_ue); &mci->fake_inject_ue);
if (!d)
goto nomem;
d = debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent, debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent,
&mci->fake_inject_count); &mci->fake_inject_count);
if (!d)
goto nomem;
d = debugfs_create_file("fake_inject", S_IWUSR, parent, debugfs_create_file("fake_inject", S_IWUSR, parent, &mci->dev,
&mci->dev, &debug_fake_inject_fops);
&debug_fake_inject_fops);
if (!d)
goto nomem;
mci->debugfs = parent; mci->debugfs = parent;
return 0;
nomem:
edac_debugfs_remove_recursive(mci->debugfs);
return -ENOMEM;
} }
/* Create a toplevel dir under EDAC's debugfs hierarchy */ /* Create a toplevel dir under EDAC's debugfs hierarchy */
......
...@@ -69,9 +69,9 @@ extern void *edac_align_ptr(void **p, unsigned size, int n_elems); ...@@ -69,9 +69,9 @@ extern void *edac_align_ptr(void **p, unsigned size, int n_elems);
#define edac_debugfs_remove_recursive debugfs_remove_recursive #define edac_debugfs_remove_recursive debugfs_remove_recursive
#define edac_debugfs_remove debugfs_remove #define edac_debugfs_remove debugfs_remove
#ifdef CONFIG_EDAC_DEBUG #ifdef CONFIG_EDAC_DEBUG
int edac_debugfs_init(void); void edac_debugfs_init(void);
void edac_debugfs_exit(void); void edac_debugfs_exit(void);
int edac_create_debugfs_nodes(struct mem_ctl_info *mci); void edac_create_debugfs_nodes(struct mem_ctl_info *mci);
struct dentry *edac_debugfs_create_dir(const char *dirname); struct dentry *edac_debugfs_create_dir(const char *dirname);
struct dentry * struct dentry *
edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent); edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent);
...@@ -83,9 +83,9 @@ edac_debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 ...@@ -83,9 +83,9 @@ edac_debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8
struct dentry * struct dentry *
edac_debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); edac_debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value);
#else #else
static inline int edac_debugfs_init(void) { return -ENODEV; } static inline void edac_debugfs_init(void) { }
static inline void edac_debugfs_exit(void) { } static inline void edac_debugfs_exit(void) { }
static inline int edac_create_debugfs_nodes(struct mem_ctl_info *mci) { return 0; } static inline void edac_create_debugfs_nodes(struct mem_ctl_info *mci) { }
static inline struct dentry *edac_debugfs_create_dir(const char *dirname) { return NULL; } static inline struct dentry *edac_debugfs_create_dir(const char *dirname) { return NULL; }
static inline struct dentry * static inline struct dentry *
edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent) { return NULL; } edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent) { return NULL; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment