[PATCH 11/23] drm/amdgpu: check function points valid before use.

Christian König deathsimple at vodafone.de
Thu Mar 9 10:07:22 UTC 2017


Am 09.03.2017 um 04:44 schrieb Alex Deucher:
> From: Rex Zhu <Rex.Zhu at amd.com>
>
> Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 78b3b0b..5854357 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1191,9 +1191,10 @@ int amdgpu_set_clockgating_state(struct amdgpu_device *adev,
>   	for (i = 0; i < adev->num_ip_blocks; i++) {
>   		if (!adev->ip_blocks[i].status.valid)
>   			continue;
> -		if (adev->ip_blocks[i].version->type == block_type) {
> -			r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev,
> -										     state);
> +		if (adev->ip_blocks[i].version->type == block_type &&
> +			adev->ip_blocks[i].version->funcs->set_clockgating_state) {

Could be my mail client, but the indentation doesn't looks correct here.

Additional to that checking that as prerequisites would be easier to 
read I think, e.g. coding it like this:

if (adev->ip_blocks[i].version->type != block_type)
     continue;

if (!adev->ip_blocks[i].version->funcs->set_clockgating_state)
     continue;

Regards,
Christian.

> +			r = adev->ip_blocks[i].version->funcs->set_clockgating_state(
> +							(void *)adev, state);
>   			if (r)
>   				return r;
>   			break;
> @@ -1211,9 +1212,10 @@ int amdgpu_set_powergating_state(struct amdgpu_device *adev,
>   	for (i = 0; i < adev->num_ip_blocks; i++) {
>   		if (!adev->ip_blocks[i].status.valid)
>   			continue;
> -		if (adev->ip_blocks[i].version->type == block_type) {
> -			r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev,
> -										     state);
> +		if (adev->ip_blocks[i].version->type == block_type &&
> +			adev->ip_blocks[i].version->funcs->set_powergating_state) {
> +			r = adev->ip_blocks[i].version->funcs->set_powergating_state(
> +							(void *)adev, state);
>   			if (r)
>   				return r;
>   			break;




More information about the amd-gfx mailing list