clkmsr: adjust register debugfs [1/4]
authorBichao Zheng <bichao.zheng@amlogic.com>
Mon, 16 Aug 2021 08:00:54 +0000 (16:00 +0800)
committerChristian Hoffmann <chrmhoffmann@gmail.com>
Sun, 12 Feb 2023 08:13:12 +0000 (09:13 +0100)
PD#SWPL-57735

Problem:
close DEBUG_FS then clkmsr crash.

Solution:
adjust register debugfs

Verify:
g12a_u212

Change-Id: I7988c6d4a9508dad26a6f886289ec3509c0af1df
Signed-off-by: Bichao Zheng <bichao.zheng@amlogic.com>
drivers/amlogic/clk/clk_measure.c

index 289f74e67a222d256323c4cf7511c771571b9b72..e2538ef7e9b51aa5f90dffe51dd7e6a2734d68ae 100644 (file)
@@ -1305,20 +1305,17 @@ static int aml_clkmsr_probe(struct platform_device *pdev)
        u32 ringctrl;
 
        np = pdev->dev.of_node;
-       debugfs_root = debugfs_create_dir("aml_clkmsr", NULL);
-       if (IS_ERR(debugfs_root) || !debugfs_root) {
-               pr_warn("failed to create debugfs directory\n");
-               debugfs_root = NULL;
-               return -1;
+       msr_clk_reg0 = of_iomap(np, 0);
+       if (!msr_clk_reg0) {
+               pr_err("%s: failed to map msr_clk_reg0 registers\n", __func__);
+               return -EINVAL;
        }
-       debugfs_create_file("clkmsr", S_IFREG | 0444,
-                           debugfs_root, NULL, &clkmsr_file_ops);
 
-       debugfs_create_file("ringmsr", S_IFREG | 0444,
-                           debugfs_root, NULL, &ringmsr_file_ops);
-
-       msr_clk_reg0 = of_iomap(np, 0);
        msr_clk_reg2 = of_iomap(np, 1);
+       if (!msr_clk_reg2) {
+               pr_err("%s: failed to map msr_clk_reg2 registers\n", __func__);
+               goto err_out;
+       }
        pr_info("msr_clk_reg0=%p,msr_clk_reg2=%p\n",
                msr_clk_reg0, msr_clk_reg2);
 
@@ -1329,13 +1326,35 @@ static int aml_clkmsr_probe(struct platform_device *pdev)
                msr_ring_reg0 = NULL;
        } else {
                msr_ring_reg0 = ioremap(ringctrl, 1);
+               if (!msr_ring_reg0) {
+                       pr_err("%s: failed to map msr_ring_reg0 registers\n",
+                             __func__);
+                       goto err_out1;
+               }
                pr_info("msr_ring_reg0=%p\n", msr_ring_reg0);
        }
 
        clk_data = (struct meson_clkmsr_data *)
        of_device_get_match_data(&pdev->dev);
 
+       debugfs_root = debugfs_create_dir("aml_clkmsr", NULL);
+       if (IS_ERR(debugfs_root) || !debugfs_root) {
+               pr_warn("failed to create debugfs directory\n");
+               return 0;
+       }
+
+       debugfs_create_file("clkmsr", S_IFREG | 0444,
+                           debugfs_root, NULL, &clkmsr_file_ops);
+
+       debugfs_create_file("ringmsr", S_IFREG | 0444,
+                           debugfs_root, NULL, &ringmsr_file_ops);
+
        return 0;
+err_out1:
+       iounmap(msr_clk_reg2);
+err_out:
+       iounmap(msr_clk_reg0);
+       return -EINVAL;
 }
 
 static const char * const tl1_table[] = {