diff mbox

drm/amd/display/dc/dce110/dce110_mem_input_v: use swap macro in program_size_and_rotation

Message ID 20171110223109.GA31549@embeddedor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gustavo A. R. Silva Nov. 10, 2017, 10:31 p.m. UTC
Make use of the swap macro instead of _manually_ swapping values
and remove unnecessary variable swap.

This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 .../drm/amd/display/dc/dce110/dce110_mem_input_v.c | 28 +++++++---------------
 1 file changed, 8 insertions(+), 20 deletions(-)

Comments

Harry Wentland Nov. 17, 2017, 3:45 p.m. UTC | #1
On 2017-11-10 05:31 PM, Gustavo A. R. Silva wrote:
> Make use of the swap macro instead of _manually_ swapping values
> and remove unnecessary variable swap.
> 
> This makes the code easier to read and maintain.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  .../drm/amd/display/dc/dce110/dce110_mem_input_v.c | 28 +++++++---------------
>  1 file changed, 8 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
> index a06c602..7bab8c6 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
> @@ -237,26 +237,14 @@ static void program_size_and_rotation(
>  	if (rotation == ROTATION_ANGLE_90 ||
>  		rotation == ROTATION_ANGLE_270) {
>  
> -		uint32_t swap;
> -		swap = local_size.video.luma_size.x;
> -		local_size.video.luma_size.x =
> -			local_size.video.luma_size.y;
> -		local_size.video.luma_size.y  = swap;
> -
> -		swap = local_size.video.luma_size.width;
> -		local_size.video.luma_size.width =
> -			local_size.video.luma_size.height;
> -		local_size.video.luma_size.height = swap;
> -
> -		swap = local_size.video.chroma_size.x;
> -		local_size.video.chroma_size.x =
> -			local_size.video.chroma_size.y;
> -		local_size.video.chroma_size.y  = swap;
> -
> -		swap = local_size.video.chroma_size.width;
> -		local_size.video.chroma_size.width =
> -			local_size.video.chroma_size.height;
> -		local_size.video.chroma_size.height = swap;
> +		swap(local_size.video.luma_size.x,
> +		     local_size.video.luma_size.y);
> +		swap(local_size.video.luma_size.width,
> +		     local_size.video.luma_size.height);
> +		swap(local_size.video.chroma_size.x,
> +		     local_size.video.chroma_size.y);
> +		swap(local_size.video.chroma_size.width,
> +		     local_size.video.chroma_size.height);
>  	}
>  
>  	value = 0;
>
Gustavo A. R. Silva Nov. 20, 2017, 5:25 a.m. UTC | #2
Quoting Harry Wentland <harry.wentland@amd.com>:

> On 2017-11-10 05:31 PM, Gustavo A. R. Silva wrote:
>> Make use of the swap macro instead of _manually_ swapping values
>> and remove unnecessary variable swap.
>>
>> This makes the code easier to read and maintain.
>>
>> This code was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>

Thank you, Harry.

--
Gustavo A. R. Silva
diff mbox

Patch

diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
index a06c602..7bab8c6 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
@@ -237,26 +237,14 @@  static void program_size_and_rotation(
 	if (rotation == ROTATION_ANGLE_90 ||
 		rotation == ROTATION_ANGLE_270) {
 
-		uint32_t swap;
-		swap = local_size.video.luma_size.x;
-		local_size.video.luma_size.x =
-			local_size.video.luma_size.y;
-		local_size.video.luma_size.y  = swap;
-
-		swap = local_size.video.luma_size.width;
-		local_size.video.luma_size.width =
-			local_size.video.luma_size.height;
-		local_size.video.luma_size.height = swap;
-
-		swap = local_size.video.chroma_size.x;
-		local_size.video.chroma_size.x =
-			local_size.video.chroma_size.y;
-		local_size.video.chroma_size.y  = swap;
-
-		swap = local_size.video.chroma_size.width;
-		local_size.video.chroma_size.width =
-			local_size.video.chroma_size.height;
-		local_size.video.chroma_size.height = swap;
+		swap(local_size.video.luma_size.x,
+		     local_size.video.luma_size.y);
+		swap(local_size.video.luma_size.width,
+		     local_size.video.luma_size.height);
+		swap(local_size.video.chroma_size.x,
+		     local_size.video.chroma_size.y);
+		swap(local_size.video.chroma_size.width,
+		     local_size.video.chroma_size.height);
 	}
 
 	value = 0;