cpuidle / sysfs: move structure declaration into the sysfs.c file
[deliverable/linux.git] / drivers / cpuidle / sysfs.c
index 5f809e337b89d04dde3d2cb3ffee098e6dff6e86..f15c1e56e16ff81ba6e7387ed87f501d54e03d18 100644 (file)
@@ -297,6 +297,13 @@ static struct attribute *cpuidle_state_default_attrs[] = {
        NULL
 };
 
+struct cpuidle_state_kobj {
+       struct cpuidle_state *state;
+       struct cpuidle_state_usage *state_usage;
+       struct completion kobj_unregister;
+       struct kobject kobj;
+};
+
 #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj)
 #define kobj_to_state(k) (kobj_to_state_obj(k)->state)
 #define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage)
@@ -374,8 +381,8 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device)
                kobj->state_usage = &device->states_usage[i];
                init_completion(&kobj->kobj_unregister);
 
-               ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
-                                          "state%d", i);
+               ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,
+                                          &device->kobj, "state%d", i);
                if (ret) {
                        kfree(kobj);
                        goto error_state;
@@ -408,13 +415,13 @@ void cpuidle_remove_state_sysfs(struct cpuidle_device *device)
  * cpuidle_add_sysfs - creates a sysfs instance for the target device
  * @dev: the target device
  */
-int cpuidle_add_sysfs(struct device *cpu_dev)
+int cpuidle_add_sysfs(struct cpuidle_device *dev)
 {
-       int cpu = cpu_dev->id;
-       struct cpuidle_device *dev;
+       struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
        int error;
 
-       dev = per_cpu(cpuidle_devices, cpu);
+       init_completion(&dev->kobj_unregister);
+
        error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj,
                                     "cpuidle");
        if (!error)
@@ -426,11 +433,8 @@ int cpuidle_add_sysfs(struct device *cpu_dev)
  * cpuidle_remove_sysfs - deletes a sysfs instance on the target device
  * @dev: the target device
  */
-void cpuidle_remove_sysfs(struct device *cpu_dev)
+void cpuidle_remove_sysfs(struct cpuidle_device *dev)
 {
-       int cpu = cpu_dev->id;
-       struct cpuidle_device *dev;
-
-       dev = per_cpu(cpuidle_devices, cpu);
        kobject_put(&dev->kobj);
+       wait_for_completion(&dev->kobj_unregister);
 }
This page took 0.034975 seconds and 5 git commands to generate.