All of lore.kernel.org
 help / color / mirror / Atom feed
* PATCH: (as177)  Add class_device_unregister_wait() and platform_device_unregister_wait() to the driver model core
@ 2004-01-23 16:58 Alan Stern
  2004-01-23 17:42 ` Linus Torvalds
  0 siblings, 1 reply; 38+ messages in thread
From: Alan Stern @ 2004-01-23 16:58 UTC (permalink / raw)
  To: Greg KH, Patrick Mochel; +Cc: Kernel development list

Since I haven't seen any progress towards implementing the 
class_device_unregister_wait() and platform_device_unregister_wait() 
functions, here is my attempt.  This also fixes an unnecessary WARN_ON 
about devices with no release() function if the completion pointer is set.

Alan Stern


===== device.h 1.89 vs edited =====
--- 1.89/include/linux/device.h	Tue Jan 20 11:58:44 2004
+++ edited/include/linux/device.h	Fri Jan 23 11:00:34 2004
@@ -186,6 +186,7 @@
 struct class_device {
 	struct list_head	node;
 
+	struct completion	* complete;	/* Notification for freeing. */
 	struct kobject		kobj;
 	struct class		* class;	/* required */
 	struct device		* dev;		/* not necessary, but nice to have */
@@ -209,6 +210,7 @@
 
 extern int class_device_register(struct class_device *);
 extern void class_device_unregister(struct class_device *);
+extern void class_device_unregister_wait(struct class_device *);
 extern void class_device_initialize(struct class_device *);
 extern int class_device_add(struct class_device *);
 extern void class_device_del(struct class_device *);
@@ -380,6 +382,7 @@
 
 extern int platform_device_register(struct platform_device *);
 extern void platform_device_unregister(struct platform_device *);
+extern void platform_device_unregister_wait(struct platform_device *);
 
 extern struct bus_type platform_bus_type;
 extern struct device platform_bus;
===== class.c 1.45 vs edited =====
--- 1.45/drivers/base/class.c	Tue Jan 20 17:07:57 2004
+++ edited/drivers/base/class.c	Fri Jan 23 11:05:57 2004
@@ -205,17 +205,20 @@
 {
 	struct class_device *cd = to_class_dev(kobj);
 	struct class * cls = cd->class;
+	struct completion * c = cd->complete;
 
 	pr_debug("device class '%s': release.\n",cd->class_id);
 
 	if (cls->release)
 		cls->release(cd);
-	else {
+	else if (!c) {
 		printk(KERN_ERR "Device class '%s' does not have a release() function, "
 			"it is broken and must be fixed.\n",
 			cd->class_id);
 		WARN_ON(1);
 	}
+	if (c)
+		complete(c);
 }
 
 static struct kobj_type ktype_class_device = {
@@ -363,6 +366,16 @@
 	class_device_put(class_dev);
 }
 
+void class_device_unregister_wait(struct class_device *class_dev)
+{
+	struct completion c;
+
+	init_completion(&c);
+	class_dev->complete = &c;
+	class_device_unregister(class_dev);
+	wait_for_completion(&c);
+}
+
 int class_device_rename(struct class_device *class_dev, char *new_name)
 {
 	class_dev = class_device_get(class_dev);
@@ -470,6 +483,7 @@
 
 EXPORT_SYMBOL(class_device_register);
 EXPORT_SYMBOL(class_device_unregister);
+EXPORT_SYMBOL(class_device_unregister_wait);
 EXPORT_SYMBOL(class_device_initialize);
 EXPORT_SYMBOL(class_device_add);
 EXPORT_SYMBOL(class_device_del);
===== core.c 1.73 vs edited =====
--- 1.73/drivers/base/core.c	Tue Jan 20 17:07:57 2004
+++ edited/drivers/base/core.c	Wed Jan 21 11:43:24 2004
@@ -83,7 +83,7 @@
 
 	if (dev->release)
 		dev->release(dev);
-	else {
+	else if (!c) {
 		printk(KERN_ERR "Device '%s' does not have a release() function, "
 			"it is broken and must be fixed.\n",
 			dev->bus_id);
===== platform.c 1.11 vs edited =====
--- 1.11/drivers/base/platform.c	Tue Dec 30 13:25:09 2003
+++ edited/drivers/base/platform.c	Fri Jan 23 11:06:44 2004
@@ -46,6 +46,12 @@
 		device_unregister(&pdev->dev);
 }
 
+void platform_device_unregister_wait(struct platform_device * pdev)
+{
+	if (pdev)
+		device_unregister_wait(&pdev->dev);
+}
+
 
 /**
  *	platform_match - bind platform device to platform driver.
@@ -113,3 +119,4 @@
 EXPORT_SYMBOL(platform_bus_type);
 EXPORT_SYMBOL(platform_device_register);
 EXPORT_SYMBOL(platform_device_unregister);
+EXPORT_SYMBOL(platform_device_unregister_wait);


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

end of thread, other threads:[~2004-01-29  0:32 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-23 16:58 PATCH: (as177) Add class_device_unregister_wait() and platform_device_unregister_wait() to the driver model core Alan Stern
2004-01-23 17:42 ` Linus Torvalds
2004-01-23 18:03   ` Alan Stern
2004-01-23 18:10     ` viro
2004-01-23 18:18       ` Greg KH
2004-01-23 18:15     ` Linus Torvalds
2004-01-23 18:31       ` Greg KH
2004-01-23 18:11   ` Greg KH
2004-01-23 18:19     ` Linus Torvalds
2004-01-23 18:27       ` Greg KH
2004-01-25 17:32       ` Alan Stern
2004-01-25 19:02         ` Linus Torvalds
2004-01-25 20:21           ` viro
2004-01-27  6:51             ` Rusty Russell
2004-01-27 13:56               ` Roman Zippel
2004-01-27 23:29                 ` Rusty Russell
2004-01-28  2:36                   ` Roman Zippel
2004-01-28  3:54                     ` Rusty Russell
2004-01-25 23:12           ` Steve Youngs
2004-01-26  3:22             ` Adam Kropelin
2004-01-26  5:06               ` Steve Youngs
2004-01-26  5:21                 ` Valdis.Kletnieks
2004-01-26  5:55                   ` Steve Youngs
2004-01-26  6:25                     ` Valdis.Kletnieks
2004-01-26  8:48                     ` Helge Hafting
2004-01-26 15:50                 ` Adam Kropelin
2004-01-26 16:22           ` Roman Zippel
2004-01-27 19:32             ` Russell King
2004-01-27 20:28               ` Greg KH
2004-01-27 20:29             ` Greg KH
2004-01-28  2:03               ` Roman Zippel
2004-01-28  2:17                 ` viro
2004-01-28  2:53                   ` Roman Zippel
2004-01-27  6:41           ` Rusty Russell
2004-01-23 19:45     ` viro
2004-01-26  5:50     ` Rusty Russell
2004-01-26 15:51       ` Alan Stern
2004-01-27 22:55         ` Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.