diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2017-02-22 02:33:46 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:53:41 -0400 |
commit | c722865a19f97aa9f56aaa8665f87cbf1dbaf96a (patch) | |
tree | 8b518e2abc23bee791a6069c2922627f3fb6d1b8 /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |
parent | 5463545b9280093f4614049df2dfee3f9e662172 (diff) |
drm/amdgpu: check function points valid before use. (v3)
v2: agd: integrate Christian's comments.
v3: print error message if call fails
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index ff0b9920ea79..a70247203f18 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1191,13 +1191,15 @@ int amdgpu_set_clockgating_state(struct amdgpu_device *adev, | |||
1191 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1191 | for (i = 0; i < adev->num_ip_blocks; i++) { |
1192 | if (!adev->ip_blocks[i].status.valid) | 1192 | if (!adev->ip_blocks[i].status.valid) |
1193 | continue; | 1193 | continue; |
1194 | if (adev->ip_blocks[i].version->type == block_type) { | 1194 | if (adev->ip_blocks[i].version->type != block_type) |
1195 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | 1195 | continue; |
1196 | state); | 1196 | if (!adev->ip_blocks[i].version->funcs->set_clockgating_state) |
1197 | if (r) | 1197 | continue; |
1198 | return r; | 1198 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state( |
1199 | break; | 1199 | (void *)adev, state); |
1200 | } | 1200 | if (r) |
1201 | DRM_ERROR("set_clockgating_state of IP block <%s> failed %d\n", | ||
1202 | adev->ip_blocks[i].version->funcs->name, r); | ||
1201 | } | 1203 | } |
1202 | return r; | 1204 | return r; |
1203 | } | 1205 | } |
@@ -1211,13 +1213,15 @@ int amdgpu_set_powergating_state(struct amdgpu_device *adev, | |||
1211 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1213 | for (i = 0; i < adev->num_ip_blocks; i++) { |
1212 | if (!adev->ip_blocks[i].status.valid) | 1214 | if (!adev->ip_blocks[i].status.valid) |
1213 | continue; | 1215 | continue; |
1214 | if (adev->ip_blocks[i].version->type == block_type) { | 1216 | if (adev->ip_blocks[i].version->type != block_type) |
1215 | r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev, | 1217 | continue; |
1216 | state); | 1218 | if (!adev->ip_blocks[i].version->funcs->set_powergating_state) |
1217 | if (r) | 1219 | continue; |
1218 | return r; | 1220 | r = adev->ip_blocks[i].version->funcs->set_powergating_state( |
1219 | break; | 1221 | (void *)adev, state); |
1220 | } | 1222 | if (r) |
1223 | DRM_ERROR("set_powergating_state of IP block <%s> failed %d\n", | ||
1224 | adev->ip_blocks[i].version->funcs->name, r); | ||
1221 | } | 1225 | } |
1222 | return r; | 1226 | return r; |
1223 | } | 1227 | } |