mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 22:05:08 +00:00
OPP: Reorder code in _opp_set_required_opps_genpd()
Reorder code in _opp_set_required_opps_genpd() to reduce duplicate code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
96104046d1
commit
c2bebf9804
@ -1076,7 +1076,18 @@ static int _opp_set_required_opps_genpd(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct device **genpd_virt_devs =
|
struct device **genpd_virt_devs =
|
||||||
opp_table->genpd_virt_devs ? opp_table->genpd_virt_devs : &dev;
|
opp_table->genpd_virt_devs ? opp_table->genpd_virt_devs : &dev;
|
||||||
int i, ret = 0;
|
int index, target, delta, ret = 0;
|
||||||
|
|
||||||
|
/* Scaling up? Set required OPPs in normal order, else reverse */
|
||||||
|
if (!scaling_down) {
|
||||||
|
index = 0;
|
||||||
|
target = opp_table->required_opp_count;
|
||||||
|
delta = 1;
|
||||||
|
} else {
|
||||||
|
index = opp_table->required_opp_count - 1;
|
||||||
|
target = -1;
|
||||||
|
delta = -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Acquire genpd_virt_dev_lock to make sure we don't use a genpd_dev
|
* Acquire genpd_virt_dev_lock to make sure we don't use a genpd_dev
|
||||||
@ -1084,19 +1095,12 @@ static int _opp_set_required_opps_genpd(struct device *dev,
|
|||||||
*/
|
*/
|
||||||
mutex_lock(&opp_table->genpd_virt_dev_lock);
|
mutex_lock(&opp_table->genpd_virt_dev_lock);
|
||||||
|
|
||||||
/* Scaling up? Set required OPPs in normal order, else reverse */
|
while (index != target) {
|
||||||
if (!scaling_down) {
|
ret = _set_performance_state(dev, genpd_virt_devs[index], opp, index);
|
||||||
for (i = 0; i < opp_table->required_opp_count; i++) {
|
if (ret)
|
||||||
ret = _set_performance_state(dev, genpd_virt_devs[i], opp, i);
|
break;
|
||||||
if (ret)
|
|
||||||
break;
|
index += delta;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i = opp_table->required_opp_count - 1; i >= 0; i--) {
|
|
||||||
ret = _set_performance_state(dev, genpd_virt_devs[i], opp, i);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&opp_table->genpd_virt_dev_lock);
|
mutex_unlock(&opp_table->genpd_virt_dev_lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user