OSDN Git Service

0fbc4bd8cad85f550fb05fd83015508546b468f5
[immortalwrt/immortalwrt.git] / target / linux / ipq806x / patches-5.15 / 107-2-thermal-qcom-tsens-simplify-debugfs-init-function.patch
1 From 4204f22060f7a5d42c6ccb4d4c25a6a875571099 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Mon, 19 Apr 2021 03:08:37 +0200
4 Subject: [thermal-next PATCH v2 2/2] thermal: qcom: tsens: simplify debugfs init
5  function
6
7 Simplify debugfs init function.
8 - Add check for existing dev directory.
9 - Fix wrong version in dbg_version_show (with version 0.0.0, 0.1.0 was
10   incorrectly reported)
11
12 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
13 Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>
14 ---
15  drivers/thermal/qcom/tsens.c | 16 +++++++---------
16  1 file changed, 7 insertions(+), 9 deletions(-)
17
18 --- a/drivers/thermal/qcom/tsens.c
19 +++ b/drivers/thermal/qcom/tsens.c
20 @@ -692,7 +692,7 @@ static int dbg_version_show(struct seq_f
21                         return ret;
22                 seq_printf(s, "%d.%d.%d\n", maj_ver, min_ver, step_ver);
23         } else {
24 -               seq_puts(s, "0.1.0\n");
25 +               seq_printf(s, "0.%d.0\n", priv->feat->ver_major);
26         }
27  
28         return 0;
29 @@ -704,21 +704,17 @@ DEFINE_SHOW_ATTRIBUTE(dbg_sensors);
30  static void tsens_debug_init(struct platform_device *pdev)
31  {
32         struct tsens_priv *priv = platform_get_drvdata(pdev);
33 -       struct dentry *root, *file;
34  
35 -       root = debugfs_lookup("tsens", NULL);
36 -       if (!root)
37 +       priv->debug_root = debugfs_lookup("tsens", NULL);
38 +       if (!priv->debug_root)
39                 priv->debug_root = debugfs_create_dir("tsens", NULL);
40 -       else
41 -               priv->debug_root = root;
42  
43 -       file = debugfs_lookup("version", priv->debug_root);
44 -       if (!file)
45 +       if (!debugfs_lookup("version", priv->debug_root))
46                 debugfs_create_file("version", 0444, priv->debug_root,
47                                     pdev, &dbg_version_fops);
48  
49         /* A directory for each instance of the TSENS IP */
50 -       priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root);
51 +       priv->debug = debugfs_lookup(dev_name(&pdev->dev), priv->debug_root);
52         debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops);
53  }
54  #else