Skip to content

Commit 2e56a1f

Browse files
jonasjelonekrobimarko
authored andcommitted
realtek: mdio-serdes: improve debugfs creation
Commit 3c073b5 cleaned up the debugfs creation in mdio-realtek-otto-serdes driver to not explicitly check if the root directory already exists. This is fine because kernel handles the case properly so there's no need to check anymore. However, this pollutes the boot log with: [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' Now, the root directory creation is attempted multiple times, causing the kernel to print an error message because the directory already exists. Fix this by moving the SerDes loop into rtsds_debug_init and only try to create the root debugfs directory once. Signed-off-by: Jonas Jelonek <[email protected]> Link: openwrt/openwrt#21179 Signed-off-by: Robert Marko <[email protected]> (cherry picked from commit 8e4730f)
1 parent 86ebe64 commit 2e56a1f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,30 @@ static int rtsds_dbg_registers_show(struct seq_file *seqf, void *unused)
142142
}
143143
DEFINE_SHOW_ATTRIBUTE(rtsds_dbg_registers);
144144

145-
static int rtsds_debug_init(struct rtsds_ctrl *ctrl, u32 sds)
145+
static int rtsds_debug_init(struct rtsds_ctrl *ctrl)
146146
{
147147
struct rtsds_debug_info *dbg_info;
148148
struct dentry *dir, *root;
149149
char dirname[32];
150150

151-
dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL);
152-
if (!dbg_info)
153-
return -ENOMEM;
154-
155-
dbg_info->ctrl = ctrl;
156-
dbg_info->sds = sds;
157-
158151
root = debugfs_create_dir(RTSDS_DBG_ROOT_DIR, NULL);
159152
if (IS_ERR(root))
160153
return PTR_ERR(root);
161154

162-
snprintf(dirname, sizeof(dirname), "serdes.%d", sds);
163-
dir = debugfs_create_dir(dirname, root);
155+
for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++) {
156+
dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL);
157+
if (!dbg_info)
158+
return -ENOMEM;
164159

165-
debugfs_create_file("registers", 0600, dir, dbg_info, &rtsds_dbg_registers_fops);
160+
dbg_info->ctrl = ctrl;
161+
dbg_info->sds = sds;
162+
163+
snprintf(dirname, sizeof(dirname), "serdes.%d", sds);
164+
dir = debugfs_create_dir(dirname, root);
165+
166+
debugfs_create_file("registers", 0600, dir, dbg_info,
167+
&rtsds_dbg_registers_fops);
168+
}
166169

167170
return 0;
168171
}
@@ -461,8 +464,7 @@ static int rtsds_probe(struct platform_device *pdev)
461464
return ret;
462465

463466
#ifdef CONFIG_DEBUG_FS
464-
for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++)
465-
rtsds_debug_init(ctrl, sds);
467+
rtsds_debug_init(ctrl);
466468
#endif
467469

468470
dev_info(dev, "Realtek SerDes mdio bus initialized, %d SerDes, %d pages, %d registers\n",

0 commit comments

Comments
 (0)