diff options
Diffstat (limited to 'drivers/cpuidle/sysfs.c')
-rw-r--r-- | drivers/cpuidle/sysfs.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 0f3515e77d4b..088ea74edd34 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -277,7 +277,7 @@ static struct kobj_type ktype_state_cpuidle = { | |||
277 | 277 | ||
278 | static void inline cpuidle_free_state_kobj(struct cpuidle_device *device, int i) | 278 | static void inline cpuidle_free_state_kobj(struct cpuidle_device *device, int i) |
279 | { | 279 | { |
280 | kobject_unregister(&device->kobjs[i]->kobj); | 280 | kobject_put(&device->kobjs[i]->kobj); |
281 | wait_for_completion(&device->kobjs[i]->kobj_unregister); | 281 | wait_for_completion(&device->kobjs[i]->kobj_unregister); |
282 | kfree(device->kobjs[i]); | 282 | kfree(device->kobjs[i]); |
283 | device->kobjs[i] = NULL; | 283 | device->kobjs[i] = NULL; |
@@ -300,14 +300,13 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) | |||
300 | kobj->state = &device->states[i]; | 300 | kobj->state = &device->states[i]; |
301 | init_completion(&kobj->kobj_unregister); | 301 | init_completion(&kobj->kobj_unregister); |
302 | 302 | ||
303 | kobj->kobj.parent = &device->kobj; | 303 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, |
304 | kobj->kobj.ktype = &ktype_state_cpuidle; | 304 | "state%d", i); |
305 | kobject_set_name(&kobj->kobj, "state%d", i); | ||
306 | ret = kobject_register(&kobj->kobj); | ||
307 | if (ret) { | 305 | if (ret) { |
308 | kfree(kobj); | 306 | kfree(kobj); |
309 | goto error_state; | 307 | goto error_state; |
310 | } | 308 | } |
309 | kobject_uevent(&kobj->kobj, KOBJ_ADD); | ||
311 | device->kobjs[i] = kobj; | 310 | device->kobjs[i] = kobj; |
312 | } | 311 | } |
313 | 312 | ||
@@ -339,12 +338,14 @@ int cpuidle_add_sysfs(struct sys_device *sysdev) | |||
339 | { | 338 | { |
340 | int cpu = sysdev->id; | 339 | int cpu = sysdev->id; |
341 | struct cpuidle_device *dev; | 340 | struct cpuidle_device *dev; |
341 | int error; | ||
342 | 342 | ||
343 | dev = per_cpu(cpuidle_devices, cpu); | 343 | dev = per_cpu(cpuidle_devices, cpu); |
344 | dev->kobj.parent = &sysdev->kobj; | 344 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj, |
345 | dev->kobj.ktype = &ktype_cpuidle; | 345 | "cpuidle"); |
346 | kobject_set_name(&dev->kobj, "%s", "cpuidle"); | 346 | if (!error) |
347 | return kobject_register(&dev->kobj); | 347 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
348 | return error; | ||
348 | } | 349 | } |
349 | 350 | ||
350 | /** | 351 | /** |
@@ -357,5 +358,5 @@ void cpuidle_remove_sysfs(struct sys_device *sysdev) | |||
357 | struct cpuidle_device *dev; | 358 | struct cpuidle_device *dev; |
358 | 359 | ||
359 | dev = per_cpu(cpuidle_devices, cpu); | 360 | dev = per_cpu(cpuidle_devices, cpu); |
360 | kobject_unregister(&dev->kobj); | 361 | kobject_put(&dev->kobj); |
361 | } | 362 | } |