linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/radeon/ci_dpm: Use int type to store negative error codes
@ 2025-09-03 12:21 Qianfeng Rong
  2025-09-03 14:41 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Qianfeng Rong @ 2025-09-03 12:21 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	amd-gfx, dri-devel, linux-kernel
  Cc: Qianfeng Rong

Change the 'ret' variable in ci_populate_all_graphic_levels()
and ci_populate_all_memory_levels() from u32 to int, as it needs to store
either negative error codes or zero returned by other functions.

Storing the negative error codes in unsigned type, doesn't cause an issue
at runtime but can be confusing.  Additionally, assigning negative error
codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
flag is enabled.

No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/gpu/drm/radeon/ci_dpm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index 7c3a960f486a..1f9f4424055a 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -3238,7 +3238,8 @@ static int ci_populate_all_graphic_levels(struct radeon_device *rdev)
 	u32 level_array_size = sizeof(SMU7_Discrete_GraphicsLevel) *
 		SMU7_MAX_LEVELS_GRAPHICS;
 	SMU7_Discrete_GraphicsLevel *levels = pi->smc_state_table.GraphicsLevel;
-	u32 i, ret;
+	int ret;
+	u32 i;
 
 	memset(levels, 0, level_array_size);
 
@@ -3285,7 +3286,8 @@ static int ci_populate_all_memory_levels(struct radeon_device *rdev)
 	u32 level_array_size = sizeof(SMU7_Discrete_MemoryLevel) *
 		SMU7_MAX_LEVELS_MEMORY;
 	SMU7_Discrete_MemoryLevel *levels = pi->smc_state_table.MemoryLevel;
-	u32 i, ret;
+	int ret;
+	u32 i;
 
 	memset(levels, 0, level_array_size);
 
-- 
2.34.1


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

* Re: [PATCH] drm/radeon/ci_dpm: Use int type to store negative error codes
  2025-09-03 12:21 [PATCH] drm/radeon/ci_dpm: Use int type to store negative error codes Qianfeng Rong
@ 2025-09-03 14:41 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2025-09-03 14:41 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	amd-gfx, dri-devel, linux-kernel

Applied.  Thanks!

Alex

On Wed, Sep 3, 2025 at 8:59 AM Qianfeng Rong <rongqianfeng@vivo.com> wrote:
>
> Change the 'ret' variable in ci_populate_all_graphic_levels()
> and ci_populate_all_memory_levels() from u32 to int, as it needs to store
> either negative error codes or zero returned by other functions.
>
> Storing the negative error codes in unsigned type, doesn't cause an issue
> at runtime but can be confusing.  Additionally, assigning negative error
> codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
> flag is enabled.
>
> No effect on runtime.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
>  drivers/gpu/drm/radeon/ci_dpm.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
> index 7c3a960f486a..1f9f4424055a 100644
> --- a/drivers/gpu/drm/radeon/ci_dpm.c
> +++ b/drivers/gpu/drm/radeon/ci_dpm.c
> @@ -3238,7 +3238,8 @@ static int ci_populate_all_graphic_levels(struct radeon_device *rdev)
>         u32 level_array_size = sizeof(SMU7_Discrete_GraphicsLevel) *
>                 SMU7_MAX_LEVELS_GRAPHICS;
>         SMU7_Discrete_GraphicsLevel *levels = pi->smc_state_table.GraphicsLevel;
> -       u32 i, ret;
> +       int ret;
> +       u32 i;
>
>         memset(levels, 0, level_array_size);
>
> @@ -3285,7 +3286,8 @@ static int ci_populate_all_memory_levels(struct radeon_device *rdev)
>         u32 level_array_size = sizeof(SMU7_Discrete_MemoryLevel) *
>                 SMU7_MAX_LEVELS_MEMORY;
>         SMU7_Discrete_MemoryLevel *levels = pi->smc_state_table.MemoryLevel;
> -       u32 i, ret;
> +       int ret;
> +       u32 i;
>
>         memset(levels, 0, level_array_size);
>
> --
> 2.34.1
>

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

end of thread, other threads:[~2025-09-03 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 12:21 [PATCH] drm/radeon/ci_dpm: Use int type to store negative error codes Qianfeng Rong
2025-09-03 14:41 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).