public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch -mm] notifier chain initialization
@ 2006-03-22 16:11 Jes Sorensen
  2006-03-22 17:05 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Jes Sorensen @ 2006-03-22 16:11 UTC (permalink / raw)
  To: Alan Stern; +Cc: Andrew Morton, linux-kernel

Hi,

This one is against the -mm tree, description below.

Cheers,
Jes

This patch goes on top of Alan Stern's
notifier-chain-update-api-changes.patch

It restructures the notifier chain initialization macros by
introducing FOO_NOTIFIER_INIT() macros which are used by the
FOO_NOTIFIER_HEAD() macros.

The benefit is that one can use the FOO_NOTIFIER_INIT() macro for
static initialization of a notifier chain.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 include/linux/notifier.h |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/notifier.h
===================================================================
--- linux-2.6.orig/include/linux/notifier.h
+++ linux-2.6/include/linux/notifier.h
@@ -64,17 +64,24 @@
 		(name)->head = NULL;		\
 	} while (0)
 
-#define ATOMIC_NOTIFIER_HEAD(name)				\
-	struct atomic_notifier_head name = {			\
+#define ATOMIC_NOTIFIER_INIT(name) {				\
 		.mutex = __MUTEX_INITIALIZER((name).mutex),	\
 		.head = NULL }
-#define BLOCKING_NOTIFIER_HEAD(name)				\
-	struct blocking_notifier_head name = {			\
+#define BLOCKING_NOTIFIER_INIT(name) {				\
 		.rwsem = __RWSEM_INITIALIZER((name).rwsem),	\
 		.head = NULL }
+#define RAW_NOTIFIER_INIT(name) {				\
+		.head = NULL }
+
+#define ATOMIC_NOTIFIER_HEAD(name)				\
+	struct atomic_notifier_head name =			\
+		ATOMIC_NOTIFIER_INIT(name)
+#define BLOCKING_NOTIFIER_HEAD(name)				\
+	struct blocking_notifier_head name =			\
+		BLOCKING_NOTIFIER_INIT(name)
 #define RAW_NOTIFIER_HEAD(name)					\
-	struct raw_notifier_head name = {			\
-	.head = NULL }
+	struct raw_notifier_head name =				\
+		RAW_NOTIFIER_INIT(name)
 
 #ifdef __KERNEL__
 

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

* Re: [patch -mm] notifier chain initialization
  2006-03-22 16:11 [patch -mm] notifier chain initialization Jes Sorensen
@ 2006-03-22 17:05 ` Alan Stern
  2006-03-22 21:10   ` Jes Sorensen
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2006-03-22 17:05 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Andrew Morton, linux-kernel

On 22 Mar 2006, Jes Sorensen wrote:

> Hi,
> 
> This one is against the -mm tree, description below.
> 
> Cheers,
> Jes
> 
> This patch goes on top of Alan Stern's
> notifier-chain-update-api-changes.patch
> 
> It restructures the notifier chain initialization macros by
> introducing FOO_NOTIFIER_INIT() macros which are used by the
> FOO_NOTIFIER_HEAD() macros.
> 
> The benefit is that one can use the FOO_NOTIFIER_INIT() macro for
> static initialization of a notifier chain.

You probably mean _dynamic_ initialization of a notifier head.  The 
current code handles static initialization just fine.

There's nothing wrong with doing things like this.  I didn't include 
initialization macros originally simply because there aren't any 
dynamically-initialized notifier heads in the kernel.

Alan Stern


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

* Re: [patch -mm] notifier chain initialization
  2006-03-22 17:05 ` Alan Stern
@ 2006-03-22 21:10   ` Jes Sorensen
  0 siblings, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2006-03-22 21:10 UTC (permalink / raw)
  To: Alan Stern; +Cc: Andrew Morton, linux-kernel

Alan Stern wrote:
>> The benefit is that one can use the FOO_NOTIFIER_INIT() macro for
>> static initialization of a notifier chain.
> 
> You probably mean _dynamic_ initialization of a notifier head.  The 
> current code handles static initialization just fine.

Actually I meant static, I have a notifier declared within a struct and
a macro that initializes it at compile time - didn't work with the old
code.

But I also use it dynamically where this also benefits it.

> There's nothing wrong with doing things like this.  I didn't include 
> initialization macros originally simply because there aren't any 
> dynamically-initialized notifier heads in the kernel.

There probably will be :)

Cheers,
Jes

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

end of thread, other threads:[~2006-03-22 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-22 16:11 [patch -mm] notifier chain initialization Jes Sorensen
2006-03-22 17:05 ` Alan Stern
2006-03-22 21:10   ` Jes Sorensen

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