[openwrt/openwrt] realtek: mdio-serdes: improve debugfs creation

LEDE Commits lede-commits at lists.infradead.org
Tue Dec 16 04:11:37 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/8e4730fd60a1b4998d1c9c07aeb6c6a27bce210f

commit 8e4730fd60a1b4998d1c9c07aeb6c6a27bce210f
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Tue Dec 16 10:20:13 2025 +0000

    realtek: mdio-serdes: improve debugfs creation
    
    Commit 3c073b5cb2 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 <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21179
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../drivers/net/mdio/mdio-realtek-otto-serdes.c    | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
index 5c8741383f..097fcc41b4 100644
--- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
+++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c
@@ -142,27 +142,30 @@ static int rtsds_dbg_registers_show(struct seq_file *seqf, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(rtsds_dbg_registers);
 
-static int rtsds_debug_init(struct rtsds_ctrl *ctrl, u32 sds)
+static int rtsds_debug_init(struct rtsds_ctrl *ctrl)
 {
 	struct rtsds_debug_info *dbg_info;
 	struct dentry *dir, *root;
 	char dirname[32];
 
-	dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL);
-	if (!dbg_info)
-		return -ENOMEM;
-
-	dbg_info->ctrl = ctrl;
-	dbg_info->sds = sds;
-
 	root = debugfs_create_dir(RTSDS_DBG_ROOT_DIR, NULL);
 	if (IS_ERR(root))
 		return PTR_ERR(root);
 
-	snprintf(dirname, sizeof(dirname), "serdes.%d", sds);
-	dir = debugfs_create_dir(dirname, root);
+	for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++) {
+		dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL);
+		if (!dbg_info)
+			return -ENOMEM;
 
-	debugfs_create_file("registers", 0600, dir, dbg_info, &rtsds_dbg_registers_fops);
+		dbg_info->ctrl = ctrl;
+		dbg_info->sds = sds;
+
+		snprintf(dirname, sizeof(dirname), "serdes.%d", sds);
+		dir = debugfs_create_dir(dirname, root);
+
+		debugfs_create_file("registers", 0600, dir, dbg_info,
+				    &rtsds_dbg_registers_fops);
+	}
 
 	return 0;
 }
@@ -461,8 +464,7 @@ static int rtsds_probe(struct platform_device *pdev)
 		return ret;
 
 #ifdef CONFIG_DEBUG_FS
-	for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++)
-		rtsds_debug_init(ctrl, sds);
+	rtsds_debug_init(ctrl);
 #endif
 
 	dev_info(dev, "Realtek SerDes mdio bus initialized, %d SerDes, %d pages, %d registers\n",




More information about the lede-commits mailing list