All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amdgpu_dm: no need to check return value of debugfs_create functions
@ 2019-06-13 13:20 Greg Kroah-Hartman
       [not found] ` <20190613132012.GC3432-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-13 13:20 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter
  Cc: Bhawanpreet Lakha, David Francis, amd-gfx, hersen wu, dri-devel,
	Leo (Hanghong) Ma, Anthony Koo, Nicholas Kazlauskas

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Cc: David Francis <David.Francis@amd.com>
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Cc: Anthony Koo <Anthony.Koo@amd.com>
Cc: hersen wu <hersenxs.wu@amd.com>
Cc: "Leo (Hanghong) Ma" <hanghong.ma@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 35 ++++++-------------
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 +-
 3 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bcb1a93c0b4c..cd10b0825087 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4825,11 +4825,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
 
 	drm_connector_register(&aconnector->base);
 #if defined(CONFIG_DEBUG_FS)
-	res = connector_debugfs_init(aconnector);
-	if (res) {
-		DRM_ERROR("Failed to create debugfs for connector");
-		goto out_free;
-	}
+	connector_debugfs_init(aconnector);
 	aconnector->debugfs_dpcd_address = 0;
 	aconnector->debugfs_dpcd_size = 0;
 #endif
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 1d5fc5ad3bee..2b9ea1b67c9a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -873,25 +873,19 @@ static const struct {
 		{"aux_dpcd_data", &dp_dpcd_data_debugfs_fops}
 };
 
-int connector_debugfs_init(struct amdgpu_dm_connector *connector)
+void connector_debugfs_init(struct amdgpu_dm_connector *connector)
 {
 	int i;
-	struct dentry *ent, *dir = connector->base.debugfs_entry;
+	struct dentry *dir = connector->base.debugfs_entry;
 
 	if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
 	    connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
 		for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
-			ent = debugfs_create_file(dp_debugfs_entries[i].name,
-						  0644,
-						  dir,
-						  connector,
-						  dp_debugfs_entries[i].fops);
-			if (IS_ERR(ent))
-				return PTR_ERR(ent);
+			debugfs_create_file(dp_debugfs_entries[i].name,
+					    0644, dir, connector,
+					    dp_debugfs_entries[i].fops);
 		}
 	}
-
-	return 0;
 }
 
 /*
@@ -1034,7 +1028,7 @@ int dtn_debugfs_init(struct amdgpu_device *adev)
 	};
 
 	struct drm_minor *minor = adev->ddev->primary;
-	struct dentry *ent, *root = minor->debugfs_root;
+	struct dentry *root = minor->debugfs_root;
 	int ret;
 
 	ret = amdgpu_debugfs_add_files(adev, amdgpu_dm_debugfs_list,
@@ -1042,20 +1036,11 @@ int dtn_debugfs_init(struct amdgpu_device *adev)
 	if (ret)
 		return ret;
 
-	ent = debugfs_create_file(
-		"amdgpu_dm_dtn_log",
-		0644,
-		root,
-		adev,
-		&dtn_log_fops);
-
-	if (IS_ERR(ent))
-		return PTR_ERR(ent);
+	debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
+			    &dtn_log_fops);
 
-	ent = debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root,
-					 adev, &visual_confirm_fops);
-	if (IS_ERR(ent))
-		return PTR_ERR(ent);
+	debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root, adev,
+				   &visual_confirm_fops);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
index bdef1587b0a0..5e5b2b2afa31 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
@@ -29,7 +29,7 @@
 #include "amdgpu.h"
 #include "amdgpu_dm.h"
 
-int connector_debugfs_init(struct amdgpu_dm_connector *connector);
+void connector_debugfs_init(struct amdgpu_dm_connector *connector);
 int dtn_debugfs_init(struct amdgpu_device *adev);
 
 #endif
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] amdgpu_dm: no need to check return value of debugfs_create functions
       [not found] ` <20190613132012.GC3432-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2019-06-13 13:35   ` Kazlauskas, Nicholas
  0 siblings, 0 replies; 2+ messages in thread
From: Kazlauskas, Nicholas @ 2019-06-13 13:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zhou, David(ChunMing)
  Cc: Mario Kleiner, Li, Sun peng (Leo), Lakha, Bhawanpreet,
	Francis, David,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	David Airlie, Wu, Hersen,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Daniel Vetter, Deucher, Alexander, Ma, Hanghong, Wentland, Harry,
	Koenig, Christian, Koo, Anthony

On 6/13/19 9:20 AM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> Cc: David Francis <David.Francis@amd.com>
> Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
> Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
> Cc: Anthony Koo <Anthony.Koo@amd.com>
> Cc: hersen wu <hersenxs.wu@amd.com>
> Cc: "Leo (Hanghong) Ma" <hanghong.ma@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>

I'll keep this in mind when we're adding more of these entries - the 
functions do seem to check internally, so this makes the code a little 
simpler.

Thanks!

Nicholas Kazlauskas

> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +---
>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 35 ++++++-------------
>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 +-
>   3 files changed, 12 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index bcb1a93c0b4c..cd10b0825087 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4825,11 +4825,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
>   
>   	drm_connector_register(&aconnector->base);
>   #if defined(CONFIG_DEBUG_FS)
> -	res = connector_debugfs_init(aconnector);
> -	if (res) {
> -		DRM_ERROR("Failed to create debugfs for connector");
> -		goto out_free;
> -	}
> +	connector_debugfs_init(aconnector);
>   	aconnector->debugfs_dpcd_address = 0;
>   	aconnector->debugfs_dpcd_size = 0;
>   #endif
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index 1d5fc5ad3bee..2b9ea1b67c9a 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -873,25 +873,19 @@ static const struct {
>   		{"aux_dpcd_data", &dp_dpcd_data_debugfs_fops}
>   };
>   
> -int connector_debugfs_init(struct amdgpu_dm_connector *connector)
> +void connector_debugfs_init(struct amdgpu_dm_connector *connector)
>   {
>   	int i;
> -	struct dentry *ent, *dir = connector->base.debugfs_entry;
> +	struct dentry *dir = connector->base.debugfs_entry;
>   
>   	if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
>   	    connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
>   		for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
> -			ent = debugfs_create_file(dp_debugfs_entries[i].name,
> -						  0644,
> -						  dir,
> -						  connector,
> -						  dp_debugfs_entries[i].fops);
> -			if (IS_ERR(ent))
> -				return PTR_ERR(ent);
> +			debugfs_create_file(dp_debugfs_entries[i].name,
> +					    0644, dir, connector,
> +					    dp_debugfs_entries[i].fops);
>   		}
>   	}
> -
> -	return 0;
>   }
>   
>   /*
> @@ -1034,7 +1028,7 @@ int dtn_debugfs_init(struct amdgpu_device *adev)
>   	};
>   
>   	struct drm_minor *minor = adev->ddev->primary;
> -	struct dentry *ent, *root = minor->debugfs_root;
> +	struct dentry *root = minor->debugfs_root;
>   	int ret;
>   
>   	ret = amdgpu_debugfs_add_files(adev, amdgpu_dm_debugfs_list,
> @@ -1042,20 +1036,11 @@ int dtn_debugfs_init(struct amdgpu_device *adev)
>   	if (ret)
>   		return ret;
>   
> -	ent = debugfs_create_file(
> -		"amdgpu_dm_dtn_log",
> -		0644,
> -		root,
> -		adev,
> -		&dtn_log_fops);
> -
> -	if (IS_ERR(ent))
> -		return PTR_ERR(ent);
> +	debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
> +			    &dtn_log_fops);
>   
> -	ent = debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root,
> -					 adev, &visual_confirm_fops);
> -	if (IS_ERR(ent))
> -		return PTR_ERR(ent);
> +	debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root, adev,
> +				   &visual_confirm_fops);
>   
>   	return 0;
>   }
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> index bdef1587b0a0..5e5b2b2afa31 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> @@ -29,7 +29,7 @@
>   #include "amdgpu.h"
>   #include "amdgpu_dm.h"
>   
> -int connector_debugfs_init(struct amdgpu_dm_connector *connector);
> +void connector_debugfs_init(struct amdgpu_dm_connector *connector);
>   int dtn_debugfs_init(struct amdgpu_device *adev);
>   
>   #endif
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2019-06-13 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-13 13:20 [PATCH] amdgpu_dm: no need to check return value of debugfs_create functions Greg Kroah-Hartman
     [not found] ` <20190613132012.GC3432-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2019-06-13 13:35   ` Kazlauskas, Nicholas

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.