diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-13 22:25:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-04-27 13:57:28 -0400 |
commit | 864062457a2e444227bd368ca5f2a2b740de604f (patch) | |
tree | 38e516852ee9825b5ffe0b1f2e8abea0a88b1674 /lib | |
parent | 00ed8e3dda47f8421b11da17e353d7db8c878121 (diff) |
driver core: fix namespace issue with devices assigned to classes
- uses a kset in "struct class" to keep track of all directories
belonging to this class
- merges with the /sys/devices/virtual logic.
- removes the namespace-dir if the last member of that class
leaves the directory.
There may be locking or refcounting fixes left, I stopped when it seemed
to work with network and sound modules. :)
From: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 12 | ||||
-rw-r--r-- | lib/kobject_uevent.c | 16 |
2 files changed, 20 insertions, 8 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 057921c5945a..f66455155606 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -488,13 +488,15 @@ static struct kobj_type dir_ktype = { | |||
488 | }; | 488 | }; |
489 | 489 | ||
490 | /** | 490 | /** |
491 | * kobject_add_dir - add sub directory of object. | 491 | * kobject__kset_add_dir - add sub directory of object. |
492 | * @kset: kset the directory is belongs to. | ||
492 | * @parent: object in which a directory is created. | 493 | * @parent: object in which a directory is created. |
493 | * @name: directory name. | 494 | * @name: directory name. |
494 | * | 495 | * |
495 | * Add a plain directory object as child of given object. | 496 | * Add a plain directory object as child of given object. |
496 | */ | 497 | */ |
497 | struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | 498 | struct kobject *kobject_kset_add_dir(struct kset *kset, |
499 | struct kobject *parent, const char *name) | ||
498 | { | 500 | { |
499 | struct kobject *k; | 501 | struct kobject *k; |
500 | int ret; | 502 | int ret; |
@@ -506,6 +508,7 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | |||
506 | if (!k) | 508 | if (!k) |
507 | return NULL; | 509 | return NULL; |
508 | 510 | ||
511 | k->kset = kset; | ||
509 | k->parent = parent; | 512 | k->parent = parent; |
510 | k->ktype = &dir_ktype; | 513 | k->ktype = &dir_ktype; |
511 | kobject_set_name(k, name); | 514 | kobject_set_name(k, name); |
@@ -520,6 +523,11 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | |||
520 | return k; | 523 | return k; |
521 | } | 524 | } |
522 | 525 | ||
526 | struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | ||
527 | { | ||
528 | return kobject_kset_add_dir(NULL, parent, name); | ||
529 | } | ||
530 | |||
523 | /** | 531 | /** |
524 | * kset_init - initialize a kset for use | 532 | * kset_init - initialize a kset for use |
525 | * @k: kset | 533 | * @k: kset |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 82fc1794b691..4122f38330d4 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
@@ -115,6 +115,16 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | /* originating subsystem */ | ||
119 | if (uevent_ops && uevent_ops->name) | ||
120 | subsystem = uevent_ops->name(kset, kobj); | ||
121 | else | ||
122 | subsystem = kobject_name(&kset->kobj); | ||
123 | if (!subsystem) { | ||
124 | pr_debug("unset subsytem caused the event to drop!\n"); | ||
125 | return 0; | ||
126 | } | ||
127 | |||
118 | /* environment index */ | 128 | /* environment index */ |
119 | envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); | 129 | envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); |
120 | if (!envp) | 130 | if (!envp) |
@@ -134,12 +144,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
134 | goto exit; | 144 | goto exit; |
135 | } | 145 | } |
136 | 146 | ||
137 | /* originating subsystem */ | ||
138 | if (uevent_ops && uevent_ops->name) | ||
139 | subsystem = uevent_ops->name(kset, kobj); | ||
140 | else | ||
141 | subsystem = kobject_name(&kset->kobj); | ||
142 | |||
143 | /* event environemnt for helper process only */ | 147 | /* event environemnt for helper process only */ |
144 | envp[i++] = "HOME=/"; | 148 | envp[i++] = "HOME=/"; |
145 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | 149 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |