110-02-thermal-qcom-tsens-simplify-debugfs-init-function.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 4204f22060f7a5d42c6ccb4d4c25a6a875571099 Mon Sep 17 00:00:00 2001
  2. From: Ansuel Smith <[email protected]>
  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. Simplify debugfs init function.
  7. - Add check for existing dev directory.
  8. - Fix wrong version in dbg_version_show (with version 0.0.0, 0.1.0 was
  9. incorrectly reported)
  10. Signed-off-by: Ansuel Smith <[email protected]>
  11. Reviewed-by: Thara Gopinath <[email protected]>
  12. ---
  13. drivers/thermal/qcom/tsens.c | 16 +++++++---------
  14. 1 file changed, 7 insertions(+), 9 deletions(-)
  15. --- a/drivers/thermal/qcom/tsens.c
  16. +++ b/drivers/thermal/qcom/tsens.c
  17. @@ -691,7 +691,7 @@ static int dbg_version_show(struct seq_f
  18. return ret;
  19. seq_printf(s, "%d.%d.%d\n", maj_ver, min_ver, step_ver);
  20. } else {
  21. - seq_puts(s, "0.1.0\n");
  22. + seq_printf(s, "0.%d.0\n", priv->feat->ver_major);
  23. }
  24. return 0;
  25. @@ -703,21 +703,17 @@ DEFINE_SHOW_ATTRIBUTE(dbg_sensors);
  26. static void tsens_debug_init(struct platform_device *pdev)
  27. {
  28. struct tsens_priv *priv = platform_get_drvdata(pdev);
  29. - struct dentry *root, *file;
  30. - root = debugfs_lookup("tsens", NULL);
  31. - if (!root)
  32. + priv->debug_root = debugfs_lookup("tsens", NULL);
  33. + if (!priv->debug_root)
  34. priv->debug_root = debugfs_create_dir("tsens", NULL);
  35. - else
  36. - priv->debug_root = root;
  37. - file = debugfs_lookup("version", priv->debug_root);
  38. - if (!file)
  39. + if (!debugfs_lookup("version", priv->debug_root))
  40. debugfs_create_file("version", 0444, priv->debug_root,
  41. pdev, &dbg_version_fops);
  42. /* A directory for each instance of the TSENS IP */
  43. - priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root);
  44. + priv->debug = debugfs_lookup(dev_name(&pdev->dev), priv->debug_root);
  45. debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops);
  46. }
  47. #else