Skip to content

Commit e7930ba

Browse files
Rob HerringMauro Carvalho Chehab
authored andcommitted
edac: create top-level debugfs directory
Create a single, top-level "edac" directory for debugfs. An "mc[0-N]" directory is then created for each memory controller. Individual drivers can create additional entries such as h/w error injection control. Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent c105383 commit e7930ba

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

drivers/edac/edac_mc_sysfs.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,33 @@ static struct device_type mci_attr_type = {
899899
};
900900

901901
#ifdef CONFIG_EDAC_DEBUG
902+
static struct dentry *edac_debugfs;
903+
904+
int __init edac_debugfs_init(void)
905+
{
906+
edac_debugfs = debugfs_create_dir("edac", NULL);
907+
if (IS_ERR(edac_debugfs)) {
908+
edac_debugfs = NULL;
909+
return -ENOMEM;
910+
}
911+
return 0;
912+
}
913+
914+
void __exit edac_debugfs_exit(void)
915+
{
916+
debugfs_remove(edac_debugfs);
917+
}
918+
902919
int edac_create_debug_nodes(struct mem_ctl_info *mci)
903920
{
904921
struct dentry *d, *parent;
905922
char name[80];
906923
int i;
907924

908-
d = debugfs_create_dir(mci->dev.kobj.name, mci->debugfs);
925+
if (!edac_debugfs)
926+
return -ENODEV;
927+
928+
d = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
909929
if (!d)
910930
return -ENOMEM;
911931
parent = d;
@@ -930,6 +950,7 @@ int edac_create_debug_nodes(struct mem_ctl_info *mci)
930950
if (!d)
931951
goto nomem;
932952

953+
mci->debugfs = parent;
933954
return 0;
934955
nomem:
935956
debugfs_remove(mci->debugfs);

drivers/edac/edac_module.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ static int __init edac_init(void)
9494
if (err)
9595
goto error;
9696

97+
edac_debugfs_init();
98+
9799
/* Setup/Initialize the workq for this core */
98100
err = edac_workqueue_setup();
99101
if (err) {
@@ -118,6 +120,7 @@ static void __exit edac_exit(void)
118120
/* tear down the various subsystems */
119121
edac_workqueue_teardown();
120122
edac_mc_sysfs_exit();
123+
edac_debugfs_exit();
121124
}
122125

123126
/*

drivers/edac/edac_module.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ extern void edac_mc_reset_delay_period(int value);
5656

5757
extern void *edac_align_ptr(void **p, unsigned size, int n_elems);
5858

59+
/*
60+
* EDAC debugfs functions
61+
*/
62+
#ifdef CONFIG_EDAC_DEBUG
63+
int edac_debugfs_init(void);
64+
void edac_debugfs_exit(void);
65+
#else
66+
static inline int edac_debugfs_init(void)
67+
{
68+
return -ENODEV;
69+
}
70+
static inline void edac_debugfs_exit(void) {}
71+
#endif
72+
5973
/*
6074
* EDAC PCI functions
6175
*/

0 commit comments

Comments
 (0)