1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

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: Darren Powell <darren.powell@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Darren Powell 2023-04-20 19:48:08 -04:00 committed by Alex Deucher
parent f72dcf8b29
commit ee78ef046c

View file

@ -794,11 +794,11 @@ static int arcturus_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 = 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,
clock_mhz,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -815,11 +815,11 @@ static int arcturus_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 = 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, clock_mhz,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -836,11 +836,11 @@ static int arcturus_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 = 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, clock_mhz,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -854,14 +854,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.fclk_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;
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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -875,14 +875,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.vclk_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;
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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -896,14 +896,14 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.dclk_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;
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, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" :
(freq_match ? "*" : ""));
i, clock_mhz,
freq_match ? "*" : "");
}
break;
@ -926,7 +926,6 @@ static int arcturus_emit_clk_levels(struct smu_context *smu,
default:
return -EINVAL;
break;
}
return 0;