004-v6.2-03-thermal-drivers-qcom-tsens-Rework-debugfs-file-struc.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 89992d95ed1046338c7866ef7bbe6de543a2af91 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Sat, 22 Oct 2022 14:56:57 +0200
  4. Subject: [PATCH 3/3] thermal/drivers/qcom/tsens: Rework debugfs file structure
  5. The current tsens debugfs structure is composed by:
  6. - a tsens dir in debugfs with a version file
  7. - a directory for each tsens istance with sensors file to dump all the
  8. sensors value.
  9. This works on the assumption that we have the same version for each
  10. istance but this assumption seems fragile and with more than one tsens
  11. istance results in the version file not tracking each of them.
  12. A better approach is to just create a subdirectory for each tsens
  13. istance and put there version and sensors debugfs file.
  14. Using this new implementation results in less code since debugfs entry
  15. are created only on successful tsens probe.
  16. Signed-off-by: Christian Marangi <[email protected]>
  17. Link: https://lore.kernel.org/r/[email protected]
  18. Signed-off-by: Daniel Lezcano <[email protected]>
  19. ---
  20. drivers/thermal/qcom/tsens.c | 13 +++----------
  21. 1 file changed, 3 insertions(+), 10 deletions(-)
  22. --- a/drivers/thermal/qcom/tsens.c
  23. +++ b/drivers/thermal/qcom/tsens.c
  24. @@ -704,21 +704,14 @@ DEFINE_SHOW_ATTRIBUTE(dbg_sensors);
  25. static void tsens_debug_init(struct platform_device *pdev)
  26. {
  27. struct tsens_priv *priv = platform_get_drvdata(pdev);
  28. - struct dentry *root, *file;
  29. - root = debugfs_lookup("tsens", NULL);
  30. - if (!root)
  31. + priv->debug_root = debugfs_lookup("tsens", NULL);
  32. + if (!priv->debug_root)
  33. priv->debug_root = debugfs_create_dir("tsens", NULL);
  34. - else
  35. - priv->debug_root = root;
  36. -
  37. - file = debugfs_lookup("version", priv->debug_root);
  38. - if (!file)
  39. - debugfs_create_file("version", 0444, priv->debug_root,
  40. - pdev, &dbg_version_fops);
  41. /* A directory for each instance of the TSENS IP */
  42. priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root);
  43. + debugfs_create_file("version", 0444, priv->debug, pdev, &dbg_version_fops);
  44. debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops);
  45. }
  46. #else