hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/wireless/ath/ath11k/debugfs.c
....@@ -836,10 +836,6 @@
836836 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
837837 return 0;
838838
839
- ab->debugfs_soc = debugfs_create_dir(ab->hw_params.name, ab->debugfs_ath11k);
840
- if (IS_ERR(ab->debugfs_soc))
841
- return PTR_ERR(ab->debugfs_soc);
842
-
843839 debugfs_create_file("simulate_fw_crash", 0600, ab->debugfs_soc, ab,
844840 &fops_simulate_fw_crash);
845841
....@@ -857,15 +853,51 @@
857853
858854 int ath11k_debugfs_soc_create(struct ath11k_base *ab)
859855 {
860
- ab->debugfs_ath11k = debugfs_create_dir("ath11k", NULL);
856
+ struct dentry *root;
857
+ bool dput_needed;
858
+ char name[64];
859
+ int ret;
861860
862
- return PTR_ERR_OR_ZERO(ab->debugfs_ath11k);
861
+ root = debugfs_lookup("ath11k", NULL);
862
+ if (!root) {
863
+ root = debugfs_create_dir("ath11k", NULL);
864
+ if (IS_ERR_OR_NULL(root))
865
+ return PTR_ERR(root);
866
+
867
+ dput_needed = false;
868
+ } else {
869
+ /* a dentry from lookup() needs dput() after we don't use it */
870
+ dput_needed = true;
871
+ }
872
+
873
+ scnprintf(name, sizeof(name), "%s-%s", ath11k_bus_str(ab->hif.bus),
874
+ dev_name(ab->dev));
875
+
876
+ ab->debugfs_soc = debugfs_create_dir(name, root);
877
+ if (IS_ERR_OR_NULL(ab->debugfs_soc)) {
878
+ ret = PTR_ERR(ab->debugfs_soc);
879
+ goto out;
880
+ }
881
+
882
+ ret = 0;
883
+
884
+out:
885
+ if (dput_needed)
886
+ dput(root);
887
+
888
+ return ret;
863889 }
864890
865891 void ath11k_debugfs_soc_destroy(struct ath11k_base *ab)
866892 {
867
- debugfs_remove_recursive(ab->debugfs_ath11k);
868
- ab->debugfs_ath11k = NULL;
893
+ debugfs_remove_recursive(ab->debugfs_soc);
894
+ ab->debugfs_soc = NULL;
895
+
896
+ /* We are not removing ath11k directory on purpose, even if it
897
+ * would be empty. This simplifies the directory handling and it's
898
+ * a minor cosmetic issue to leave an empty ath11k directory to
899
+ * debugfs.
900
+ */
869901 }
870902
871903 void ath11k_debugfs_fw_stats_init(struct ath11k *ar)