diff options
Diffstat (limited to 'drivers/base/sys.c')
-rw-r--r-- | drivers/base/sys.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index ac7ff6d0c6e5..2f79c55acdcc 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -25,8 +25,6 @@ | |||
25 | 25 | ||
26 | #include "base.h" | 26 | #include "base.h" |
27 | 27 | ||
28 | extern struct kset devices_subsys; | ||
29 | |||
30 | #define to_sysdev(k) container_of(k, struct sys_device, kobj) | 28 | #define to_sysdev(k) container_of(k, struct sys_device, kobj) |
31 | #define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr) | 29 | #define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr) |
32 | 30 | ||
@@ -128,18 +126,17 @@ void sysdev_class_remove_file(struct sysdev_class *c, | |||
128 | } | 126 | } |
129 | EXPORT_SYMBOL_GPL(sysdev_class_remove_file); | 127 | EXPORT_SYMBOL_GPL(sysdev_class_remove_file); |
130 | 128 | ||
131 | /* | 129 | static struct kset *system_kset; |
132 | * declare system_subsys | ||
133 | */ | ||
134 | static decl_subsys(system, &ktype_sysdev_class, NULL); | ||
135 | 130 | ||
136 | int sysdev_class_register(struct sysdev_class * cls) | 131 | int sysdev_class_register(struct sysdev_class * cls) |
137 | { | 132 | { |
138 | pr_debug("Registering sysdev class '%s'\n", | 133 | pr_debug("Registering sysdev class '%s'\n", |
139 | kobject_name(&cls->kset.kobj)); | 134 | kobject_name(&cls->kset.kobj)); |
140 | INIT_LIST_HEAD(&cls->drivers); | 135 | INIT_LIST_HEAD(&cls->drivers); |
141 | cls->kset.kobj.parent = &system_subsys.kobj; | 136 | cls->kset.kobj.parent = &system_kset->kobj; |
142 | cls->kset.kobj.kset = &system_subsys; | 137 | cls->kset.kobj.ktype = &ktype_sysdev_class; |
138 | cls->kset.kobj.kset = system_kset; | ||
139 | kobject_set_name(&cls->kset.kobj, cls->name); | ||
143 | return kset_register(&cls->kset); | 140 | return kset_register(&cls->kset); |
144 | } | 141 | } |
145 | 142 | ||
@@ -228,20 +225,15 @@ int sysdev_register(struct sys_device * sysdev) | |||
228 | if (!cls) | 225 | if (!cls) |
229 | return -EINVAL; | 226 | return -EINVAL; |
230 | 227 | ||
228 | pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj)); | ||
229 | |||
231 | /* Make sure the kset is set */ | 230 | /* Make sure the kset is set */ |
232 | sysdev->kobj.kset = &cls->kset; | 231 | sysdev->kobj.kset = &cls->kset; |
233 | 232 | ||
234 | /* But make sure we point to the right type for sysfs translation */ | ||
235 | sysdev->kobj.ktype = &ktype_sysdev; | ||
236 | error = kobject_set_name(&sysdev->kobj, "%s%d", | ||
237 | kobject_name(&cls->kset.kobj), sysdev->id); | ||
238 | if (error) | ||
239 | return error; | ||
240 | |||
241 | pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj)); | ||
242 | |||
243 | /* Register the object */ | 233 | /* Register the object */ |
244 | error = kobject_register(&sysdev->kobj); | 234 | error = kobject_init_and_add(&sysdev->kobj, &ktype_sysdev, NULL, |
235 | "%s%d", kobject_name(&cls->kset.kobj), | ||
236 | sysdev->id); | ||
245 | 237 | ||
246 | if (!error) { | 238 | if (!error) { |
247 | struct sysdev_driver * drv; | 239 | struct sysdev_driver * drv; |
@@ -258,6 +250,7 @@ int sysdev_register(struct sys_device * sysdev) | |||
258 | } | 250 | } |
259 | mutex_unlock(&sysdev_drivers_lock); | 251 | mutex_unlock(&sysdev_drivers_lock); |
260 | } | 252 | } |
253 | kobject_uevent(&sysdev->kobj, KOBJ_ADD); | ||
261 | return error; | 254 | return error; |
262 | } | 255 | } |
263 | 256 | ||
@@ -272,7 +265,7 @@ void sysdev_unregister(struct sys_device * sysdev) | |||
272 | } | 265 | } |
273 | mutex_unlock(&sysdev_drivers_lock); | 266 | mutex_unlock(&sysdev_drivers_lock); |
274 | 267 | ||
275 | kobject_unregister(&sysdev->kobj); | 268 | kobject_put(&sysdev->kobj); |
276 | } | 269 | } |
277 | 270 | ||
278 | 271 | ||
@@ -298,8 +291,7 @@ void sysdev_shutdown(void) | |||
298 | pr_debug("Shutting Down System Devices\n"); | 291 | pr_debug("Shutting Down System Devices\n"); |
299 | 292 | ||
300 | mutex_lock(&sysdev_drivers_lock); | 293 | mutex_lock(&sysdev_drivers_lock); |
301 | list_for_each_entry_reverse(cls, &system_subsys.list, | 294 | list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { |
302 | kset.kobj.entry) { | ||
303 | struct sys_device * sysdev; | 295 | struct sys_device * sysdev; |
304 | 296 | ||
305 | pr_debug("Shutting down type '%s':\n", | 297 | pr_debug("Shutting down type '%s':\n", |
@@ -361,9 +353,7 @@ int sysdev_suspend(pm_message_t state) | |||
361 | 353 | ||
362 | pr_debug("Suspending System Devices\n"); | 354 | pr_debug("Suspending System Devices\n"); |
363 | 355 | ||
364 | list_for_each_entry_reverse(cls, &system_subsys.list, | 356 | list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { |
365 | kset.kobj.entry) { | ||
366 | |||
367 | pr_debug("Suspending type '%s':\n", | 357 | pr_debug("Suspending type '%s':\n", |
368 | kobject_name(&cls->kset.kobj)); | 358 | kobject_name(&cls->kset.kobj)); |
369 | 359 | ||
@@ -414,8 +404,7 @@ aux_driver: | |||
414 | } | 404 | } |
415 | 405 | ||
416 | /* resume other classes */ | 406 | /* resume other classes */ |
417 | list_for_each_entry_continue(cls, &system_subsys.list, | 407 | list_for_each_entry_continue(cls, &system_kset->list, kset.kobj.entry) { |
418 | kset.kobj.entry) { | ||
419 | list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) { | 408 | list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) { |
420 | pr_debug(" %s\n", kobject_name(&err_dev->kobj)); | 409 | pr_debug(" %s\n", kobject_name(&err_dev->kobj)); |
421 | __sysdev_resume(err_dev); | 410 | __sysdev_resume(err_dev); |
@@ -440,7 +429,7 @@ int sysdev_resume(void) | |||
440 | 429 | ||
441 | pr_debug("Resuming System Devices\n"); | 430 | pr_debug("Resuming System Devices\n"); |
442 | 431 | ||
443 | list_for_each_entry(cls, &system_subsys.list, kset.kobj.entry) { | 432 | list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) { |
444 | struct sys_device * sysdev; | 433 | struct sys_device * sysdev; |
445 | 434 | ||
446 | pr_debug("Resuming type '%s':\n", | 435 | pr_debug("Resuming type '%s':\n", |
@@ -458,8 +447,10 @@ int sysdev_resume(void) | |||
458 | 447 | ||
459 | int __init system_bus_init(void) | 448 | int __init system_bus_init(void) |
460 | { | 449 | { |
461 | system_subsys.kobj.parent = &devices_subsys.kobj; | 450 | system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj); |
462 | return subsystem_register(&system_subsys); | 451 | if (!system_kset) |
452 | return -ENOMEM; | ||
453 | return 0; | ||
463 | } | 454 | } |
464 | 455 | ||
465 | EXPORT_SYMBOL_GPL(sysdev_register); | 456 | EXPORT_SYMBOL_GPL(sysdev_register); |