[2/3] drm/amdgpu: Remove two ! operations in an if condition

Submitted by Xie, AlexBin on May 30, 2017, 9:47 p.m.

Details

Message ID 1496180868-2617-2-git-send-email-AlexBin.Xie@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Xie, AlexBin May 30, 2017, 9:47 p.m.
Make the code easier to understand.

Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 7a323f9..9fdeb82 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -680,9 +680,11 @@  bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
 
 	if (amdgpu_vm_had_gpu_reset(adev, id))
 		return true;
-	if (!vm_flush_needed && !gds_switch_needed)
+
+	if (vm_flush_needed || gds_switch_needed)
+		return true;
+	else
 		return false;
-	return true;
 }
 
 /**

Comments

On 2017年05月31日 05:47, Alex Xie wrote:
>   Make the code easier to understand.
>
> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
ok to me, Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 7a323f9..9fdeb82 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -680,9 +680,11 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
>   
>   	if (amdgpu_vm_had_gpu_reset(adev, id))
>   		return true;
> -	if (!vm_flush_needed && !gds_switch_needed)
> +
> +	if (vm_flush_needed || gds_switch_needed)
> +		return true;
> +	else
>   		return false;
> -	return true;
>   }
>   
>   /**
On 31/05/17 06:47 AM, Alex Xie wrote:
>  Make the code easier to understand.
> 
> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 7a323f9..9fdeb82 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -680,9 +680,11 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
>  
>  	if (amdgpu_vm_had_gpu_reset(adev, id))
>  		return true;
> -	if (!vm_flush_needed && !gds_switch_needed)
> +
> +	if (vm_flush_needed || gds_switch_needed)
> +		return true;
> +	else
>  		return false;

This can be further simplified to

	return vm_flush_needed || gds_switch_needed;

With that,

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Am 30.05.2017 um 23:47 schrieb Alex Xie:
>   Make the code easier to understand.
>
> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 7a323f9..9fdeb82 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -680,9 +680,11 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
>   
>   	if (amdgpu_vm_had_gpu_reset(adev, id))
>   		return true;
> -	if (!vm_flush_needed && !gds_switch_needed)
> +
> +	if (vm_flush_needed || gds_switch_needed)
> +		return true;
> +	else
>   		return false;
> -	return true;

Actually that should even use the canonical form, e.g. something like 
"return vm_flush_needed || gds_switch_needed;".

Apart from that looks good to me,
Christian.

>   }
>   
>   /**