cpufreq: Return 0 from ->fast_switch() on errors
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 9 Aug 2017 04:51:46 +0000 (10:21 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 9 Aug 2017 23:26:35 +0000 (01:26 +0200)
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 <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
kernel/sched/cpufreq_schedutil.c

index 9bf97a366029f22b959a50d819d362b0f51bf5a4..0c728190e4445571433d421a646f8c12243892ae 100644 (file)
@@ -1817,9 +1817,10 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier);
  * twice in parallel for the same policy and that it will never be called in
  * parallel with either ->target() or ->target_index() for the same policy.
  *
- * If CPUFREQ_ENTRY_INVALID is returned by the driver's ->fast_switch()
- * callback to indicate an error condition, the hardware configuration must be
- * preserved.
+ * Returns the actual frequency set for the CPU.
+ *
+ * If 0 is returned by the driver's ->fast_switch() callback to indicate an
+ * error condition, the hardware configuration must be preserved.
  */
 unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
                                        unsigned int target_freq)
index 7dbc76801f8627addf94dba3c250d21fe377f2d9..2ba04bb3182a5b42299fb470b20038d9dfb8536d 100644 (file)
@@ -123,7 +123,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
 
        if (policy->fast_switch_enabled) {
                next_freq = cpufreq_driver_fast_switch(policy, next_freq);
-               if (next_freq == CPUFREQ_ENTRY_INVALID)
+               if (!next_freq)
                        return;
 
                policy->cur = next_freq;