All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: Fix build warning for TA debugfs interface
@ 2022-04-27 11:22 Candice Li
  2022-04-27 12:13 ` Wang, Yang(Kevin)
  0 siblings, 1 reply; 2+ messages in thread
From: Candice Li @ 2022-04-27 11:22 UTC (permalink / raw)
  To: amd-gfx; +Cc: Candice Li

Remove the redundant codes to fix build warning
when CONFIG_DEBUG_FS is disabled.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Candice Li <candice.li@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 43 ++++++----------------
 1 file changed, 12 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
index 6806deb098d3f7..97ea2246bc1ddb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
@@ -24,13 +24,6 @@
 #include "amdgpu.h"
 #include "amdgpu_psp_ta.h"
 
-static const char *TA_IF_FS_NAME = "ta_if";
-
-struct dentry *dir;
-static struct dentry *ta_load_debugfs_dentry;
-static struct dentry *ta_unload_debugfs_dentry;
-static struct dentry *ta_invoke_debugfs_dentry;
-
 static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf,
 					    size_t len, loff_t *off);
 static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf,
@@ -38,7 +31,6 @@ static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf,
 static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf,
 					    size_t len, loff_t *off);
 
-
 static uint32_t get_bin_version(const uint8_t *bin)
 {
 	const struct common_firmware_header *hdr =
@@ -74,19 +66,19 @@ static bool is_ta_type_valid(enum ta_type_id ta_type)
 }
 
 static const struct file_operations ta_load_debugfs_fops = {
-	.write   = ta_if_load_debugfs_write,
+	.write  = ta_if_load_debugfs_write,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
 
 static const struct file_operations ta_unload_debugfs_fops = {
-	.write   = ta_if_unload_debugfs_write,
+	.write  = ta_if_unload_debugfs_write,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
 
 static const struct file_operations ta_invoke_debugfs_fops = {
-	.write   = ta_if_invoke_debugfs_write,
+	.write  = ta_if_invoke_debugfs_write,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
@@ -286,31 +278,20 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
 	return ret;
 }
 
-static struct dentry *amdgpu_ta_if_debugfs_create(struct amdgpu_device *adev)
+void amdgpu_ta_if_debugfs_init(struct amdgpu_device *adev)
 {
+#if defined(CONFIG_DEBUG_FS)
 	struct drm_minor *minor = adev_to_drm(adev)->primary;
 
-	dir = debugfs_create_dir(TA_IF_FS_NAME, minor->debugfs_root);
-
-	ta_load_debugfs_dentry = debugfs_create_file("ta_load", 0200, dir, adev,
-						     &ta_load_debugfs_fops);
+	struct dentry *dir = debugfs_create_dir("ta_if", minor->debugfs_root);
 
-	ta_unload_debugfs_dentry = debugfs_create_file("ta_unload", 0200, dir,
-						     adev, &ta_unload_debugfs_fops);
+	debugfs_create_file("ta_load", 0200, dir, adev,
+				     &ta_load_debugfs_fops);
 
-	ta_invoke_debugfs_dentry = debugfs_create_file("ta_invoke", 0200, dir,
-						     adev, &ta_invoke_debugfs_fops);
-	return dir;
-}
+	debugfs_create_file("ta_unload", 0200, dir,
+				     adev, &ta_unload_debugfs_fops);
 
-void amdgpu_ta_if_debugfs_init(struct amdgpu_device *adev)
-{
-#if defined(CONFIG_DEBUG_FS)
-	dir = amdgpu_ta_if_debugfs_create(adev);
+	debugfs_create_file("ta_invoke", 0200, dir,
+				     adev, &ta_invoke_debugfs_fops);
 #endif
 }
-
-void amdgpu_ta_if_debugfs_remove(void)
-{
-	debugfs_remove_recursive(dir);
-}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] drm/amdgpu: Fix build warning for TA debugfs interface
  2022-04-27 11:22 [PATCH v2] drm/amdgpu: Fix build warning for TA debugfs interface Candice Li
@ 2022-04-27 12:13 ` Wang, Yang(Kevin)
  0 siblings, 0 replies; 2+ messages in thread
From: Wang, Yang(Kevin) @ 2022-04-27 12:13 UTC (permalink / raw)
  To: Li, Candice, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 4541 bytes --]

[Public]


________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Candice Li <candice.li@amd.com>
Sent: Wednesday, April 27, 2022 7:22 PM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Li, Candice <Candice.Li@amd.com>
Subject: [PATCH v2] drm/amdgpu: Fix build warning for TA debugfs interface

Remove the redundant codes to fix build warning
when CONFIG_DEBUG_FS is disabled.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Candice Li <candice.li@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 43 ++++++----------------
 1 file changed, 12 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
index 6806deb098d3f7..97ea2246bc1ddb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
@@ -24,13 +24,6 @@
 #include "amdgpu.h"
 #include "amdgpu_psp_ta.h"

-static const char *TA_IF_FS_NAME = "ta_if";
-
-struct dentry *dir;
-static struct dentry *ta_load_debugfs_dentry;
-static struct dentry *ta_unload_debugfs_dentry;
-static struct dentry *ta_invoke_debugfs_dentry;
-
 static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf,
                                             size_t len, loff_t *off);
 static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf,
@@ -38,7 +31,6 @@ static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf,
 static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf,
                                             size_t len, loff_t *off);

-
 static uint32_t get_bin_version(const uint8_t *bin)
 {
         const struct common_firmware_header *hdr =
@@ -74,19 +66,19 @@ static bool is_ta_type_valid(enum ta_type_id ta_type)
 }

 static const struct file_operations ta_load_debugfs_fops = {
-       .write   = ta_if_load_debugfs_write,
+       .write  = ta_if_load_debugfs_write,
         .llseek = default_llseek,
         .owner  = THIS_MODULE
 };

 static const struct file_operations ta_unload_debugfs_fops = {
-       .write   = ta_if_unload_debugfs_write,
+       .write  = ta_if_unload_debugfs_write,
         .llseek = default_llseek,
         .owner  = THIS_MODULE
 };

 static const struct file_operations ta_invoke_debugfs_fops = {
-       .write   = ta_if_invoke_debugfs_write,
+       .write  = ta_if_invoke_debugfs_write,
         .llseek = default_llseek,
         .owner  = THIS_MODULE
 };
@@ -286,31 +278,20 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
         return ret;
 }

-static struct dentry *amdgpu_ta_if_debugfs_create(struct amdgpu_device *adev)
+void amdgpu_ta_if_debugfs_init(struct amdgpu_device *adev)
 {
+#if defined(CONFIG_DEBUG_FS)


         struct drm_minor *minor = adev_to_drm(adev)->primary;

-       dir = debugfs_create_dir(TA_IF_FS_NAME, minor->debugfs_root);
-
-       ta_load_debugfs_dentry = debugfs_create_file("ta_load", 0200, dir, adev,
-                                                    &ta_load_debugfs_fops);
+       struct dentry *dir = debugfs_create_dir("ta_if", minor->debugfs_root);

-       ta_unload_debugfs_dentry = debugfs_create_file("ta_unload", 0200, dir,
-                                                    adev, &ta_unload_debugfs_fops);
+       debugfs_create_file("ta_load", 0200, dir, adev,
+                                    &ta_load_debugfs_fops);

-       ta_invoke_debugfs_dentry = debugfs_create_file("ta_invoke", 0200, dir,
-                                                    adev, &ta_invoke_debugfs_fops);
-       return dir;
-}
+       debugfs_create_file("ta_unload", 0200, dir,
+                                    adev, &ta_unload_debugfs_fops);

[kevin]:

I think your patch is still have "defined but not used" warning,
because the ta_xxx_debugfs_fops are not used when the macro of CONFIG_DEBUG_FS is undefined.

It's better to add this macro check outside all functions.

Best Regards,
Kevin

-void amdgpu_ta_if_debugfs_init(struct amdgpu_device *adev)
-{
-#if defined(CONFIG_DEBUG_FS)
-       dir = amdgpu_ta_if_debugfs_create(adev);
+       debugfs_create_file("ta_invoke", 0200, dir,
+                                    adev, &ta_invoke_debugfs_fops);
 #endif
 }
-
-void amdgpu_ta_if_debugfs_remove(void)
-{
-       debugfs_remove_recursive(dir);
-}
--
2.17.1


[-- Attachment #2: Type: text/html, Size: 11469 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-27 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 11:22 [PATCH v2] drm/amdgpu: Fix build warning for TA debugfs interface Candice Li
2022-04-27 12:13 ` Wang, Yang(Kevin)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.