aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/sys.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:35:13 -0500
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /drivers/base/sys.c
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas: - Documentation updates (language translations and fixes, as well as kobject and kset documenatation updates.) - major kset/kobject/ktype rework and fixes. This cleans up the kset and kobject and ktype relationship and architecture, making sense of things now, and good documenation and samples are provided for others to use. Also the attributes for kobjects are much easier to handle now. This cleaned up a LOT of code all through the kernel, making kobjects easier to use if you want to. - struct bus_type has been reworked to now handle the lifetime rules properly, as the kobject is properly dynamic. - struct driver has also been reworked, and now the lifetime issues are resolved. - the block subsystem has been converted to use struct device now, and not "raw" kobjects. This patch has been in the -mm tree for over a year now, and finally all the issues are worked out with it. Older distros now properly work with new kernels, and no userspace updates are needed at all. - nozomi driver is added. This has also been in -mm for a long time, and many people have asked for it to go in. It is now in good enough shape to do so. - lots of class_device conversions to use struct device instead. The tree is almost all cleaned up now, only SCSI and IB is the remaining code to fix up... * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits) Driver core: coding style fixes Kobject: fix coding style issues in kobject c files Kobject: fix coding style issues in kobject.h Driver core: fix coding style issues in device.h spi: use class iteration api scsi: use class iteration api rtc: use class iteration api power supply : use class iteration api ieee1394: use class iteration api Driver Core: add class iteration api Driver core: Cleanup get_device_parent() in device_add() and device_move() UIO: constify function pointer tables Driver Core: constify the name passed to platform_device_register_simple driver core: fix build with SYSFS=n sysfs: make SYSFS_DEPRECATED depend on SYSFS Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init kobject: add sample code for how to use ksets/ktypes/kobjects kobject: add sample code for how to use kobjects in a simple manner. kobject: update the kobject/kset documentation kobject: remove old, outdated documentation. ...
Diffstat (limited to 'drivers/base/sys.c')
-rw-r--r--drivers/base/sys.c49
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
28extern 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}
129EXPORT_SYMBOL_GPL(sysdev_class_remove_file); 127EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
130 128
131/* 129static struct kset *system_kset;
132 * declare system_subsys
133 */
134static decl_subsys(system, &ktype_sysdev_class, NULL);
135 130
136int sysdev_class_register(struct sysdev_class * cls) 131int 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
459int __init system_bus_init(void) 448int __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
465EXPORT_SYMBOL_GPL(sysdev_register); 456EXPORT_SYMBOL_GPL(sysdev_register);