]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
cpufreq: Store cpufreq policies in a list
authorLukasz Majewski <l.majewski@samsung.com>
Tue, 6 Aug 2013 17:23:08 +0000 (22:53 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 10 Aug 2013 01:24:06 +0000 (03:24 +0200)
Policies available in the cpufreq framework are now linked together.
They are accessible via cpufreq_policy_list defined in the cpufreq
core.

[rjw: Fix from Yinghai Lu folded in]
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h

index 9e83d9142072a27b5eaf555371a6ea712d9ea1ce..75c5bd424d599a71f49856d931787aef27f163a7 100644 (file)
@@ -40,6 +40,7 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
 static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data_fallback);
 static DEFINE_RWLOCK(cpufreq_driver_lock);
 static DEFINE_MUTEX(cpufreq_governor_lock);
+static LIST_HEAD(cpufreq_policy_list);
 
 #ifdef CONFIG_HOTPLUG_CPU
 /* This one keeps track of the previously set governor of a removed CPU */
@@ -952,6 +953,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(void)
        if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL))
                goto err_free_cpumask;
 
+       INIT_LIST_HEAD(&policy->policy_list);
        return policy;
 
 err_free_cpumask:
@@ -964,6 +966,12 @@ err_free_policy:
 
 static void cpufreq_policy_free(struct cpufreq_policy *policy)
 {
+       unsigned long flags;
+
+       write_lock_irqsave(&cpufreq_driver_lock, flags);
+       list_del(&policy->policy_list);
+       write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
        free_cpumask_var(policy->related_cpus);
        free_cpumask_var(policy->cpus);
        kfree(policy);
@@ -1077,6 +1085,10 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
                ret = cpufreq_add_dev_interface(policy, dev);
                if (ret)
                        goto err_out_unregister;
+
+               write_lock_irqsave(&cpufreq_driver_lock, flags);
+               list_add(&policy->policy_list, &cpufreq_policy_list);
+               write_unlock_irqrestore(&cpufreq_driver_lock, flags);
        }
 
        cpufreq_init_policy(policy);
index 29208923c9d32a03c852abbdb45ee6991598e18c..431a05d4b4c9e5cb73a712b056d0adbcb04b2add 100644 (file)
@@ -82,6 +82,7 @@ struct cpufreq_policy {
 
        struct cpufreq_real_policy      user_policy;
 
+       struct list_head        policy_list;
        struct kobject          kobj;
        struct completion       kobj_unregister;
        int                     transition_ongoing; /* Tracks transition status */