diff mbox series

[-next,2/2] drm/tegra: Use PTR_ERR_OR_ZERO() to simplify code

Message ID 20230822071503.178000-3-ruanjinjie@huawei.com
State Rejected
Headers show
Series drm: Use PTR_ERR_OR_ZERO() to simplify code | expand

Commit Message

Jinjie Ruan Aug. 22, 2023, 7:15 a.m. UTC
Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
simplify code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/gpu/drm/tegra/drm.c | 5 +----
 drivers/gpu/drm/tegra/gem.c | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)

Comments

Mikko Perttunen Aug. 22, 2023, 12:32 p.m. UTC | #1
On 8/22/23 10:15, Jinjie Ruan wrote:
> Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
> simplify code.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>   drivers/gpu/drm/tegra/drm.c | 5 +----
>   drivers/gpu/drm/tegra/gem.c | 5 +----
>   2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index ff36171c8fb7..4e29d76da1be 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -354,10 +354,7 @@ static int tegra_gem_create(struct drm_device *drm, void *data,
>   
>   	bo = tegra_bo_create_with_handle(file, drm, args->size, args->flags,
>   					 &args->handle);
> -	if (IS_ERR(bo))
> -		return PTR_ERR(bo);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(bo);
>   }
>   
>   static int tegra_gem_mmap(struct drm_device *drm, void *data,
> diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
> index a4023163493d..11ef0f8cb1e1 100644
> --- a/drivers/gpu/drm/tegra/gem.c
> +++ b/drivers/gpu/drm/tegra/gem.c
> @@ -533,10 +533,7 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
>   
>   	bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
>   					 &args->handle);
> -	if (IS_ERR(bo))
> -		return PTR_ERR(bo);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(bo);
>   }
>   
>   static vm_fault_t tegra_bo_fault(struct vm_fault *vmf)

NAK. See 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20230822&id=b784c77075023e1a71bc06e6b4f711acb99e9c73

Mikko
Jinjie Ruan Aug. 22, 2023, 12:43 p.m. UTC | #2
On 2023/8/22 20:32, Mikko Perttunen wrote:
> On 8/22/23 10:15, Jinjie Ruan wrote:
>> Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
>> simplify code.
>>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>>   drivers/gpu/drm/tegra/drm.c | 5 +----
>>   drivers/gpu/drm/tegra/gem.c | 5 +----
>>   2 files changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
>> index ff36171c8fb7..4e29d76da1be 100644
>> --- a/drivers/gpu/drm/tegra/drm.c
>> +++ b/drivers/gpu/drm/tegra/drm.c
>> @@ -354,10 +354,7 @@ static int tegra_gem_create(struct drm_device
>> *drm, void *data,
>>         bo = tegra_bo_create_with_handle(file, drm, args->size,
>> args->flags,
>>                        &args->handle);
>> -    if (IS_ERR(bo))
>> -        return PTR_ERR(bo);
>> -
>> -    return 0;
>> +    return PTR_ERR_OR_ZERO(bo);
>>   }
>>     static int tegra_gem_mmap(struct drm_device *drm, void *data,
>> diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
>> index a4023163493d..11ef0f8cb1e1 100644
>> --- a/drivers/gpu/drm/tegra/gem.c
>> +++ b/drivers/gpu/drm/tegra/gem.c
>> @@ -533,10 +533,7 @@ int tegra_bo_dumb_create(struct drm_file *file,
>> struct drm_device *drm,
>>         bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
>>                        &args->handle);
>> -    if (IS_ERR(bo))
>> -        return PTR_ERR(bo);
>> -
>> -    return 0;
>> +    return PTR_ERR_OR_ZERO(bo);
>>   }
>>     static vm_fault_t tegra_bo_fault(struct vm_fault *vmf)
> 
> NAK. See
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20230822&id=b784c77075023e1a71bc06e6b4f711acb99e9c73

Thank you! It is right.

> 
> Mikko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index ff36171c8fb7..4e29d76da1be 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -354,10 +354,7 @@  static int tegra_gem_create(struct drm_device *drm, void *data,
 
 	bo = tegra_bo_create_with_handle(file, drm, args->size, args->flags,
 					 &args->handle);
-	if (IS_ERR(bo))
-		return PTR_ERR(bo);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(bo);
 }
 
 static int tegra_gem_mmap(struct drm_device *drm, void *data,
diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index a4023163493d..11ef0f8cb1e1 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -533,10 +533,7 @@  int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
 
 	bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
 					 &args->handle);
-	if (IS_ERR(bo))
-		return PTR_ERR(bo);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(bo);
 }
 
 static vm_fault_t tegra_bo_fault(struct vm_fault *vmf)