lkml.org 
[lkml]   [2003]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH][2.6][CFT] rmmod floppy kills box fixes + default_device_remove
On Tue, 9 Sep 2003, Greg KH wrote:

> Ugh. Sure, point out the theoretical :)
>
> Any thoughts on how to solve this?

How about something like the following, the kobj_type.done is passed from
the driver so the driver's presence can maintain it's persistence and
we're guaranteed that the ->release() function is not running on a
processor at completion time.

Index: linux-2.6.0-test5/drivers/base/core.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test5/drivers/base/core.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 core.c
--- linux-2.6.0-test5/drivers/base/core.c 8 Sep 2003 22:07:57 -0000 1.1.1.1
+++ linux-2.6.0-test5/drivers/base/core.c 9 Sep 2003 18:38:45 -0000
@@ -334,6 +334,14 @@ void device_del(struct device * dev)

}

+void device_release_notify(struct device *dev, struct completion *done)
+{
+ struct kobj_type *ktype = get_ktype(&dev->kobj);
+
+ init_completion(done);
+ ktype->done = done;
+}
+
/**
* device_unregister - unregister device from system.
* @dev: device going away.
Index: linux-2.6.0-test5/lib/kobject.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test5/lib/kobject.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 kobject.c
--- linux-2.6.0-test5/lib/kobject.c 8 Sep 2003 22:08:55 -0000 1.1.1.1
+++ linux-2.6.0-test5/lib/kobject.c 9 Sep 2003 18:10:50 -0000
@@ -448,8 +448,12 @@ void kobject_cleanup(struct kobject * ko
if (kobj->k_name != kobj->name)
kfree(kobj->k_name);
kobj->k_name = NULL;
- if (t && t->release)
+ if (t && t->release) {
t->release(kobj);
+ if (t->done)
+ complete(t->done);
+ }
+
if (s)
kset_put(s);
}
Index: linux-2.6.0-test5/include/linux/kobject.h
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test5/include/linux/kobject.h,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 kobject.h
--- linux-2.6.0-test5/include/linux/kobject.h 8 Sep 2003 22:08:50 -0000 1.1.1.1
+++ linux-2.6.0-test5/include/linux/kobject.h 9 Sep 2003 17:47:19 -0000
@@ -59,6 +59,7 @@ extern void kobject_put(struct kobject *

struct kobj_type {
void (*release)(struct kobject *);
+ struct completion * done;
struct sysfs_ops * sysfs_ops;
struct attribute ** default_attrs;
};

Then in the driver module_exit;

void cleanup_module(void)
{
...
struct completion done;
struct device *dev = ...
device_release_notify(dev, &done);

...

wait_for_completion(&done);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.047 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site