All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>,
	torvalds@osdl.org, linux-kernel@vger.kernel.org,
	mochel@digitalimplant.org
Subject: Re: PATCH: (as177) Add class_device_unregister_wait() and platform_device_unregister_wait() to the driver model core
Date: Wed, 28 Jan 2004 09:55:04 +1100	[thread overview]
Message-ID: <20040128005801.403242C069@lists.samba.org> (raw)
In-Reply-To: Your message of "Mon, 26 Jan 2004 10:51:14 CDT." <Pine.LNX.4.44L0.0401261016530.822-100000@ida.rowland.org>

In message <Pine.LNX.4.44L0.0401261016530.822-100000@ida.rowland.org> you write:
> Create a new module entry point, the module_unreg routine.  For all
> existing modules this entry point would be undefined and hence not used.  

Just use the notifier, which already exists, just needs a few more
points.

Cheers!
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: More Module Notifiers
Author: Rusty Russell
Status: Trivial

D: Put in the rest of the module notifiers, esp. one when a module is being
D: removed.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.6.0-test5-bk2/include/linux/module.h working-2.6.0-test5-bk2-nat-expect/include/linux/module.h
--- linux-2.6.0-test5-bk2/include/linux/module.h	2003-07-31 01:50:19.000000000 +1000
+++ working-2.6.0-test5-bk2-nat-expect/include/linux/module.h	2003-09-21 15:24:09.000000000 +1000
@@ -180,6 +180,7 @@ enum module_state
 	MODULE_STATE_LIVE,
 	MODULE_STATE_COMING,
 	MODULE_STATE_GOING,
+	MODULE_STATE_GONE, /* Only for notifier: module about to be freed */
 };
 
 struct module
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.6.0-test5-bk2/kernel/module.c working-2.6.0-test5-bk2-nat-expect/kernel/module.c
--- linux-2.6.0-test5-bk2/kernel/module.c	2003-09-09 10:35:05.000000000 +1000
+++ working-2.6.0-test5-bk2-nat-expect/kernel/module.c	2003-09-21 15:22:36.000000000 +1000
@@ -83,6 +83,13 @@ int unregister_module_notifier(struct no
 }
 EXPORT_SYMBOL(unregister_module_notifier);
 
+static void module_notify(struct module *mod, enum module_state state)
+{
+	down(&notify_mutex);
+	notifier_call_chain(&module_notify_list, state, mod);
+	up(&notify_mutex);
+}
+
 /* We require a truly strong try_module_get() */
 static inline int strong_try_module_get(struct module *mod)
 {
@@ -723,12 +730,15 @@ sys_delete_module(const char __user *nam
 	mod->state = MODULE_STATE_GOING;
 	restart_refcounts();
 
+	module_notify(mod, MODULE_STATE_GOING);
+
 	/* Never wait if forced. */
 	if (!forced && module_refcount(mod) != 0)
 		wait_for_zero_refcount(mod);
 
 	/* Final destruction now noone is using it. */
 	mod->exit();
+	module_notify(mod, MODULE_STATE_GONE);
 	free_module(mod);
 
  out:
@@ -1718,9 +1728,7 @@ sys_init_module(void __user *umod,
 	/* Drop lock so they can recurse */
 	up(&module_mutex);
 
-	down(&notify_mutex);
-	notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
-	up(&notify_mutex);
+	module_notify(mod, MODULE_STATE_COMING);
 
 	/* Start the module */
 	ret = mod->init();
@@ -1728,12 +1736,14 @@ sys_init_module(void __user *umod,
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
 		mod->state = MODULE_STATE_GOING;
+		module_notify(mod, MODULE_STATE_GOING);
 		synchronize_kernel();
 		if (mod->unsafe)
 			printk(KERN_ERR "%s: module is now stuck!\n",
 			       mod->name);
 		else {
 			module_put(mod);
+			module_notify(mod, MODULE_STATE_GONE);
 			down(&module_mutex);
 			free_module(mod);
 			up(&module_mutex);
@@ -1751,6 +1761,7 @@ sys_init_module(void __user *umod,
 	mod->init_size = 0;
 	mod->init_text_size = 0;
 	up(&module_mutex);
+	module_notify(mod, MODULE_STATE_LIVE);
 
 	return 0;
 }

      reply	other threads:[~2004-01-28  0:57 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040128005801.403242C069@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@digitalimplant.org \
    --cc=stern@rowland.harvard.edu \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.