diff options
author | Darren Powell <darren.powell@amd.com> | 2023-04-20 19:48:08 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2023-08-30 15:51:17 -0400 |
commit | ee78ef046cde9886c935ee4557039c398e372e8c (patch) | |
tree | 411a9df63df8cf1957d0b469f01dd58e20cf4851 | |
parent | f72dcf8b29c49b18444d7ca7b3341d1ef0cb3402 (diff) | |
download | linux-stable-ee78ef046cde9886c935ee4557039c398e372e8c.tar.gz linux-stable-ee78ef046cde9886c935ee4557039c398e372e8c.tar.bz2 linux-stable-ee78ef046cde9886c935ee4557039c398e372e8c.zip |
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>
-rw-r--r-- | drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c index 7f8ed455c5c3..541461cd5cc3 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c @@ -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; |