cpufreq: mediatek: Replace old_* with pre_*

To make driver more readable, replace old_* with pre_*.

Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
Rex-BC Chen 2022-04-22 15:52:28 +08:00 committed by Viresh Kumar
parent 9acc0f7a6e
commit 4aef4aeaf1
1 changed files with 42 additions and 42 deletions

View File

@ -61,18 +61,18 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
{ {
struct regulator *proc_reg = info->proc_reg; struct regulator *proc_reg = info->proc_reg;
struct regulator *sram_reg = info->sram_reg; struct regulator *sram_reg = info->sram_reg;
int old_vproc, old_vsram, new_vsram, vsram, vproc, ret; int pre_vproc, pre_vsram, new_vsram, vsram, vproc, ret;
old_vproc = regulator_get_voltage(proc_reg); pre_vproc = regulator_get_voltage(proc_reg);
if (old_vproc < 0) { if (pre_vproc < 0) {
dev_err(info->cpu_dev, dev_err(info->cpu_dev,
"invalid Vproc value: %d\n", old_vproc); "invalid Vproc value: %d\n", pre_vproc);
return old_vproc; return pre_vproc;
} }
/* Vsram should not exceed the maximum allowed voltage of SoC. */ /* Vsram should not exceed the maximum allowed voltage of SoC. */
new_vsram = min(new_vproc + MIN_VOLT_SHIFT, MAX_VOLT_LIMIT); new_vsram = min(new_vproc + MIN_VOLT_SHIFT, MAX_VOLT_LIMIT);
if (old_vproc < new_vproc) { if (pre_vproc < new_vproc) {
/* /*
* When scaling up voltages, Vsram and Vproc scale up step * When scaling up voltages, Vsram and Vproc scale up step
* by step. At each step, set Vsram to (Vproc + 200mV) first, * by step. At each step, set Vsram to (Vproc + 200mV) first,
@ -80,20 +80,20 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
* Keep doing it until Vsram and Vproc hit target voltages. * Keep doing it until Vsram and Vproc hit target voltages.
*/ */
do { do {
old_vsram = regulator_get_voltage(sram_reg); pre_vsram = regulator_get_voltage(sram_reg);
if (old_vsram < 0) { if (pre_vsram < 0) {
dev_err(info->cpu_dev, dev_err(info->cpu_dev,
"invalid Vsram value: %d\n", old_vsram); "invalid Vsram value: %d\n", pre_vsram);
return old_vsram; return pre_vsram;
} }
old_vproc = regulator_get_voltage(proc_reg); pre_vproc = regulator_get_voltage(proc_reg);
if (old_vproc < 0) { if (pre_vproc < 0) {
dev_err(info->cpu_dev, dev_err(info->cpu_dev,
"invalid Vproc value: %d\n", old_vproc); "invalid Vproc value: %d\n", pre_vproc);
return old_vproc; return pre_vproc;
} }
vsram = min(new_vsram, old_vproc + MAX_VOLT_SHIFT); vsram = min(new_vsram, pre_vproc + MAX_VOLT_SHIFT);
if (vsram + VOLT_TOL >= MAX_VOLT_LIMIT) { if (vsram + VOLT_TOL >= MAX_VOLT_LIMIT) {
vsram = MAX_VOLT_LIMIT; vsram = MAX_VOLT_LIMIT;
@ -122,12 +122,12 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
ret = regulator_set_voltage(proc_reg, vproc, ret = regulator_set_voltage(proc_reg, vproc,
vproc + VOLT_TOL); vproc + VOLT_TOL);
if (ret) { if (ret) {
regulator_set_voltage(sram_reg, old_vsram, regulator_set_voltage(sram_reg, pre_vsram,
old_vsram); pre_vsram);
return ret; return ret;
} }
} while (vproc < new_vproc || vsram < new_vsram); } while (vproc < new_vproc || vsram < new_vsram);
} else if (old_vproc > new_vproc) { } else if (pre_vproc > new_vproc) {
/* /*
* When scaling down voltages, Vsram and Vproc scale down step * When scaling down voltages, Vsram and Vproc scale down step
* by step. At each step, set Vproc to (Vsram - 200mV) first, * by step. At each step, set Vproc to (Vsram - 200mV) first,
@ -135,20 +135,20 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
* Keep doing it until Vsram and Vproc hit target voltages. * Keep doing it until Vsram and Vproc hit target voltages.
*/ */
do { do {
old_vproc = regulator_get_voltage(proc_reg); pre_vproc = regulator_get_voltage(proc_reg);
if (old_vproc < 0) { if (pre_vproc < 0) {
dev_err(info->cpu_dev, dev_err(info->cpu_dev,
"invalid Vproc value: %d\n", old_vproc); "invalid Vproc value: %d\n", pre_vproc);
return old_vproc; return pre_vproc;
} }
old_vsram = regulator_get_voltage(sram_reg); pre_vsram = regulator_get_voltage(sram_reg);
if (old_vsram < 0) { if (pre_vsram < 0) {
dev_err(info->cpu_dev, dev_err(info->cpu_dev,
"invalid Vsram value: %d\n", old_vsram); "invalid Vsram value: %d\n", pre_vsram);
return old_vsram; return pre_vsram;
} }
vproc = max(new_vproc, old_vsram - MAX_VOLT_SHIFT); vproc = max(new_vproc, pre_vsram - MAX_VOLT_SHIFT);
ret = regulator_set_voltage(proc_reg, vproc, ret = regulator_set_voltage(proc_reg, vproc,
vproc + VOLT_TOL); vproc + VOLT_TOL);
if (ret) if (ret)
@ -178,8 +178,8 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
} }
if (ret) { if (ret) {
regulator_set_voltage(proc_reg, old_vproc, regulator_set_voltage(proc_reg, pre_vproc,
old_vproc); pre_vproc);
return ret; return ret;
} }
} while (vproc > new_vproc + VOLT_TOL || } while (vproc > new_vproc + VOLT_TOL ||
@ -207,16 +207,16 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
struct mtk_cpu_dvfs_info *info = policy->driver_data; struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device *cpu_dev = info->cpu_dev; struct device *cpu_dev = info->cpu_dev;
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
long freq_hz, old_freq_hz; long freq_hz, pre_freq_hz;
int vproc, old_vproc, inter_vproc, target_vproc, ret; int vproc, pre_vproc, inter_vproc, target_vproc, ret;
inter_vproc = info->intermediate_voltage; inter_vproc = info->intermediate_voltage;
old_freq_hz = clk_get_rate(cpu_clk); pre_freq_hz = clk_get_rate(cpu_clk);
old_vproc = regulator_get_voltage(info->proc_reg); pre_vproc = regulator_get_voltage(info->proc_reg);
if (old_vproc < 0) { if (pre_vproc < 0) {
dev_err(cpu_dev, "invalid Vproc value: %d\n", old_vproc); dev_err(cpu_dev, "invalid Vproc value: %d\n", pre_vproc);
return old_vproc; return pre_vproc;
} }
freq_hz = freq_table[index].frequency * 1000; freq_hz = freq_table[index].frequency * 1000;
@ -235,12 +235,12 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
* current voltage, scale up voltage first. * current voltage, scale up voltage first.
*/ */
target_vproc = (inter_vproc > vproc) ? inter_vproc : vproc; target_vproc = (inter_vproc > vproc) ? inter_vproc : vproc;
if (old_vproc < target_vproc) { if (pre_vproc < target_vproc) {
ret = mtk_cpufreq_set_voltage(info, target_vproc); ret = mtk_cpufreq_set_voltage(info, target_vproc);
if (ret) { if (ret) {
dev_err(cpu_dev, dev_err(cpu_dev,
"cpu%d: failed to scale up voltage!\n", policy->cpu); "cpu%d: failed to scale up voltage!\n", policy->cpu);
mtk_cpufreq_set_voltage(info, old_vproc); mtk_cpufreq_set_voltage(info, pre_vproc);
return ret; return ret;
} }
} }
@ -250,7 +250,7 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
if (ret) { if (ret) {
dev_err(cpu_dev, dev_err(cpu_dev,
"cpu%d: failed to re-parent cpu clock!\n", policy->cpu); "cpu%d: failed to re-parent cpu clock!\n", policy->cpu);
mtk_cpufreq_set_voltage(info, old_vproc); mtk_cpufreq_set_voltage(info, pre_vproc);
WARN_ON(1); WARN_ON(1);
return ret; return ret;
} }
@ -261,7 +261,7 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
dev_err(cpu_dev, dev_err(cpu_dev,
"cpu%d: failed to scale cpu clock rate!\n", policy->cpu); "cpu%d: failed to scale cpu clock rate!\n", policy->cpu);
clk_set_parent(cpu_clk, armpll); clk_set_parent(cpu_clk, armpll);
mtk_cpufreq_set_voltage(info, old_vproc); mtk_cpufreq_set_voltage(info, pre_vproc);
return ret; return ret;
} }
@ -279,13 +279,13 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
* If the new voltage is lower than the intermediate voltage or the * If the new voltage is lower than the intermediate voltage or the
* original voltage, scale down to the new voltage. * original voltage, scale down to the new voltage.
*/ */
if (vproc < inter_vproc || vproc < old_vproc) { if (vproc < inter_vproc || vproc < pre_vproc) {
ret = mtk_cpufreq_set_voltage(info, vproc); ret = mtk_cpufreq_set_voltage(info, vproc);
if (ret) { if (ret) {
dev_err(cpu_dev, dev_err(cpu_dev,
"cpu%d: failed to scale down voltage!\n", policy->cpu); "cpu%d: failed to scale down voltage!\n", policy->cpu);
clk_set_parent(cpu_clk, info->inter_clk); clk_set_parent(cpu_clk, info->inter_clk);
clk_set_rate(armpll, old_freq_hz); clk_set_rate(armpll, pre_freq_hz);
clk_set_parent(cpu_clk, armpll); clk_set_parent(cpu_clk, armpll);
return ret; return ret;
} }