[PATCH] Synchronous hotplug for kobjects
From: Todd Poynor
Date: Mon May 10 2004 - 15:49:57 EST
As discussed recently, it's expected to be useful to generate
synchronous hotplug events from the kobject subsystem in certain
situations. This patch adds a kobject_hotplug_wait function that issues
a synchronous call. The function should be used for appropriate actions
that require synchronous semantics; please note many hotplug events
would suffer severe performance degradation if issued synchronously, and
one should exercise caution in choosing to use this function.
--- linux-2.6.6-orig/include/linux/kobject.h 2004-05-10 11:23:55.000000000 -0700
+++ linux-2.6.6-pm/include/linux/kobject.h 2004-05-10 11:41:25.000000000 -0700
@@ -57,6 +57,7 @@
extern void kobject_put(struct kobject *);
extern void kobject_hotplug(const char *action, struct kobject *);
+extern void kobject_hotplug_wait(const char *action, struct kobject *);
struct kobj_type {
void (*release)(struct kobject *);
--- linux-2.6.6-orig/lib/kobject.c 2004-05-10 11:26:35.000000000 -0700
+++ linux-2.6.6-pm/lib/kobject.c 2004-05-10 13:20:35.389369032 -0700
@@ -104,7 +104,7 @@
static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
static void kset_hotplug(const char *action, struct kset *kset,
- struct kobject *kobj)
+ struct kobject *kobj, int wait)
{
char *argv [3];
char **envp = NULL;
@@ -185,9 +185,9 @@
}
}
- pr_debug ("%s: %s %s %s %s %s %s %s\n", __FUNCTION__, argv[0], argv[1],
- envp[0], envp[1], envp[2], envp[3], envp[4]);
- retval = call_usermodehelper (argv[0], argv, envp, 0);
+ pr_debug ("%s: %s %s %s %s %s %s %s %d\n", __FUNCTION__, argv[0], argv[1],
+ envp[0], envp[1], envp[2], envp[3], envp[4], wait);
+ retval = call_usermodehelper (argv[0], argv, envp, wait);
if (retval)
pr_debug ("%s - call_usermodehelper returned %d\n",
__FUNCTION__, retval);
@@ -199,7 +199,8 @@
return;
}
-void kobject_hotplug(const char *action, struct kobject *kobj)
+static void kobject_hotplug_flags(const char *action, struct kobject *kobj,
+ int wait)
{
struct kobject * top_kobj = kobj;
@@ -212,13 +213,27 @@
}
if (top_kobj->kset && top_kobj->kset->hotplug_ops)
- kset_hotplug(action, top_kobj->kset, kobj);
+ kset_hotplug(action, top_kobj->kset, kobj, wait);
+}
+
+void kobject_hotplug(const char *action, struct kobject *kobj)
+{
+ kobject_hotplug_flags(action, kobj, 0);
+}
+
+void kobject_hotplug_wait(const char *action, struct kobject *kobj)
+{
+ kobject_hotplug_flags(action, kobj, 1);
}
#else
void kobject_hotplug(const char *action, struct kobject *kobj)
{
return;
}
+void kobject_hotplug_wait(const char *action, struct kobject *kobj)
+{
+ return;
+}
#endif /* CONFIG_HOTPLUG */
/**
--
Todd Poynor
MontaVista Software
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/