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

amdgpu/pm: Optimize emit_clock_levels for aldebaran - 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 2ecf214b
......@@ -792,12 +792,11 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < display_levels; i++) {
clock_mhz = freq_values[i];
freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (display_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", i,
clock_mhz,
(display_levels == 1) ?
"*" :
(freq_match) ? "*" : "");
(freq_match) ? "*" : "");
}
break;
......@@ -818,10 +817,10 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = aldebaran_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, clock_mhz,
(clocks.num_levels == 1) ? "*" :
(freq_match) ? "*" : "");
}
break;
......@@ -839,10 +838,10 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = aldebaran_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, clock_mhz,
(clocks.num_levels == 1) ? "*" :
(freq_match) ? "*" : "");
}
break;
......@@ -857,13 +856,13 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.fclk_table);
aldebaran_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;
freq_match = aldebaran_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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
......@@ -878,13 +877,13 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.vclk_table);
aldebaran_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;
freq_match = aldebaran_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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
......@@ -899,13 +898,13 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.dclk_table);
aldebaran_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;
freq_match = aldebaran_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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
......
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