[PATCH 3/3] drm/amdgpu: clean up code to make it easier to understand

zhoucm1 david1.zhou at amd.com
Wed May 31 03:11:03 UTC 2017



On 2017年05月31日 05:47, Alex Xie wrote:
>   The original code convert pointer from amdgpu_crtc to
>   drm_crtc then later convert the pointer back.
>   It is difficult to understand why it was written
>   that way.
>
> Signed-off-by: Alex Xie <AlexBin.Xie at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 4dd83a3..7317fc9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -258,8 +258,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   		for (i = 0, found = 0; i < adev->mode_info.num_crtc; i++) {
>   			crtc = (struct drm_crtc *)minfo->crtcs[i];
>   			if (crtc && crtc->base.id == info->mode_crtc.id) {
> -				struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> -				ui32 = amdgpu_crtc->crtc_id;
> +				ui32 = minfo->crtcs[i]->crtc_id;
I feel previous code is more clear, it differentiates drm_crtc and 
amdgpu_crtc, which makes more clear for accessing their member.
If totally not convert, then we will see the below code, when we read 
the code, we will need to check struct amdgpu_mode_info, struct 
amdgpu_crtc and struct drm_crtc for condition line.
if (minfo->crtcs[i] && minfo->crtcs[i]->base.base.id == 
info->mode_crtc.id) {
     ui32 = minfo->crtcs[i]->crtc_id;


Regards,
David Zhou
>   				found = 1;
>   				break;
>   			}



More information about the amd-gfx mailing list