@@ -588,6 +588,22 @@ static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf)
588
588
return sysfs_emit (buf , "%d\n" , policy -> boost_enabled );
589
589
}
590
590
591
+ static int policy_set_boost (struct cpufreq_policy * policy , bool enable )
592
+ {
593
+ int ret ;
594
+
595
+ if (policy -> boost_enabled == enable )
596
+ return 0 ;
597
+
598
+ policy -> boost_enabled = enable ;
599
+
600
+ ret = cpufreq_driver -> set_boost (policy , enable );
601
+ if (ret )
602
+ policy -> boost_enabled = !policy -> boost_enabled ;
603
+
604
+ return ret ;
605
+ }
606
+
591
607
static ssize_t store_local_boost (struct cpufreq_policy * policy ,
592
608
const char * buf , size_t count )
593
609
{
@@ -603,21 +619,14 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
603
619
if (!policy -> boost_supported )
604
620
return - EINVAL ;
605
621
606
- if (policy -> boost_enabled == enable )
607
- return count ;
608
-
609
- policy -> boost_enabled = enable ;
610
-
611
622
cpus_read_lock ();
612
- ret = cpufreq_driver -> set_boost (policy , enable );
623
+ ret = policy_set_boost (policy , enable );
613
624
cpus_read_unlock ();
614
625
615
- if (ret ) {
616
- policy -> boost_enabled = !policy -> boost_enabled ;
617
- return ret ;
618
- }
626
+ if (!ret )
627
+ return count ;
619
628
620
- return count ;
629
+ return ret ;
621
630
}
622
631
623
632
static struct freq_attr local_boost = __ATTR (boost , 0644 , show_local_boost , store_local_boost );
@@ -1615,15 +1624,12 @@ static int cpufreq_online(unsigned int cpu)
1615
1624
policy -> cdev = of_cpufreq_cooling_register (policy );
1616
1625
1617
1626
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1618
- if (cpufreq_driver -> set_boost && policy -> boost_supported &&
1619
- policy -> boost_enabled != cpufreq_boost_enabled ()) {
1620
- policy -> boost_enabled = cpufreq_boost_enabled ();
1621
- ret = cpufreq_driver -> set_boost (policy , policy -> boost_enabled );
1627
+ if (cpufreq_driver -> set_boost && policy -> boost_supported ) {
1628
+ ret = policy_set_boost (policy , cpufreq_boost_enabled ());
1622
1629
if (ret ) {
1623
1630
/* If the set_boost fails, the online operation is not affected */
1624
1631
pr_info ("%s: CPU%d: Cannot %s BOOST\n" , __func__ , policy -> cpu ,
1625
- str_enable_disable (policy -> boost_enabled ));
1626
- policy -> boost_enabled = !policy -> boost_enabled ;
1632
+ str_enable_disable (cpufreq_boost_enabled ()));
1627
1633
}
1628
1634
}
1629
1635
@@ -2807,15 +2813,12 @@ static int cpufreq_boost_trigger_state(int state)
2807
2813
2808
2814
cpus_read_lock ();
2809
2815
for_each_active_policy (policy ) {
2810
- if (!policy -> boost_supported || policy -> boost_enabled == state )
2816
+ if (!policy -> boost_supported )
2811
2817
continue ;
2812
2818
2813
- policy -> boost_enabled = state ;
2814
- ret = cpufreq_driver -> set_boost (policy , state );
2815
- if (ret ) {
2816
- policy -> boost_enabled = !policy -> boost_enabled ;
2819
+ ret = policy_set_boost (policy , state );
2820
+ if (ret )
2817
2821
goto err_reset_state ;
2818
- }
2819
2822
}
2820
2823
cpus_read_unlock ();
2821
2824
0 commit comments