Commit ce1bcfe9 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: check cpufreq_policy_list instead of scanning policies for all CPUs

CPUFREQ_STICKY flag is set by drivers which don't want to get unregistered
even if cpufreq-core isn't able to initialize policy for any CPU.

When this flag isn't set, we try to unregister the driver. To find out
which CPUs are registered and which are not, we try to check per_cpu
cpufreq_cpu_data for all CPUs. Because we have a list of valid policies
available now, we better check if the list is empty or not instead of
the 'for' loop. That will be much more efficient.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 39c132ee
...@@ -2455,24 +2455,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) ...@@ -2455,24 +2455,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
if (ret) if (ret)
goto err_boost_unreg; goto err_boost_unreg;
if (!(cpufreq_driver->flags & CPUFREQ_STICKY)) { if (!(cpufreq_driver->flags & CPUFREQ_STICKY) &&
int i; list_empty(&cpufreq_policy_list)) {
ret = -ENODEV;
/* check for at least one working CPU */
for (i = 0; i < nr_cpu_ids; i++)
if (cpu_possible(i) && per_cpu(cpufreq_cpu_data, i)) {
ret = 0;
break;
}
/* if all ->init() calls failed, unregister */ /* if all ->init() calls failed, unregister */
if (ret) { pr_debug("%s: No CPU initialized for driver %s\n", __func__,
pr_debug("no CPU initialized for driver %s\n",
driver_data->name); driver_data->name);
goto err_if_unreg; goto err_if_unreg;
} }
}
register_hotcpu_notifier(&cpufreq_cpu_notifier); register_hotcpu_notifier(&cpufreq_cpu_notifier);
pr_debug("driver %s up and running\n", driver_data->name); pr_debug("driver %s up and running\n", driver_data->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment