From 76a1e14e9cdda684be19a3f1b477f417679eee37 Mon Sep 17 00:00:00 2001 From: Bichao Zheng Date: Mon, 16 Aug 2021 16:00:54 +0800 Subject: [PATCH] clkmsr: adjust register debugfs [1/4] 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 --- drivers/amlogic/clk/clk_measure.c | 41 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/amlogic/clk/clk_measure.c b/drivers/amlogic/clk/clk_measure.c index 289f74e67a22..e2538ef7e9b5 100644 --- a/drivers/amlogic/clk/clk_measure.c +++ b/drivers/amlogic/clk/clk_measure.c @@ -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[] = { -- 2.20.1