summaryrefslogtreecommitdiffstats
path: root/lib/kobject_uevent.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-12-19 01:40:42 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 20:40:39 -0800
commit0f4dafc0563c6c49e17fe14b3f5f356e4c4b8806 (patch)
treef4ded2831853cb6ea328d15d72871db6f8c22610 /lib/kobject_uevent.c
parent12e339ac6e31a34fe42396aec8fb1c0b43caf61e (diff)
downloadop-kernel-dev-0f4dafc0563c6c49e17fe14b3f5f356e4c4b8806.zip
op-kernel-dev-0f4dafc0563c6c49e17fe14b3f5f356e4c4b8806.tar.gz
Kobject: auto-cleanup on final unref
We save the current state in the object itself, so we can do proper cleanup when the last reference is dropped. If the initial reference is dropped, the object will be removed from sysfs if needed, if an "add" event was sent, "remove" will be send, and the allocated resources are released. This allows us to clean up some driver core usage as well as allowing us to do other such changes to the rest of the kernel. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject_uevent.c')
-rw-r--r--lib/kobject_uevent.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 51dc4d2..b021e67 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -180,6 +180,17 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
}
}
+ /*
+ * Mark "add" and "remove" events in the object to ensure proper
+ * events to userspace during automatic cleanup. If the object did
+ * send an "add" event, "remove" will automatically generated by
+ * the core, if not already done by the caller.
+ */
+ if (action == KOBJ_ADD)
+ kobj->state_add_uevent_sent = 1;
+ else if (action == KOBJ_REMOVE)
+ kobj->state_remove_uevent_sent = 1;
+
/* we will send an event, so request a new sequence number */
spin_lock(&sequence_lock);
seq = ++uevent_seqnum;
OpenPOWER on IntegriCloud