Skip to content

Commit 4d6ced7

Browse files
zhang-ruilenb
authored andcommitted
tools/power turbostat: Remove add_cstate_perf_counter_()
As the only caller of add_cstate_perf_counter_(), add_cstate_perf_counter() just gives extra debug output on top. There is no need to keep both functions. Remove add_cstate_perf_counter_() and move all the logic to add_cstate_perf_counter(). No functional change. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent c8bca95 commit 4d6ced7

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8021,35 +8021,31 @@ int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *gro
80218021
return NULL;
80228022
}
80238023

8024-
int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
8024+
int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
80258025
{
8026+
int ret = -1;
8027+
80268028
if (no_perf)
80278029
return -1;
80288030

80298031
int *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);
80308032

80318033
if (pfd_group == NULL)
8032-
return -1;
8034+
goto end;
80338035

80348036
const unsigned int type = read_perf_type(cai->perf_subsys);
80358037
const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);
80368038

8037-
const int fd_counter = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);
8039+
ret = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);
80388040

8039-
if (fd_counter == -1)
8040-
return -1;
8041+
if (ret == -1)
8042+
goto end;
80418043

80428044
/* If it's the first counter opened, make it a group descriptor */
80438045
if (*pfd_group == -1)
8044-
*pfd_group = fd_counter;
8045-
8046-
return fd_counter;
8047-
}
8048-
8049-
int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
8050-
{
8051-
int ret = add_cstate_perf_counter_(cpu, cci, cai);
8046+
*pfd_group = ret;
80528047

8048+
end:
80538049
if (debug >= 2)
80548050
fprintf(stderr, "%s: %d (cpu: %d)\n", __func__, ret, cpu);
80558051

0 commit comments

Comments
 (0)