summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2009-07-08 18:05:42 -0400
committerDave Jones <davej@redhat.com>2009-09-01 12:45:13 -0400
commit909a694e336bf3a6e48b5b51129887a1c5cae04c (patch)
treeb0f5af649d60c703156574409e8813e8c88b84b8
parent19d6f7ec3eb1652fc89dd05ebcc2a21a95c60a5a (diff)
downloadop-kernel-dev-909a694e336bf3a6e48b5b51129887a1c5cae04c.zip
op-kernel-dev-909a694e336bf3a6e48b5b51129887a1c5cae04c.tar.gz
[CPUFREQ] Factor out interface creation from cpufreq_add_dev
Signed-off-by: Dave Jones <davej@redhat.com>
-rw-r--r--drivers/cpufreq/cpufreq.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7600c10..0ee008d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -784,6 +784,57 @@ int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy)
return ret;
}
+int cpufreq_add_dev_interface(unsigned int cpu, struct cpufreq_policy *policy,
+ struct sys_device *sys_dev)
+{
+ struct freq_attr **drv_attr;
+ unsigned long flags;
+ int ret = 0;
+ unsigned int j;
+
+ /* prepare interface data */
+ ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
+ &sys_dev->kobj, "cpufreq");
+ if (ret)
+ return ret;
+
+ /* set up files for this cpu device */
+ drv_attr = cpufreq_driver->attr;
+ while ((drv_attr) && (*drv_attr)) {
+ ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
+ if (ret)
+ goto err_out_kobj_put;
+ drv_attr++;
+ }
+ if (cpufreq_driver->get) {
+ ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
+ if (ret)
+ goto err_out_kobj_put;
+ }
+ if (cpufreq_driver->target) {
+ ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
+ if (ret)
+ goto err_out_kobj_put;
+ }
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ for_each_cpu(j, policy->cpus) {
+ if (!cpu_online(j))
+ continue;
+ per_cpu(cpufreq_cpu_data, j) = policy;
+ per_cpu(policy_cpu, j) = policy->cpu;
+ }
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ ret = cpufreq_add_dev_symlink(cpu, policy);
+ return ret;
+
+err_out_kobj_put:
+ kobject_put(&policy->kobj);
+ wait_for_completion(&policy->kobj_unregister);
+ return ret;
+}
+
/**
* cpufreq_add_dev - add a CPU device
@@ -800,7 +851,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
int ret = 0;
struct cpufreq_policy new_policy;
struct cpufreq_policy *policy;
- struct freq_attr **drv_attr;
unsigned long flags;
unsigned int j;
@@ -923,41 +973,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
#endif
memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
- /* prepare interface data */
- ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj,
- "cpufreq");
- if (ret)
- goto out_driver_exit;
-
- /* set up files for this cpu device */
- drv_attr = cpufreq_driver->attr;
- while ((drv_attr) && (*drv_attr)) {
- ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
- if (ret)
- goto err_out_kobj_put;
- drv_attr++;
- }
- if (cpufreq_driver->get) {
- ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
- if (ret)
- goto err_out_kobj_put;
- }
- if (cpufreq_driver->target) {
- ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
- if (ret)
- goto err_out_kobj_put;
- }
-
- spin_lock_irqsave(&cpufreq_driver_lock, flags);
- for_each_cpu(j, policy->cpus) {
- if (!cpu_online(j))
- continue;
- per_cpu(cpufreq_cpu_data, j) = policy;
- per_cpu(policy_cpu, j) = policy->cpu;
- }
- spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
- ret = cpufreq_add_dev_symlink(cpu, policy->cpus, policy);
+ ret = cpufreq_add_dev_interface(cpu, policy, sys_dev);
if (ret)
goto err_out_unregister;
@@ -990,7 +1006,6 @@ err_out_unregister:
per_cpu(cpufreq_cpu_data, j) = NULL;
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
-err_out_kobj_put:
kobject_put(&policy->kobj);
wait_for_completion(&policy->kobj_unregister);
OpenPOWER on IntegriCloud