mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: use swap() in is_config_schedulable()
@ 2024-06-24  1:57 Jiapeng Chong
  2024-06-24 14:55 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-06-24  1:57 UTC (permalink / raw)
  To: harry.wentland
  Cc: sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, daniel, amd-gfx,
	dri-devel, linux-kernel, Jiapeng Chong, Abaci Robot

Use existing swap() function rather than duplicating its implementation.

./drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c:1171:103-104: WARNING opportunity for swap().
./drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c:1231:99-100: WARNING opportunity for swap().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9400
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 .../dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c  | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c b/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
index 7272a04b9d1d..926d45496e79 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
@@ -1158,7 +1158,6 @@ static bool is_config_schedulable(
 	schedulable = true;
 
 	/* sort disallow times from greatest to least */
-	unsigned int temp;
 	for (i = 0; i < s->pmo_dcn4.num_timing_groups; i++) {
 		bool swapped = false;
 
@@ -1167,9 +1166,8 @@ static bool is_config_schedulable(
 			double jp1_disallow_us = s->pmo_dcn4.group_common_fams2_meta[s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1]].disallow_time_us;
 			if (j_disallow_us < jp1_disallow_us) {
 				/* swap as A < B */
-				temp = s->pmo_dcn4.sorted_group_gtl_disallow_index[j];
-				s->pmo_dcn4.sorted_group_gtl_disallow_index[j] = s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1];
-				s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1] = temp;
+				swap(s->pmo_dcn4.sorted_group_gtl_disallow_index[j],
+				     s->pmo_dcn4.sorted_group_gtl_disallow_index[j+1]);
 				swapped = true;
 			}
 		}
@@ -1227,9 +1225,8 @@ static bool is_config_schedulable(
 			double jp1_period_us = s->pmo_dcn4.group_common_fams2_meta[s->pmo_dcn4.sorted_group_gtl_period_index[j + 1]].period_us;
 			if (j_period_us < jp1_period_us) {
 				/* swap as A < B */
-				temp = s->pmo_dcn4.sorted_group_gtl_period_index[j];
-				s->pmo_dcn4.sorted_group_gtl_period_index[j] = s->pmo_dcn4.sorted_group_gtl_period_index[j + 1];
-				s->pmo_dcn4.sorted_group_gtl_period_index[j + 1] = temp;
+				swap(s->pmo_dcn4.sorted_group_gtl_period_index[j],
+				     s->pmo_dcn4.sorted_group_gtl_period_index[j+1]);
 				swapped = true;
 			}
 		}
-- 
2.20.1.7.g153144c


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

* Re: [PATCH] drm/amd/display: use swap() in is_config_schedulable()
  2024-06-24  1:57 [PATCH] drm/amd/display: use swap() in is_config_schedulable() Jiapeng Chong
@ 2024-06-24 14:55 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2024-06-24 14:55 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, daniel, amd-gfx,
	dri-devel, linux-kernel, Abaci Robot

Applied.  Thanks!

Alex

On Sun, Jun 23, 2024 at 10:22 PM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> Use existing swap() function rather than duplicating its implementation.
>
> ./drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c:1171:103-104: WARNING opportunity for swap().
> ./drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c:1231:99-100: WARNING opportunity for swap().
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9400
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  .../dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c  | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c b/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
> index 7272a04b9d1d..926d45496e79 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
> @@ -1158,7 +1158,6 @@ static bool is_config_schedulable(
>         schedulable = true;
>
>         /* sort disallow times from greatest to least */
> -       unsigned int temp;
>         for (i = 0; i < s->pmo_dcn4.num_timing_groups; i++) {
>                 bool swapped = false;
>
> @@ -1167,9 +1166,8 @@ static bool is_config_schedulable(
>                         double jp1_disallow_us = s->pmo_dcn4.group_common_fams2_meta[s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1]].disallow_time_us;
>                         if (j_disallow_us < jp1_disallow_us) {
>                                 /* swap as A < B */
> -                               temp = s->pmo_dcn4.sorted_group_gtl_disallow_index[j];
> -                               s->pmo_dcn4.sorted_group_gtl_disallow_index[j] = s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1];
> -                               s->pmo_dcn4.sorted_group_gtl_disallow_index[j + 1] = temp;
> +                               swap(s->pmo_dcn4.sorted_group_gtl_disallow_index[j],
> +                                    s->pmo_dcn4.sorted_group_gtl_disallow_index[j+1]);
>                                 swapped = true;
>                         }
>                 }
> @@ -1227,9 +1225,8 @@ static bool is_config_schedulable(
>                         double jp1_period_us = s->pmo_dcn4.group_common_fams2_meta[s->pmo_dcn4.sorted_group_gtl_period_index[j + 1]].period_us;
>                         if (j_period_us < jp1_period_us) {
>                                 /* swap as A < B */
> -                               temp = s->pmo_dcn4.sorted_group_gtl_period_index[j];
> -                               s->pmo_dcn4.sorted_group_gtl_period_index[j] = s->pmo_dcn4.sorted_group_gtl_period_index[j + 1];
> -                               s->pmo_dcn4.sorted_group_gtl_period_index[j + 1] = temp;
> +                               swap(s->pmo_dcn4.sorted_group_gtl_period_index[j],
> +                                    s->pmo_dcn4.sorted_group_gtl_period_index[j+1]);
>                                 swapped = true;
>                         }
>                 }
> --
> 2.20.1.7.g153144c
>

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

end of thread, other threads:[~2024-06-24 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24  1:57 [PATCH] drm/amd/display: use swap() in is_config_schedulable() Jiapeng Chong
2024-06-24 14:55 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®