Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+14 -14
+14 -14
drivers/cpufreq/intel_pstate.c
··· 2048 2048 intel_pstate_update_epp_defaults(cpudata); 2049 2049 } 2050 2050 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 + 2051 2063 static int atom_get_min_pstate(int not_used) 2052 2064 { 2053 2065 u64 value; ··· 2086 2074 2087 2075 static u64 atom_get_val(struct cpudata *cpudata, int pstate) 2088 2076 { 2089 - u64 val; 2077 + u64 val = get_perf_ctl_val(pstate); 2090 2078 int32_t vid_fp; 2091 2079 u32 vid; 2092 - 2093 - val = (u64)pstate << 8; 2094 - if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) && 2095 - cpu_feature_enabled(X86_FEATURE_IDA)) 2096 - val |= (u64)1 << 32; 2097 2080 2098 2081 vid_fp = cpudata->vid.min + mul_fp( 2099 2082 int_tofp(pstate - cpudata->pstate.min_pstate), ··· 2249 2242 2250 2243 static u64 core_get_val(struct cpudata *cpudata, int pstate) 2251 2244 { 2252 - u64 val; 2253 - 2254 - val = (u64)pstate << 8; 2255 - if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) && 2256 - cpu_feature_enabled(X86_FEATURE_IDA)) 2257 - val |= (u64)1 << 32; 2258 - 2259 - return val; 2245 + return get_perf_ctl_val(pstate); 2260 2246 } 2261 2247 2262 2248 static int knl_get_aperf_mperf_shift(void)