Skip to content

Commit b20a374

Browse files
committed
cpufreq: intel_pstate: Eliminate some code duplication
To eliminate some code duplication from the intel_pstate driver, move the core_get_val() function body to a new function called get_perf_ctl_val() and make both core_get_val() and atom_get_val() invoke it to carry out the same computation. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/2829273.mvXUDI8C0e@rafael.j.wysocki
1 parent 62c95ea commit b20a374

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,18 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
20482048
intel_pstate_update_epp_defaults(cpudata);
20492049
}
20502050

2051+
static u64 get_perf_ctl_val(int pstate)
2052+
{
2053+
u64 val;
2054+
2055+
val = (u64)pstate << 8;
2056+
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
2057+
cpu_feature_enabled(X86_FEATURE_IDA))
2058+
val |= (u64)1 << 32;
2059+
2060+
return val;
2061+
}
2062+
20512063
static int atom_get_min_pstate(int not_used)
20522064
{
20532065
u64 value;
@@ -2074,15 +2086,10 @@ static int atom_get_turbo_pstate(int not_used)
20742086

20752087
static u64 atom_get_val(struct cpudata *cpudata, int pstate)
20762088
{
2077-
u64 val;
2089+
u64 val = get_perf_ctl_val(pstate);
20782090
int32_t vid_fp;
20792091
u32 vid;
20802092

2081-
val = (u64)pstate << 8;
2082-
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
2083-
cpu_feature_enabled(X86_FEATURE_IDA))
2084-
val |= (u64)1 << 32;
2085-
20862093
vid_fp = cpudata->vid.min + mul_fp(
20872094
int_tofp(pstate - cpudata->pstate.min_pstate),
20882095
cpudata->vid.ratio);
@@ -2242,14 +2249,7 @@ static int core_get_turbo_pstate(int cpu)
22422249

22432250
static u64 core_get_val(struct cpudata *cpudata, int pstate)
22442251
{
2245-
u64 val;
2246-
2247-
val = (u64)pstate << 8;
2248-
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
2249-
cpu_feature_enabled(X86_FEATURE_IDA))
2250-
val |= (u64)1 << 32;
2251-
2252-
return val;
2252+
return get_perf_ctl_val(pstate);
22532253
}
22542254

22552255
static int knl_get_aperf_mperf_shift(void)

0 commit comments

Comments
 (0)