[PATCH 38/38] drm/radeon: simplify boot level calculation

Andrzej Hajda a.hajda at samsung.com
Mon Sep 21 06:34:10 PDT 2015


The patch simplifies the code without changing behaviour, but most
problably there is a bug somewhere else.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda at samsung.com>
---
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 11 +----------
 drivers/gpu/drm/radeon/kv_dpm.c     | 11 +----------
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index 94ec04a..f9cfc56 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -1622,19 +1622,10 @@ static int kv_update_samu_dpm(struct amdgpu_device *adev, bool gate)
 
 static u8 kv_get_acp_boot_level(struct amdgpu_device *adev)
 {
-	u8 i;
 	struct amdgpu_clock_voltage_dependency_table *table =
 		&adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table;
 
-	for (i = 0; i < table->count; i++) {
-		if (table->entries[i].clk >= 0) /* XXX */
-			break;
-	}
-
-	if (i >= table->count)
-		i = table->count - 1;
-
-	return i;
+	return table->count ? 0 : -1;
 }
 
 static void kv_update_acp_boot_level(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 2d71da4..dc9aab5 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -1546,19 +1546,10 @@ static int kv_update_samu_dpm(struct radeon_device *rdev, bool gate)
 
 static u8 kv_get_acp_boot_level(struct radeon_device *rdev)
 {
-	u8 i;
 	struct radeon_clock_voltage_dependency_table *table =
 		&rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table;
 
-	for (i = 0; i < table->count; i++) {
-		if (table->entries[i].clk >= 0) /* XXX */
-			break;
-	}
-
-	if (i >= table->count)
-		i = table->count - 1;
-
-	return i;
+	return table->count ? 0 : -1;
 }
 
 static void kv_update_acp_boot_level(struct radeon_device *rdev)
-- 
1.9.1



More information about the dri-devel mailing list