Commit ee78ef04 authored by Darren Powell's avatar Darren Powell Committed by Alex Deucher

amdgpu/pm: Optimize emit_clock_levels for arcturus - part 2

 Use variables to remove ternary expression in print statement and
 improve readability. This will help to optimize the code duplication
 in the switch statement
 Also Changed:
  replaced single_dpm_table->count as iterator in for loops with safer
    clocks_num_levels value
  replaced dpm_table.value usage with local var clocks_mhz
Signed-off-by: default avatarDarren Powell <darren.powell@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f72dcf8b
...@@ -794,11 +794,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -794,11 +794,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", i, *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
clock_mhz, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -815,11 +815,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -815,11 +815,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, clock_mhz, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -836,11 +836,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -836,11 +836,11 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, clock_mhz, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -854,14 +854,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -854,14 +854,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.fclk_table); single_dpm_table = &(dpm_context->dpm_tables.fclk_table);
arcturus_get_clk_table(smu, &clocks, single_dpm_table); arcturus_get_clk_table(smu, &clocks, single_dpm_table);
for (i = 0; i < single_dpm_table->count; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -875,14 +875,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -875,14 +875,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.vclk_table); single_dpm_table = &(dpm_context->dpm_tables.vclk_table);
arcturus_get_clk_table(smu, &clocks, single_dpm_table); arcturus_get_clk_table(smu, &clocks, single_dpm_table);
for (i = 0; i < single_dpm_table->count; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -896,14 +896,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -896,14 +896,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.dclk_table); single_dpm_table = &(dpm_context->dpm_tables.dclk_table);
arcturus_get_clk_table(smu, &clocks, single_dpm_table); arcturus_get_clk_table(smu, &clocks, single_dpm_table);
for (i = 0; i < single_dpm_table->count; i++) { for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000; clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, clock_mhz,
(clocks.num_levels == 1) ? "*" : freq_match ? "*" : "");
(freq_match ? "*" : ""));
} }
break; break;
...@@ -926,7 +926,6 @@ static int arcturus_emit_clk_levels(struct smu_context *smu, ...@@ -926,7 +926,6 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
default: default:
return -EINVAL; return -EINVAL;
break;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment