Skip to content

Commit 209887e

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Return 0 from ->fast_switch() on errors
CPUFREQ_ENTRY_INVALID is a special symbol which is used to specify that an entry in the cpufreq table is invalid. But using it outside of the scope of the cpufreq table looks a bit incorrect. We can represent an invalid frequency by writing it as 0 instead if we need. Note that it is already done that way for the return value of the ->get() callback. Lets do the same for ->fast_switch() and not use CPUFREQ_ENTRY_INVALID outside of the scope of cpufreq table. Also update the comment over cpufreq_driver_fast_switch() to clearly mention what this returns. None of the drivers return CPUFREQ_ENTRY_INVALID as of now from ->fast_switch() callback and so we don't need to update any of those. Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent d6344d4 commit 209887e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,9 +1817,10 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier);
18171817
* twice in parallel for the same policy and that it will never be called in
18181818
* parallel with either ->target() or ->target_index() for the same policy.
18191819
*
1820-
* If CPUFREQ_ENTRY_INVALID is returned by the driver's ->fast_switch()
1821-
* callback to indicate an error condition, the hardware configuration must be
1822-
* preserved.
1820+
* Returns the actual frequency set for the CPU.
1821+
*
1822+
* If 0 is returned by the driver's ->fast_switch() callback to indicate an
1823+
* error condition, the hardware configuration must be preserved.
18231824
*/
18241825
unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
18251826
unsigned int target_freq)

kernel/sched/cpufreq_schedutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
123123

124124
if (policy->fast_switch_enabled) {
125125
next_freq = cpufreq_driver_fast_switch(policy, next_freq);
126-
if (next_freq == CPUFREQ_ENTRY_INVALID)
126+
if (!next_freq)
127127
return;
128128

129129
policy->cur = next_freq;

0 commit comments

Comments
 (0)