public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Synchronous hotplug for kobjects
@ 2004-05-10 20:48 Todd Poynor
  2004-05-10 21:19 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Todd Poynor @ 2004-05-10 20:48 UTC (permalink / raw)
  To: greg, linux-hotplug-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-11  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-10 20:48 [PATCH] Synchronous hotplug for kobjects Todd Poynor
2004-05-10 21:19 ` Greg KH
2004-05-11  1:09   ` Todd Poynor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox