[PATCH] drm/amdgpu: Replace ternary operator with min() in 'amdgpu_iomem_read'

Christian König christian.koenig at amd.com
Mon Aug 14 09:15:39 UTC 2023


Am 12.08.23 um 16:47 schrieb Srinivasan Shanmugam:
> Fixes the following coccicheck:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2427:16-17: WARNING opportunity for min()
>
> min() macro is defined in include/linux/minmax.h. It avoids multiple
> evaluations of the arguments when non-constant and performs strict
> type-checking.
>
> Cc: Guchun Chen <guchun.chen at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>

Please double check that we don't need min_t() here.

With that done this patch and the _write variant are Reviewed-by: 
Christian König <christian.koenig at amd.com>.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index df32785a8b36..c03fe7ee555b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2424,7 +2424,7 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
>   		struct page *p;
>   		void *ptr;
>   
> -		bytes = bytes < size ? bytes : size;
> +		bytes = min(bytes, size);
>   
>   		/* Translate the bus address to a physical address.  If
>   		 * the domain is NULL it means there is no IOMMU active



More information about the amd-gfx mailing list