aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject_uevent.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 /lib/kobject_uevent.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 'lib/kobject_uevent.c')
-rw-r--r--lib/kobject_uevent.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 5886147252d0..5a402e2982af 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -98,7 +98,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
98 int i = 0; 98 int i = 0;
99 int retval = 0; 99 int retval = 0;
100 100
101 pr_debug("%s\n", __FUNCTION__); 101 pr_debug("kobject: '%s' (%p): %s\n",
102 kobject_name(kobj), kobj, __FUNCTION__);
102 103
103 /* search the kset we belong to */ 104 /* search the kset we belong to */
104 top_kobj = kobj; 105 top_kobj = kobj;
@@ -106,7 +107,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
106 top_kobj = top_kobj->parent; 107 top_kobj = top_kobj->parent;
107 108
108 if (!top_kobj->kset) { 109 if (!top_kobj->kset) {
109 pr_debug("kobject attempted to send uevent without kset!\n"); 110 pr_debug("kobject: '%s' (%p): %s: attempted to send uevent "
111 "without kset!\n", kobject_name(kobj), kobj,
112 __FUNCTION__);
110 return -EINVAL; 113 return -EINVAL;
111 } 114 }
112 115
@@ -116,7 +119,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
116 /* skip the event, if the filter returns zero. */ 119 /* skip the event, if the filter returns zero. */
117 if (uevent_ops && uevent_ops->filter) 120 if (uevent_ops && uevent_ops->filter)
118 if (!uevent_ops->filter(kset, kobj)) { 121 if (!uevent_ops->filter(kset, kobj)) {
119 pr_debug("kobject filter function caused the event to drop!\n"); 122 pr_debug("kobject: '%s' (%p): %s: filter function "
123 "caused the event to drop!\n",
124 kobject_name(kobj), kobj, __FUNCTION__);
120 return 0; 125 return 0;
121 } 126 }
122 127
@@ -126,7 +131,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
126 else 131 else
127 subsystem = kobject_name(&kset->kobj); 132 subsystem = kobject_name(&kset->kobj);
128 if (!subsystem) { 133 if (!subsystem) {
129 pr_debug("unset subsystem caused the event to drop!\n"); 134 pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the "
135 "event to drop!\n", kobject_name(kobj), kobj,
136 __FUNCTION__);
130 return 0; 137 return 0;
131 } 138 }
132 139
@@ -166,12 +173,24 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
166 if (uevent_ops && uevent_ops->uevent) { 173 if (uevent_ops && uevent_ops->uevent) {
167 retval = uevent_ops->uevent(kset, kobj, env); 174 retval = uevent_ops->uevent(kset, kobj, env);
168 if (retval) { 175 if (retval) {
169 pr_debug ("%s - uevent() returned %d\n", 176 pr_debug("kobject: '%s' (%p): %s: uevent() returned "
170 __FUNCTION__, retval); 177 "%d\n", kobject_name(kobj), kobj,
178 __FUNCTION__, retval);
171 goto exit; 179 goto exit;
172 } 180 }
173 } 181 }
174 182
183 /*
184 * Mark "add" and "remove" events in the object to ensure proper
185 * events to userspace during automatic cleanup. If the object did
186 * send an "add" event, "remove" will automatically generated by
187 * the core, if not already done by the caller.
188 */
189 if (action == KOBJ_ADD)
190 kobj->state_add_uevent_sent = 1;
191 else if (action == KOBJ_REMOVE)
192 kobj->state_remove_uevent_sent = 1;
193
175 /* we will send an event, so request a new sequence number */ 194 /* we will send an event, so request a new sequence number */
176 spin_lock(&sequence_lock); 195 spin_lock(&sequence_lock);
177 seq = ++uevent_seqnum; 196 seq = ++uevent_seqnum;
@@ -219,11 +238,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
219 retval = add_uevent_var(env, "HOME=/"); 238 retval = add_uevent_var(env, "HOME=/");
220 if (retval) 239 if (retval)
221 goto exit; 240 goto exit;
222 retval = add_uevent_var(env, "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); 241 retval = add_uevent_var(env,
242 "PATH=/sbin:/bin:/usr/sbin:/usr/bin");
223 if (retval) 243 if (retval)
224 goto exit; 244 goto exit;
225 245
226 call_usermodehelper (argv[0], argv, env->envp, UMH_WAIT_EXEC); 246 call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
227 } 247 }
228 248
229exit: 249exit:
@@ -231,7 +251,6 @@ exit:
231 kfree(env); 251 kfree(env);
232 return retval; 252 return retval;
233} 253}
234
235EXPORT_SYMBOL_GPL(kobject_uevent_env); 254EXPORT_SYMBOL_GPL(kobject_uevent_env);
236 255
237/** 256/**
@@ -247,7 +266,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action)
247{ 266{
248 return kobject_uevent_env(kobj, action, NULL); 267 return kobject_uevent_env(kobj, action, NULL);
249} 268}
250
251EXPORT_SYMBOL_GPL(kobject_uevent); 269EXPORT_SYMBOL_GPL(kobject_uevent);
252 270
253/** 271/**