]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thunderbolt: dma_test: No need to store debugfs directory pointer
authorMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 24 Apr 2026 10:04:26 +0000 (13:04 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 5 May 2026 11:53:46 +0000 (13:53 +0200)
We don't actually need to store the debugfs directory pointer inside
struct dma_test. Instead we can use the debugfs_lookup_and_remove()
which also handles the case if the debugfs directory is already removed
by the core driver (for example when cable is disconnected).

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/dma_test.c

index b4aa79d482a0b9e38aa9fc3d0a2b82718b360f43..af1e6bc9c7cdbac291d8d31fa5f6151bdd376d19 100644 (file)
@@ -87,7 +87,6 @@ static const char * const dma_test_result_names[] = {
  * @error_code: Error code of the last run
  * @complete: Used to wait for the Rx to complete
  * @lock: Lock serializing access to this structure
- * @debugfs_dir: dentry of this dma_test
  */
 struct dma_test {
        const struct tb_service *svc;
@@ -108,7 +107,6 @@ struct dma_test {
        enum dma_test_test_error error_code;
        struct completion complete;
        struct mutex lock;
-       struct dentry *debugfs_dir;
 };
 
 /* DMA test property directory UUID: 3188cd10-6523-4a5a-a682-fdca07a248d8 */
@@ -619,18 +617,18 @@ DEFINE_SHOW_ATTRIBUTE(status);
 
 static void dma_test_debugfs_init(struct tb_service *svc)
 {
-       struct dma_test *dt = tb_service_get_drvdata(svc);
+       struct dentry *debugfs_dir;
 
-       dt->debugfs_dir = debugfs_create_dir("dma_test", svc->debugfs_dir);
+       debugfs_dir = debugfs_create_dir("dma_test", svc->debugfs_dir);
 
-       debugfs_create_file("lanes", 0600, dt->debugfs_dir, svc, &lanes_fops);
-       debugfs_create_file("speed", 0600, dt->debugfs_dir, svc, &speed_fops);
-       debugfs_create_file("packets_to_receive", 0600, dt->debugfs_dir, svc,
+       debugfs_create_file("lanes", 0600, debugfs_dir, svc, &lanes_fops);
+       debugfs_create_file("speed", 0600, debugfs_dir, svc, &speed_fops);
+       debugfs_create_file("packets_to_receive", 0600, debugfs_dir, svc,
                            &packets_to_receive_fops);
-       debugfs_create_file("packets_to_send", 0600, dt->debugfs_dir, svc,
+       debugfs_create_file("packets_to_send", 0600, debugfs_dir, svc,
                            &packets_to_send_fops);
-       debugfs_create_file("status", 0400, dt->debugfs_dir, svc, &status_fops);
-       debugfs_create_file("test", 0200, dt->debugfs_dir, svc, &test_fops);
+       debugfs_create_file("status", 0400, debugfs_dir, svc, &status_fops);
+       debugfs_create_file("test", 0200, debugfs_dir, svc, &test_fops);
 }
 
 static int dma_test_probe(struct tb_service *svc, const struct tb_service_id *id)
@@ -658,7 +656,7 @@ static void dma_test_remove(struct tb_service *svc)
        struct dma_test *dt = tb_service_get_drvdata(svc);
 
        mutex_lock(&dt->lock);
-       debugfs_remove_recursive(dt->debugfs_dir);
+       debugfs_lookup_and_remove("dma_test", svc->debugfs_dir);
        mutex_unlock(&dt->lock);
 }