aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2009-07-08 17:35:39 -0400
committerDave Jones <davej@redhat.com>2009-09-01 12:45:12 -0400
commit19d6f7ec3eb1652fc89dd05ebcc2a21a95c60a5a (patch)
treeb8b4c02ed6bb39928f60f7336dc60a53a40c25e1 /drivers/cpufreq
parent059019a3c3353b15d8efac5301f72036cc408bd4 (diff)
[CPUFREQ] Factor out symlink creation from cpufreq_add_dev
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 06eeff3c822f..7600c10d275a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -756,6 +756,34 @@ static struct kobj_type ktype_cpufreq = {
756 .release = cpufreq_sysfs_release, 756 .release = cpufreq_sysfs_release,
757}; 757};
758 758
759/* symlink affected CPUs */
760int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy)
761{
762 unsigned int j;
763 int ret = 0;
764
765 for_each_cpu(j, policy->cpus) {
766 struct cpufreq_policy *managed_policy;
767 struct sys_device *cpu_sys_dev;
768
769 if (j == cpu)
770 continue;
771 if (!cpu_online(j))
772 continue;
773
774 dprintk("CPU %u already managed, adding link\n", j);
775 managed_policy = cpufreq_cpu_get(cpu);
776 cpu_sys_dev = get_cpu_sysdev(j);
777 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
778 "cpufreq");
779 if (ret) {
780 cpufreq_cpu_put(managed_policy);
781 return ret;
782 }
783 }
784 return ret;
785}
786
759 787
760/** 788/**
761 * cpufreq_add_dev - add a CPU device 789 * cpufreq_add_dev - add a CPU device
@@ -929,26 +957,9 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
929 } 957 }
930 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 958 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
931 959
932 /* symlink affected CPUs */ 960 ret = cpufreq_add_dev_symlink(cpu, policy->cpus, policy);
933 for_each_cpu(j, policy->cpus) { 961 if (ret)
934 struct cpufreq_policy *managed_policy; 962 goto err_out_unregister;
935 struct sys_device *cpu_sys_dev;
936
937 if (j == cpu)
938 continue;
939 if (!cpu_online(j))
940 continue;
941
942 dprintk("CPU %u already managed, adding link\n", j);
943 managed_policy = cpufreq_cpu_get(cpu);
944 cpu_sys_dev = get_cpu_sysdev(j);
945 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
946 "cpufreq");
947 if (ret) {
948 cpufreq_cpu_put(managed_policy);
949 goto err_out_unregister;
950 }
951 }
952 963
953 policy->governor = NULL; /* to assure that the starting sequence is 964 policy->governor = NULL; /* to assure that the starting sequence is
954 * run in cpufreq_set_policy */ 965 * run in cpufreq_set_policy */